CyberSource Intergration with PHP

Discussion in 'PHP' started by mulatto401, Mar 28, 2008.

  1. #1
    Hi All,
    I'm having trouble trying to get integrated with CyberSource's gateway. I am trying to use the Simple Order API and I do believe you have to send your requests to https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/

    Here is the code that does the work and when I output the Response this is the I get: soap:Client XML parse error. Start of root element expected.

    Code:

    $authnet_values = array
    (
    "merchantID" => getMerchantID(),
    "merchantReferenceCode" => rand(1111111111, 9999999999),
    //"orderPage_transactionType" => "authorization",
    //"orderPage_timestamp" => $AUTH[0],
    //"orderPage_signaturePublic" => $AUTH[1],
    //"orderPage_serialNumber" => $AUTH[2],
    //"orderPage_version" => "4",
    "ccAuthService_run" => "TRUE",
    "card_cardType" => $_POST['card_type'],
    "card_accountNumber" => $_POST['ACCT'],
    "card_expirationMonth" => $EXP[0].$EXP[1],
    "card_expirationYear" => '20'.$EXP[2].$EXP[3],
    "card_cvNumber" => $_POST['CVV2'],
    "purchaseTotals_grandTotalAmount" => number_format($Cart->Total, 2, '.', ''),
    "billTo_firstName" => $Cart->bill_fname,
    "billTo_lastName" => $Cart->bill_lname,
    "billTo_street1" => $Cart->bill_address,
    "billTo_street2" => $Cart->bill_address2,
    "billTo_city" => $Cart->bill_city,
    "billTo_state" => $Cart->bill_state,
    "billTo_postalCode" => $Cart->bill_zip,
    "billTo_country" => $Cart->bill_country,
    "billTo_phoneNumber" => $Cart->bill_phone,
    "billTo_email" => $Cart->bill_email,
    "shipTo_firstName" => $Cart->ship_fname,
    "shipTo_lastName" => $Cart->ship_lname,
    "shipTo_street1" => $Cart->ship_address,
    "shipTo_street2" => $Cart->ship_address2,
    "shipTo_city" => $Cart->ship_city,
    "shipTo_state" => $Cart->ship_state,
    "shipTo_postalCode" => $Cart->ship_zip,
    "shipTo_country" => $Cart->ship_country,
    "shipTo_phoneNumber" => $Cart->ship_phone,
    "shipTo_email" => $Cart->ship_email,
    "taxAmount" => $Cart->Tax,
    );

    $fields = "";
    foreach( $authnet_values as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&";

    $ch = curl_init("https://ics2ws.ic3.com/commerce/1.x/transactionProcessor");
    curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
    curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
    ### curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
    $resp = curl_exec($ch); //execute post and get results
    curl_close ($ch);

    echo $fields.'<br>'.$resp;
     
    mulatto401, Mar 28, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    jestep, Mar 28, 2008 IP