[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2168
  • Last Modified:

LinkPoint API problem

I implemented the linkpoint API and getting this message in debug mode.Please Help.

It took long time to get this response message from linkpoint.

Port : 1129 is opened on my server i confirmed with my hosting.
at curl_process, incoming data: 
host = secure.linkpt.net
port = 1129
keyfile = /home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/xxxxxxx.pem
configfile = xxxxxxx
ordertype = PREAUTH
result = LIVE
transactionorigin = ECI
ponumber = 1002
taxexempt = Y
terminaltype = UNSPECIFIED
ip = 122.163.182.184
tax = 0.00
chargetotal = 1.00
cardnumber = 4111111111111111
cardexpmonth = 01
cardexpyear = 14
cvmindicator = provided
cvmvalue = 692
userid = 4
name = sunny jain
company = 
address1 = richfield drive
address2 = 
city = san jose
state = CA
country = US
phone = 9830098300
addrnum = richfield drive
zip = 700055
sname = sunny jain
saddress1 = richfield drive
saddress2 = 
scity = san jose
sstate = CA
szip = 700055
scountry = US

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/lphp.php on line 172
items = 
debugging = true

sending xml string:
<order><orderoptions><ordertype>PREAUTH</ordertype><result>LIVE</result></orderoptions><creditcard><cardnumber>4111111111111111</cardnumber><cardexpmonth>01</cardexpmonth><cardexpyear>14</cardexpyear><cvmvalue>692</cvmvalue><cvmindicator>provided</cvmindicator></creditcard><billing><name>sunny jain</name><company></company><address1>richfield drive</address1><address2></address2><city>san jose</city><state>CA</state><zip>700055</zip><country>US</country><userid>4</userid><phone>9830098300</phone><addrnum>richfield drive</addrnum></billing><shipping><name>sunny jain</name><address1>richfield drive</address1><address2></address2><city>san jose</city><state>CA</state><zip>700055</zip><country>US</country></shipping><transactiondetails><ponumber>1002</ponumber><taxexempt>Y</taxexempt><terminaltype>UNSPECIFIED</terminaltype><ip>122.163.182.184</ip><transactionorigin>ECI</transactionorigin></transactiondetails><merchantinfo><configfile>1306468</configfile><keyfile>/home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/1306468.pem</keyfile><host>secure.linkpt.net</host><port>1129</port></merchantinfo><payment><chargetotal>1.00</chargetotal><tax>0.00</tax></payment> <items> <item> <id>78</id> <description>testing</description> <quantity>1</quantity> <price>0.50</price> </item> </items> </order>


Warning: Cannot modify header information - headers already sent by (output started at /home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/lphp.php:169) in /home/hsrgnh9/public_html/catalog/includes/functions/general.php on line 33

Open in new window

linkpointFiles.zip
0
sdugar
Asked:
sdugar
  • 12
  • 11
1 Solution
 
Ray PaseurCommented:
Please post code in the code snippets.  No offense meant, but I'm reluctant to open ZIP files.  Thanks.

Regarding this:
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/lphp.php on line 172

That's pretty clear.  What does that line of code say?  Does it come from your script or did it get returned from LinkPoint?
0
 
sdugarAuthor Commented:

This gets returned from Linkpoint
[code]
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/lphp.php on line 172
[/code]
0
 
Ray PaseurCommented:
Wow, then we know two things.  They are using PHP to run their API, and they are using it wrong.  There is nothing you can do on your side of this problem.   You need to show this to LinkPoint - they have to make the fix in their program code that runs the API.  Show them this question thread and they will probably understand and be able to find the error quickly.

Best of luck with it, ~Ray
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
sdugarAuthor Commented:
Hi,

Thanks for the reply.But many people are using the gateway how can we expect they are doing wrong.I am not experienced php guy.

these errors are filled on oscommerce forums too and many of they get it worked.

see here
http://forums.oscommerce.com/topic/260233-linkpoint-api-problems/

regards,
Sunny
0
 
Ray PaseurCommented:
OK, I read that thread.

Do you have the code for this script installed on your computer?
/home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/lphp.php

If so, can you please post the code here in the code snippet? Remove any passwords, but leave author and copyright information intact and please be sure the line numbers you post here match the line numbers in the script and error message.
0
 
sdugarAuthor Commented:
Please see the code snippet added.

regards,
Sunny
File Linkpoint_API.php

code follows 
==================================================
class linkpoint_api {
  var $code, $title, $description, $enabled, $cc_type, $transtype, $transmode, $zipcode, $states, $bstate, $sstate;
  // class constructor
  function linkpoint_api() {
    global $order;
    $this->code = 'linkpoint_api';
    $this->title = MODULE_PAYMENT_LINKPOINT_API_TEXT_TITLE;
    $this->description = MODULE_PAYMENT_LINKPOINT_API_TEXT_DESCRIPTION;
    $this->enabled = ((MODULE_PAYMENT_LINKPOINT_API_STATUS == 'True') ? true : false);
    $this->sort_order = MODULE_PAYMENT_LINKPOINT_API_SORT_ORDER;
    $this->states = $this->_state_list();
    if ((int)MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID > 0) {
      $this->order_status = MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID;
    }
    if (is_object($order)) $this->update_status();
  }

  // class methods
  function filterLinkPoint($strToFilter){
    $strToFilter=str_replace("&", " and ", $strToFilter);
    $strToFilter=str_replace("�", "u", $strToFilter);

    return $strToFilter;
  }

  //in string check
  function in_string($haystack,$needle){
    if(stristr($haystack, $needle) === FALSE){
      return false;
    }else{
      return true;
    }
  }

  function update_status() {
    global $order;
    if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_LINKPOINT_API_ZONE > 0) ) {
      $check_flag = false;
      $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_LINKPOINT_API_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
      while ($check = tep_db_fetch_array($check_query)) {
        if ($check['zone_id'] < 1) {
          $check_flag = true;
          break;
        } elseif ($check['zone_id'] == $order->billing['zone_id']) {
          $check_flag = true;
          break;
        }
      }
      if ($check_flag == false) {
        $this->enabled = false;
      }
    }
  }

  function javascript_validation() {
    $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
    //            '    var cc_owner = document.checkout_payment.linkpoint_api_cc_owner.value;' . "\n" .
            '    var cc_number = document.checkout_payment.linkpoint_api_cc_number.value;' . "\n" .
    //            '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
    //            '      error_message = error_message + "' . MODULE_PAYMENT_LINKPOINT_API_TEXT_JS_CC_OWNER . '";' . "\n" .
    //            '      error = 1;' . "\n" .
    //            '    }' . "\n" .
            '    if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .
            '      error_message = error_message + "' . MODULE_PAYMENT_LINKPOINT_API_TEXT_JS_CC_NUMBER . '";' . "\n" .
            '      error = 1;' . "\n" .
            '    if (cc_number == "" || cc_number.length < 3) {' . "\n" .
            '      error_message = error_message + "' . MODULE_PAYMENT_LINKPOINT_API_TEXT_JS_CVV_NUMBER . '";' . "\n" .
            '      error = 1;' . "\n" .                                             
            '    }' . "\n" .
            '  }' . "\n";

    return $js;
  }

  function selection() {
    global $order;

    for ($i=1; $i<13; $i++) {
      $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%m - %B',mktime(0,0,0,$i,1,2000)));
    }

    $today = getdate();
    for ($i=$today['year']; $i < $today['year']+10; $i++) {
      $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));
    }
    $selection = array('id' => $this->code,
                         'module' => $this->title,
                         'fields' => array(array('title' => '<img src="'.DIR_WS_IMAGES.'cclogos.gif"><br><br>',
    //                                                 'field' => '<br><br><br>'.tep_draw_input_field('linkpoint_api_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),
                                                 'field' => ''),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_NUMBER,
                                                 'field' => tep_draw_input_field('linkpoint_api_cc_number')),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_EXPIRES,
                                                 'field' => tep_draw_pull_down_menu('linkpoint_api_cc_expires_month', $expires_month) . '&nbsp;' . tep_draw_pull_down_menu('linkpoint_api_cc_expires_year', $expires_year)),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_CHECK_VALUE,
    //                                                 'field' => tep_draw_input_field('linkpoint_api_cc_cvm', '', 'size="4" maxlength="4"') . '&nbsp;&nbsp;(last 3 or 4 digits on back of credit card)<br>' . '&nbsp;&nbsp;</small>'),
                                                'field' => tep_draw_input_field('linkpoint_api_cc_cvm', '', 'size="4" maxlength="4"') . '<img src="spacer.gif" width="13" height="1"><a href="javascript:popupWindow(\''.DIR_WS_IMAGES.'cvv2.html\')" class="articleLink"><img src="'.DIR_WS_IMAGES.'cvv.gif" title="Visa/Mastercard" alt="Visa/Mastercard" align="top" border="0"><img src="spacer.gif" width="5" height="1" border="0"><img src="'.DIR_WS_IMAGES.'cvv-amex.gif" align="top" alt="American Express" title="American Express" border="0"><img src="spacer.gif" width="15" height="1" border="0">Where?</a>')));

    return $selection;
  }

  function pre_confirmation_check() {
    global $HTTP_POST_VARS;

    include(DIR_WS_CLASSES . 'cc_validation.php');

    $cc_validation = new cc_validation();
    $result = $cc_validation->validate($HTTP_POST_VARS['linkpoint_api_cc_number'], $HTTP_POST_VARS['linkpoint_api_cc_expires_month'], $HTTP_POST_VARS['linkpoint_api_cc_expires_year']);
    $error = '';
    switch ($result) {
      case -1:
        $error = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4), strlen($cc_validation->cc_number) );
        break;
      case -2:
      case -3:
      case -4:
        $error = TEXT_CCVAL_ERROR_INVALID_DATE;
        break;
      case false:
        $error = TEXT_CCVAL_ERROR_INVALID_NUMBER;
        break;
    }
    if ( ($result == false) || ($result < 1) ) {
      $payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&linkpoint_api_cc_expires_month=' . $HTTP_POST_VARS['linkpoint_api_cc_expires_month'] . '&linkpoint_api_cc_expires_year=' . $HTTP_POST_VARS['linkpoint_api_cc_expires_year'] . '&linkpoint_api_cc_cvm=' . $HTTP_POST_VARS['linkpoint_api_cc_cvm'];
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false));
    }
    $this->cc_card_type = $cc_validation->cc_type;
    $this->cc_card_number = $cc_validation->cc_number;
    $this->cc_expiry_month = $cc_validation->cc_expiry_month;
    $this->cc_expiry_year = $cc_validation->cc_expiry_year;
    $this->cc_cvm = $HTTP_POST_VARS['linkpoint_api_cc_cvm'];
    $this->cc_nocvm = $HTTP_POST_VARS['linkpoint_api_cc_nocvm'];
  }

  function confirmation() {
    global $HTTP_POST_VARS, $order;
    $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,
                            'fields' => array(array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_OWNER,
                                                    'field' => $order->billing['firstname'] . ' ' . $order->billing['lastname']),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_NUMBER,
                                                    'field' => substr($this->cc_card_number, 0, 4) . str_repeat('X', (strlen($this->cc_card_number) - 8)) . substr($this->cc_card_number, -4)),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_EXPIRES,
                                                    'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['linkpoint_api_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['linkpoint_api_cc_expires_year'])))));
    return $confirmation;
  }

  function process_button() {
    global $HTTP_SERVER_VARS, $order, $customer_id;
    $sequence = rand(1, 1000);
    $process_button_string = tep_draw_hidden_field('cc_owner', $_POST['cc_owner']) .
    tep_draw_hidden_field('cc_expires', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) .
    tep_draw_hidden_field('cc_expires_month', $this->cc_expiry_month) .
    tep_draw_hidden_field('cc_expires_year', substr($this->cc_expiry_year, -2)) .
    tep_draw_hidden_field('cc_type', $this->cc_card_type) .
    tep_draw_hidden_field('cc_number', $this->cc_card_number) .
    tep_draw_hidden_field('userid', $customer_id) .
    tep_draw_hidden_field('cc_cvv', $this->cc_cvm);
    //                               tep_draw_hidden_field('cc_cvv', $_POST['cc_cvmvalue']);

    if ($order->billing['country']['iso_code_2'] == 'US') {
      $this->bstate = $this->states[strtoupper($order->billing['state'])];
      if ($this->bstate == '') {
        $this->bstate = $order->billing[state];
      }
      $process_button_string .= tep_draw_hidden_field('bstate', $this->bstate);
    } else {
      $process_button_string .= tep_draw_hidden_field('bstate', $order->billing[state]);
    }

    if ($order->delivery['country']['iso_code_2'] == 'US') {
      $this->sstate = $this->states[strtoupper($order->delivery['state'])];
      if ($this->sstate == '') {
        $this->sstate = $order->delivery[state];
      }
      $process_button_string .= tep_draw_hidden_field('sstate', $this->sstate);
    } else {
      $process_button_string .= tep_draw_hidden_field('sstate', $order->delivery[state]);
    }
    return $process_button_string;
  }

  function before_process() {
    global $_POST, $_SERVER, $order, $cart, $db, $lp_response_array, $lp_order_id, $lpOrderID;

    require(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/linkpoint_api/lphp.php');

    $order->info['cc_type'] = $_POST['cc_type'];
    $order->info['cc_owner'] = $_POST['cc_owner'];
    $order->info['cc_cvv'] = $_POST['cc_cvv'];

    $mylphp = new lphp;

    // Build Info to send to Gateway

    $myorder["host"]       = MODULE_PAYMENT_LINKPOINT_API_SERVER;
    $myorder["port"]       = "1129";
    $myorder["keyfile"]=(DIR_FS_CATALOG. DIR_WS_MODULES . 'payment/linkpoint_api/' . MODULE_PAYMENT_LINKPOINT_API_LOGIN . '.pem');
    $myorder["configfile"] = MODULE_PAYMENT_LINKPOINT_API_LOGIN;        // Store number

    $myorder["ordertype"]  = strtoupper(MODULE_PAYMENT_LINKPOINT_API_AUTHORIZATION_MODE);

    switch (MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE) {
      case "Live": $myorder["result"] = "LIVE"; break;
      case "Test": $myorder["result"] = "GOOD"; break;
      case "Decline": $myorder["result"] = "DECLINE"; break;
    }

    $myorder["transactionorigin"] = "ECI";           // For credit card retail txns, set to RETAIL, for Mail order/telephone order, set to MOTO, for e-commerce, leave out or set to ECI
    //  $myorder["oid"]               = "";  // Order ID number must be unique. If not set, gateway will assign one.
    $myorder["ponumber"]          = "1002";  // Needed for business credit cards
    $myorder["taxexempt"]         = "Y";  // Needed for business credit cards
    $myorder["terminaltype"]      = "UNSPECIFIED";    // Set terminaltype to POS for an electronic cash register or integrated POS system, STANDALONE for a point-of-sale credit card terminal, UNATTENDED for a self-service station, or UNSPECIFIED for e-commerce or other applications
    $myorder["ip"]                = $_SERVER['REMOTE_ADDR'];

    //  $myorder["subtotal"]    = $order->info['subtotal'];
    $myorder["tax"]         = '0.00'; //$order->info['tax'];
    //  $myorder["shipping"]    = $order->info['shipping_cost'];
    $grantotal = number_format($order->info['total'], 2);
    //in version 1.3 we are only going to pre-auth $1.00
    //$myorder["chargetotal"] = str_replace(",", "", $grantotal);
    $myorder["chargetotal"] = "1.00";

    // CARD INFO
    $myorder["cardnumber"]   = $_POST['cc_number'];
    $myorder["cardexpmonth"] = $_POST['cc_expires_month'];
    $myorder["cardexpyear"]  = $_POST['cc_expires_year'];
    if (empty($_POST['cc_cvv'])) {
      $myorder["cvmindicator"] = "not_provided";
    }
    else {
      $myorder["cvmindicator"] = "provided";
    }
    $myorder["cvmvalue"]  = $_POST['cc_cvv'];

    // BILLING INFO
    $myorder["userid"]   = $_POST['userid'];
    $myorder["name"]     = $this->filterLinkPoint($order->billing['firstname'] . ' ' . $order->billing['lastname']);
    $myorder["company"]  = $this->filterLinkPoint($order->billing['company']);
    $myorder["address1"] = $this->filterLinkPoint($order->billing['street_address']);
    $myorder["address2"] = $this->filterLinkPoint($order->billing['suburb']);
    $myorder["city"]     = $this->filterLinkPoint($order->billing['city']);
    $myorder["state"]    = $this->filterLinkPoint($_POST['bstate']);
    $myorder["country"]  = $this->filterLinkPoint($order->billing['country']['iso_code_2']);
    $myorder["phone"]    = $this->filterLinkPoint($order->customer['telephone']);
    //  $myorder["email"]    = $order->customer['email_address'];  //Prevents email address from being sent to linkpoint because they will use it to send an automated receipt to the customer that is uncessary based on the osCommerce system
    $myorder["addrnum"]  = $this->filterLinkPoint($order->billing['street_address']);   // Required for AVS. If not provided, transactions will downgrade.
    $myorder["zip"]      = $this->filterLinkPoint($order->billing['postcode']);  // Required for AVS. If not provided, transactions will downgrade.

    // SHIPPING INFO
    $myorder["sname"]     = $this->filterLinkPoint($order->delivery['firstname'] . ' ' . $order->delivery['lastname']);
    $myorder["saddress1"] = $this->filterLinkPoint($order->delivery['street_address']);
    $myorder["saddress2"] = $this->filterLinkPoint($order->delivery['suburb']);
    $myorder["scity"]     = $this->filterLinkPoint($order->delivery['city']);
    $myorder["sstate"]    = $this->filterLinkPoint($_POST['sstate']);
    $myorder["szip"]      = $this->filterLinkPoint($order->delivery['postcode']);
    $myorder["scountry"]  = $this->filterLinkPoint($order->delivery['country']['iso_code_2']);

    // description needs to be limited to 100 chars
    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
      $api = htmlentities($this->filterLinkPoint($order->products[$i]['name']), ENT_QUOTES, 'UTF-8');
      if (strlen($api) > '100') {
        $descrip = substr($api, 0, 100);
      } else {
        $descrip = $api;
      }
      $iprice = number_format($order->products[$i]['price'], 2);
      $items = array (
          'id'      => $order->products[$i]['id'],
          'description'   => $descrip,
          'quantity'    => $order->products[$i]['qty'],
          'price'   => str_replace(",", "", $iprice) 
      );
      $myorder["items"][$i] = $items;
    }

    // MISC
    //  $myorder["comments"] = "Repeat customer. Ship immediately.";
    $myorder["debugging"] = strtolower(MODULE_PAYMENT_LINKPOINT_API_DEBUG);  // for development only - not intended for production use

    //BACKUP TRANSACTION  BEGIN PREAUTH CODE!
    $realorder=$myorder;
    //added in 1.3 set the real order charge total to the full amount
    $myorder["ordertype"]  = "PREAUTH"; //make sure this is a preauth

    //BEGIN MAIL OUTBOUND DATA v1.3
    $debugoutputorder=$myorder;
    unset($debugoutputorder["cardnumber"]);
    unset($debugoutputorder["cvmvalue"]);
    unset($debugoutputorder["cardexpmonth"]);
    unset($debugoutputorder["cardexpyear"]);
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG OUTBOUND PREAUTH ".date('r'), print_r($debugoutputorder,true));
    //END MAIL OUTBOUND DATA v1.3


    // Send PREAUTH transaction.
    $result = $mylphp->curl_process($myorder);  // use curl methods
    //restore the grand total

    $lpOrderID="Auth: ".$result["r_ordernum"].", AVS: ".$result["r_avs"];

    //mail inbound data v1.3
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG INBOUND PREAUTH ".date('r'), print_r($result,true));

    //perform verification work
    if($result["r_avs"][1]=="N" || $result["r_avs"][3]=="N" || $result["r_avs"][3]=="S" || $result["r_approved"] != "APPROVED") {
      $myerrdisplay='';
      if($result["r_approved"] != "APPROVED") {
        $newerr=split(":",$result["r_error"]);

        //Check if their was a 4th colon delimited section present.
        if(isset($newerr[3])){
          //Make sure it has at least 4 characters
          if(strlen($newerr[3])>3){
            //what happened w/ Address
            if($newerr[3][0]=="N"){
              $myerrdisplay.='Address did not match. ';
            }elseif($newerr[3][0]=="Y"){
              $myerrdisplay.='Address Verified. ';
            }else{
              $myerrdisplay.='Address OK. ';
            }

            //what happened w/ Zip
            if($newerr[3][1]=="N"){
              $myerrdisplay.='Zip did not match. ';
            } elseif($newerr[3][1]=="Y"){
              $myerrdisplay.='Zip Verified. ';
            } else {
              $myerrdisplay.='Zip OK. ';
            }

            //what happened w/ CVV
            //1.3 - Added Test for r_avs=S to Change CVV verification to reject no CVV as well as incorrect CVV.  Module would previously accept good or no CVV and reject bad CVV.
            if($newerr[3][3]=="N"){
              $myerrdisplay.='CVV or Expiration did not match. ';
            }elseif($newerr[3][3]=="S"){
              $myerrdisplay.='CVV Not Provided. ';
            }elseif($newerr[3][3]=="Y"){
              $myerrdisplay.='CVV and Expiration Verified. ';
            }else{
              $myerrdisplay.='CVV and Expiration OK. ';
            }
          }
        }

        //what happened w/ Approval
        if(strstr($result['r_error'], 'R:Referral')){
          $myerrdisplay.='Card not approved, please contact your bank for detailed information or use another card.  This transaction has issued a referral code. ';
        } elseif(strstr($result['r_error'], 'Duplicate transaction')){
          $myerrdisplay.='Duplicate Transaction, please wait 1 minute and try again. ';
        } else {
          $myerrdisplay.='Card not approved, please contact your bank for detailed information or use another card. ';
        }
      }else{
        //what happened w/ Address
        if($result["r_avs"][0]=="N"){
          $myerrdisplay.='Address did not match. ';
        }elseif($result["r_avs"][0]=="Y"){
          $myerrdisplay.='Address Verified. ';
        }else{
          $myerrdisplay.='Address OK. ';
        }

        //what happened w/ Zip
        if($result["r_avs"][1]=="N"){
          $myerrdisplay.='Zip did not match. ';
        } elseif($result["r_avs"][1]=="Y") {
          $myerrdisplay.='Zip Verified. ';
        } else {
          $myerrdisplay.='Zip OK. ';
        }

        //what happened w/ CVV
        //1.3 - Added Test for r_avs=S to Change CVV verification to reject no CVV as well as incorrect CVV.  Module would previously accept good or no CVV and reject bad CVV.
        if($result["r_avs"][3]=="N") {
          $myerrdisplay.='CVV or Expiration did not match. ';
        } elseif($result["r_avs"][3]=="S") {
          $myerrdisplay.='CVV Not Provided. ';
        } elseif($result["r_avs"][3]=="Y") {
          $myerrdisplay.='CVV and Expiration Verified. ';
        } else {
          $myerrdisplay.='CVV and Expiration OK. ';
        }

        $myerrdisplay.='Card approved. ';
      }

      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=PREAUTHORIZATION FAILED - ' . urlencode($myerrdisplay. ' Please correct the listed problems and try again or contact us by phone to process this order.'), 'SSL', true, false));
    }


    //CHANGE FOR 1.3
    //build the real order
    $realorder["chargetotal"] = str_replace(",", "", $grantotal);
    $realorder["ordertype"] = "SALE";

    //BEGIN MAIL OUTBOUND DATA v1.3
    $debugoutputorder=$realorder;
    unset($debugoutputorder["cardnumber"]);
    unset($debugoutputorder["cvmvalue"]);
    unset($debugoutputorder["cardexpmonth"]);
    unset($debugoutputorder["cardexpyear"]);
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG OUTBOUND SALE ".date('r'), print_r($debugoutputorder,true));
    //END MAIL OUTBOUND DATA v1.3


    // Send the SALE transaction.
    $result = $mylphp->curl_process($realorder);  // use curl methods

    $lpOrderID.=", Sale: ".$result["r_ordernum"];

    //mail inbound data v1.3
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG INBOUND SALE ".date('r'), print_r($result,true));

    // - SGS-000001: D:Declined:P:
    //- SGS-005005: Duplicate transaction.
    //  Begin Transaction Status does not = APPROVED

    if ($myorder['debugging'] == 'true') {
      exit;
    }

    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'D:Declined')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_DECLINED_MESSAGE), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'R:Referral')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_DECLINED_MESSAGE), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'Duplicate transaction')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_DUPLICATE_MESSAGE), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'SGS')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode($result["r_error"]), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" ) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_ERROR_MESSAGE), 'SSL', true, false));
    }
    //  End Transaction Status does not = APPROVED
  }

  function after_process() {
    return false;
  }

  function get_error() {
    global $_GET;
    $error = array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_ERROR,
      'error' => stripslashes(urldecode($_GET['error'])));
    return $error;
  }

  function check() {
    if (!isset($this->_check)) {
      $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_LINKPOINT_API_STATUS'");
      $this->_check = tep_db_num_rows($check_query);
    }
    return $this->_check;
  }

  function install() {
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Linkpoint API module', 'MODULE_PAYMENT_LINKPOINT_API_STATUS', 'True', 'Do you want to accept Linkpoint payments?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Store Number', 'MODULE_PAYMENT_LINKPOINT_API_LOGIN', '000001', 'The 6 or 7 digit store number for LinkPoint. For Yourpay accounts you must enter your 10 digit store number.', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('LinkPoint Transaction Mode', 'MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE', 'Live', '<strong>Live:</strong> Use for live transactions<br /><strong>Test:</strong> Use for test transactions', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Authorization Type', 'MODULE_PAYMENT_LINKPOINT_API_AUTHORIZATION_MODE', 'Preauth', 'Preauth will reserve the funds on the credit card. Sale will immediately charge the card.', '6', '0', 'tep_cfg_select_option(array(\'Preauth\', \'Sale\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('LinkPoint server', 'MODULE_PAYMENT_LINKPOINT_API_SERVER', 'secure.linkpt.net', 'LinkPoint secure server', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Debugging', 'MODULE_PAYMENT_LINKPOINT_API_DEBUG', 'False', 'Only use for troubleshooting errors.', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_LINKPOINT_API_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_LINKPOINT_API_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
  }

  function remove() {
    tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }

  function keys() {
    return array( 'MODULE_PAYMENT_LINKPOINT_API_STATUS', 'MODULE_PAYMENT_LINKPOINT_API_LOGIN', 'MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE', 'MODULE_PAYMENT_LINKPOINT_API_AUTHORIZATION_MODE', 'MODULE_PAYMENT_LINKPOINT_API_SERVER', 'MODULE_PAYMENT_LINKPOINT_API_DEBUG', 'MODULE_PAYMENT_LINKPOINT_API_SORT_ORDER', 'MODULE_PAYMENT_LINKPOINT_API_ZONE', 'MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID');
  }

  function _state_list() {
    $list = array('ALABAMA' => 'AL',
        'ALASKA' => 'AK' ,
        'ARIZONA' => 'AZ' ,
        'ARKANSAS' => 'AR' ,
        'CALIFORNIA' => 'CA' ,
        'COLORADO' => 'CO' ,
        'CONNECTICUT' => 'CT' ,
        'DELAWARE' => 'DE' ,
        'DISTRICT OF COLUMBIA' => 'DC' ,
        'FLORIDA' => 'FL' ,
        'GEORGIA' => 'GA' ,
        'HAWAII' => 'HI' ,
        'IDAHO' => 'ID' ,
        'ILLINOIS' => 'IL' ,
        'INDIANA' => 'IN' ,
        'IOWA' => 'IA' ,
        'KANSAS' => 'KS' ,
        'KENTUCKY' => 'KY' ,
        'LOUISIANA' => 'LA' ,
        'MAINE' => 'ME' ,
        'MARYLAND' => 'MD' ,
        'MASSACHUSETTS' => 'MA' ,
        'MICHIGAN' => 'MI' ,
        'MINNESOTA' => 'MN' ,
        'MISSISSIPPI' => 'MS' ,
        'MISSOURI' => 'MO' ,
        'MONTANA' => 'MT' ,
        'NEBRASKA' => 'NE' ,
        'NEVADA' => 'NV' ,
        'NEW HAMPSHIRE' => 'NH' ,
        'NEW JERSEY' => 'NJ' ,
        'NEW MEXICO' => 'NM' ,
        'NEW YORK' => 'NY' ,
        'NORTH CAROLINA' => 'NC' ,
        'NORTH DAKOTA' => 'ND' ,
        'OHIO' => 'OH' ,
        'OKLAHOMA' => 'OK' ,
        'OREGON' => 'OR' ,
        'PENNSYLVANIA' => 'PA' ,
        'RHODE ISLAND' => 'RI' ,
        'SOUTH CAROLINA' => 'SC' ,
        'SOUTH DAKOTA' => 'SD' ,
        'TENNESSEE' => 'TN' ,
        'TEXAS' => 'TX' ,
        'UTAH' => 'UT' ,
        'VERMONT' => 'VT' ,
        'VIRGINIA' => 'VA' ,
        'WASHINGTON' => 'WA' ,
        'WEST VIRGINIA' => 'WV' ,
        'WISCONSIN' => 'WI' ,
        'WEST VIRGINIA' => 'WV' ,
        'WYOMING' => 'WY');
    return $list;
  }
}
?>



===================================================



File Name : lphp.php

code follows :
=====================================================
class lphp
{
	var $debugging;

	###########################################
	#
	#	F U N C T I O N    p r o c e s s ( ) 
	#
	#	process a hash table or XML string 
	#	using LIBLPHP.SO and LIBLPSSL.SO
	#
	###########################################

	function process($data)
	{
		$using_xml = 0;
		$webspace = 1;

		if (isset($data["webspace"]))
		{
			if ($data["webspace"] == "false") // if explicitly set to false, don't use html output
				$webspace = 0;
		}

		if ( isset($data["debugging"]) || isset($data["debug"]) )
		{
			if ($data["debugging"] == "true" || $data["debug"] == "true"  )
			{
				$this->debugging = 1;
				
				# print out incoming hash
				if ($webspace)	// use html-friendly output
				{
					echo "at process, incoming data: <br>";
				
					while (list($key, $value) = each($data))
						 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n";
				}
				else      // don't use html output
				{
					echo "at process, incoming data: \n";
					
					while (list($key, $value) = each($data))
						echo "$key = $value\n"; 
				}

				reset($data); 
			}
		}

		if (isset($data["xml"])) // if XML string is passed in, we'll use it
		{
			$using_xml = 1;
			$xml = $data["xml"];
		}
		else
		{
			//  otherwise convert incoming hash to XML string
			$xml = $this->buildXML($data);
		}

		// then set up transaction variables
		$key	= $data["keyfile"];
		$host	= $data["host"];
		$port	= $data[port];


		# FOR PERFORMANCE, Use the 'extensions' statement in your php.ini to load
		# this library at PHP startup, then comment out the next seven lines 

		// load library
		if (!extension_loaded('liblphp'))
		{
			if (!dl('liblphp.so'))
			{
				exit("cannot load liblphp.so, bye\n");
			}
		}

		if ($this->debugging)
		{
			if ($webspace)
				echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>";    
			else
				echo "\nsending xml string:\n$xml\n\n";
		}

		// send transaction to LSGS
		$retstg = send_stg($xml, $key, $host, $port);


		if (strlen($retstg) < 4)
			exit ("cannot connect to lsgs, exiting");
		
		if ($this->debugging)
		{	
			if ($this->webspace)	// we're web space
				echo "<br>server responds:<br>" . htmlspecialchars($retstg) . "<br><br>";
			else						// not html output
				echo "\nserver responds:\n $retstg\n\n";
		}
	
		if ($using_xml != 1)
		{
			// convert xml response back to hash
			$retarr = $this->decodeXML($retstg);
			
			// and send it back to caller
			return ($retarr);
		}
		else
		{
			// send server response back
			return $retstg;
		}
	}


	#####################################################
	#
	#	F U N C T I O N    c u r l _ p r o c e s s ( ) 
	#
	#	process hash table or xml string table using 
	#	curl, either with PHP built-in curl methods 
	#	or binary executable curl
	#
	#####################################################
	
	function curl_process($data)
	{
		$using_xml = 0;
		$webspace = 1;

		if (isset($data["webspace"]))
		{
			if ($data["webspace"] == "false") // if explicitly set to false, don't use html output
				$webspace = 0;
		}

		if (isset($data["debugging"]) || isset($data["debug"]) )
		{
			if ($data["debugging"] == "true" || $data["debug"] == "true" )
			{
				$this->debugging = 1;

				# print out incoming hash
				if ($webspace)	// use html-friendly output
				{
					echo "at curl_process, incoming data: <br>";

					while (list($key, $value) = each($data))
						 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n";
				}
				else      // don't use html output
				{
					echo "at curl_process, incoming data: \n";
					
					while (list($key, $value) = each($data))
						echo "$key = $value\n";
				}

				reset($data); 
			}
		}

		if (isset($data["xml"])) // if XML string is passed in, we'll use it
		{
			$using_xml = 1;
			$xml = $data["xml"];
		}
		else
		{
			// otherwise convert incoming hash to XML string
			$xml = $this->buildXML($data);
		}

		if ($this->debugging)
		{
			if ($webspace)
				echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>";    
			else
				echo "\nsending xml string:\n$xml\n\n";
		}

		// set up transaction variables
		$key = $data["keyfile"];
		$port = $data["port"];
		$host = "https://".$data["host"].":".$port."/LSGSXML";


		if (isset($data["cbin"])) //using BINARY curl methods
		{
			if ($data["cbin"] == "true")
			{
				if (isset($data["cpath"]))
					$cpath = $data["cpath"];
						
				else // curl path has not been set, try to find curl binary
				{
					if (getenv("OS") == "Windows_NT")
						$cpath = "c:\\curl\\curl.exe";
					else
						$cpath = "/usr/bin/curl";
				}

				// look for $cargs variable, otherwise use default curl arguments
				if (isset($data["cargs"]))
					$args = $data["cargs"];
				else
					$args = "-m 300 -s -S";		// default curl args; 5 min. timeout


				# TRANSACT #

				if (getenv("OS") == "Windows_NT")
				{
					if ($this->debugging)
						$result = exec ("$cpath -v -d \"$xml\" -E $key  -k $host", $retarr, $retnum);
					else
						$result = exec ("$cpath -d \"$xml\" -E $key  -k $host", $retarr, $retnum);
				}
				
				else	//*nix string
				{
					if ($this->debugging)
						$result = exec ("'$cpath' $args -v -E '$key' -d '$xml' '$host'", $retarr, $retnum);
					else
						$result = exec ("'$cpath' $args -E '$key' -d '$xml' '$host'", $retarr, $retnum);
				}

				# EVALUATE RESPONSE #

				if (strlen($result) < 2)    // no response
				{
					$result = "<r_approved>FAILURE</r_approved><r_error>Could not connect.</r_error>"; 
					return $result;
				}

				if ($this->debugging)
				{
					if ($this->webspace)
						echo "<br>server responds:<br>" . htmlspecialchars($result) . "<br><br>";
					else						// non html output
						echo "\nserver responds:\n $result\n\n";
				}

				if ($using_xml == 1)
				{ 
					// return xml string straight from server
					return ($result);
				}
				else
				{
					// convert xml response back to hash
					$retarr = $this->decodeXML($result);
					
					// and send it back to caller. Done.
					return ($retarr);
				}
			}
		}

		else	// using BUILT-IN PHP curl methods
		{
			$ch = curl_init ();
			curl_setopt ($ch, CURLOPT_URL,$host);
			curl_setopt ($ch, CURLOPT_POST, 1); 
			curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml);
			curl_setopt ($ch, CURLOPT_SSLCERT, $key);
			curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
			curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
#			curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
#			curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

			if ($this->debugging)
				curl_setopt ($ch, CURLOPT_VERBOSE, 1);

			#  use curl to send the xml SSL string
			$result = curl_exec ($ch);

			curl_close($ch);

			if (strlen($result) < 2)    # no response
			{
				$result = "<r_approved>FAILURE</r_approved><r_error>Could not connect.</r_error>"; 
				return $result;
			}

			if ($this->debugging)
			{	
				if ($webspace)	// html-friendly output
					echo "<br>server responds:<br>" . htmlspecialchars($result) . "<br><br>";
				else
					echo "\nserver responds:\n $result\n\n";
			}

			if ($using_xml)
			{
				# send xml response back
				return $result;
			}
			else
			{
				#convert xml response to hash
				$retarr = $this->decodeXML($result);
				
				# and send it back
				return ($retarr);
			}
		}
	}


	#############################################	
	#
	#	F U N C T I O N   d e c o d e X M L ( ) 
	#
	#	converts the LSGS response xml string	
	#	to a hash of name-value pairs
	#
	#############################################

	function decodeXML($xmlstg)
	{
		preg_match_all ("/<(.*?)>(.*?)\</", $xmlstg, $out, PREG_SET_ORDER);
		
		$n = 0;
		while (isset($out[$n]))
		{
			$retarr[$out[$n][1]] = strip_tags($out[$n][0]);
			$n++; 
		}

		return $retarr;
	}


	############################################
	#
	#	F U N C T I O N    b u i l d X M L ( ) 
	#
	#	converts a hash of name-value pairs
	#	to the correct XML format for LSGS
	#
	############################################

	function buildXML($pdata)
	{

//		while (list($key, $value) = each($pdata))
//			 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<br>\n";


		### ORDEROPTIONS NODE ###
		$xml = "<order><orderoptions>";

		if (isset($pdata["ordertype"]))
			$xml .= "<ordertype>" . $pdata["ordertype"] . "</ordertype>";

		if (isset($pdata["result"]))
			$xml .= "<result>" . $pdata["result"] . "</result>";

		$xml .= "</orderoptions>";


		### CREDITCARD NODE ###
		$xml .= "<creditcard>";

		if (isset($pdata["cardnumber"]))
			$xml .= "<cardnumber>" . $pdata["cardnumber"] . "</cardnumber>";

		if (isset($pdata["cardexpmonth"]))
			$xml .= "<cardexpmonth>" . $pdata["cardexpmonth"] . "</cardexpmonth>";

		if (isset($pdata["cardexpyear"]))
			$xml .= "<cardexpyear>" . $pdata["cardexpyear"] . "</cardexpyear>";

		if (isset($pdata["cvmvalue"]))
			$xml .= "<cvmvalue>" . $pdata["cvmvalue"] . "</cvmvalue>";

		if (isset($pdata["cvmindicator"]))
			$xml .= "<cvmindicator>" . $pdata["cvmindicator"] . "</cvmindicator>";

		if (isset($pdata["track"]))
			$xml .= "<track>" . $pdata["track"] . "</track>";

		$xml .= "</creditcard>";


		### BILLING NODE ###
		$xml .= "<billing>";

		if (isset($pdata["name"]))
			$xml .= "<name>" . $pdata["name"] . "</name>";

		if (isset($pdata["company"]))
			$xml .= "<company>" . $pdata["company"] . "</company>";

		if (isset($pdata["address1"]))
			$xml .= "<address1>" . $pdata["address1"] . "</address1>";
		elseif (isset($pdata["address"]))
			$xml .= "<address1>" . $pdata["address"] . "</address1>";

		if (isset($pdata["address2"]))
			$xml .= "<address2>" . $pdata["address2"] . "</address2>";

		if (isset($pdata["city"]))
			$xml .= "<city>" . $pdata["city"] . "</city>";
			
		if (isset($pdata["state"]))
			$xml .= "<state>" . $pdata["state"] . "</state>";
			
		if (isset($pdata["zip"]))
			$xml .= "<zip>" . $pdata["zip"] . "</zip>";

		if (isset($pdata["country"]))
			$xml .= "<country>" . $pdata["country"] . "</country>";

		if (isset($pdata["userid"]))
			$xml .= "<userid>" . $pdata["userid"] . "</userid>";

		if (isset($pdata["email"]))
			$xml .= "<email>" . $pdata["email"] . "</email>";

		if (isset($pdata["phone"]))
			$xml .= "<phone>" . $pdata["phone"] . "</phone>";

		if (isset($pdata["fax"]))
			$xml .= "<fax>" . $pdata["fax"] . "</fax>";

		if (isset($pdata["addrnum"]))
			$xml .= "<addrnum>" . $pdata["addrnum"] . "</addrnum>";

		$xml .= "</billing>";

		
		## SHIPPING NODE ##
		$xml .= "<shipping>";

		if (isset($pdata["sname"]))
			$xml .= "<name>" . $pdata["sname"] . "</name>";

		if (isset($pdata["saddress1"]))
			$xml .= "<address1>" . $pdata["saddress1"] . "</address1>";

		if (isset($pdata["saddress2"]))
			$xml .= "<address2>" . $pdata["saddress2"] . "</address2>";

		if (isset($pdata["scity"]))
			$xml .= "<city>" . $pdata["scity"] . "</city>";

		if (isset($pdata["sstate"]))
			$xml .= "<state>" . $pdata["sstate"] . "</state>";
		elseif (isset($pdata["state"]))
			$xml .= "<state>" . $pdata["sstate"] . "</state>";

		if (isset($pdata["szip"]))
			$xml .= "<zip>" . $pdata["szip"] . "</zip>";
		elseif (isset($pdata["sip"]))
			$xml .= "<zip>" . $pdata["zip"] . "</zip>";

		if (isset($pdata["scountry"]))
			$xml .= "<country>" . $pdata["scountry"] . "</country>";

		if (isset($pdata["scarrier"]))
			$xml .= "<carrier>" . $pdata["scarrier"] . "</carrier>";

		if (isset($pdata["sitems"]))
			$xml .= "<items>" . $pdata["sitems"] . "</items>";

		if (isset($pdata["sweight"]))
			$xml .= "<weight>" . $pdata["sweight"] . "</weight>";

		if (isset($pdata["stotal"]))
			$xml .= "<total>" . $pdata["stotal"] . "</total>";

		$xml .= "</shipping>";


		### TRANSACTIONDETAILS NODE ###
		$xml .= "<transactiondetails>";

		if (isset($pdata["oid"]))
			$xml .= "<oid>" . $pdata["oid"] . "</oid>";

		if (isset($pdata["ponumber"]))
			$xml .= "<ponumber>" . $pdata["ponumber"] . "</ponumber>";

		if (isset($pdata["recurring"]))
			$xml .= "<recurring>" . $pdata["recurring"] . "</recurring>";

		if (isset($pdata["taxexempt"]))
			$xml .= "<taxexempt>" . $pdata["taxexempt"] . "</taxexempt>";

		if (isset($pdata["terminaltype"]))
			$xml .= "<terminaltype>" . $pdata["terminaltype"] . "</terminaltype>";

		if (isset($pdata["ip"]))
			$xml .= "<ip>" . $pdata["ip"] . "</ip>";

		if (isset($pdata["reference_number"]))
			$xml .= "<reference_number>" . $pdata["reference_number"] . "</reference_number>";

		if (isset($pdata["transactionorigin"]))
			$xml .= "<transactionorigin>" . $pdata["transactionorigin"] . "</transactionorigin>";

		if (isset($pdata["tdate"]))
			$xml .= "<tdate>" . $pdata["tdate"] . "</tdate>";

		$xml .= "</transactiondetails>";


		### MERCHANTINFO NODE ###
		$xml .= "<merchantinfo>";

		if (isset($pdata["configfile"]))
			$xml .= "<configfile>" . $pdata["configfile"] . "</configfile>";

		if (isset($pdata["keyfile"]))
			$xml .= "<keyfile>" . $pdata["keyfile"] . "</keyfile>";

		if (isset($pdata["host"]))
			$xml .= "<host>" . $pdata["host"] . "</host>";

		if (isset($pdata["port"]))
			$xml .= "<port>" . $pdata["port"] . "</port>";

		if (isset($pdata["appname"]))
			$xml .= "<appname>" . $pdata["appname"] . "</appname>";

		$xml .= "</merchantinfo>";



		### PAYMENT NODE ###
		$xml .= "<payment>";

		if (isset($pdata["chargetotal"]))
			$xml .= "<chargetotal>" . $pdata["chargetotal"] . "</chargetotal>";

		if (isset($pdata["tax"]))
			$xml .= "<tax>" . $pdata["tax"] . "</tax>";

		if (isset($pdata["vattax"]))
			$xml .= "<vattax>" . $pdata["vattax"] . "</vattax>";

		if (isset($pdata["shipping"]))
			$xml .= "<shipping>" . $pdata["shipping"] . "</shipping>";

		if (isset($pdata["subtotal"]))
			$xml .= "<subtotal>" . $pdata["subtotal"] . "</subtotal>";

		$xml .= "</payment>";


		### CHECK NODE ### 


		if (isset($pdata["voidcheck"]))
		{
			$xml .= "<telecheck><void>1</void></telecheck>";
		}
		elseif (isset($pdata["routing"]))
		{
			$xml .= "<telecheck>";
			$xml .= "<routing>" . $pdata["routing"] . "</routing>";

			if (isset($pdata["account"]))
				$xml .= "<account>" . $pdata["account"] . "</account>";

			if (isset($pdata["bankname"]))
				$xml .= "<bankname>" . $pdata["bankname"] . "</bankname>";
	
			if (isset($pdata["bankstate"]))
				$xml .= "<bankstate>" . $pdata["bankstate"] . "</bankstate>";

			if (isset($pdata["ssn"]))
				$xml .= "<ssn>" . $pdata["ssn"] . "</ssn>";

			if (isset($pdata["dl"]))
				$xml .= "<dl>" . $pdata["dl"] . "</dl>";

			if (isset($pdata["dlstate"]))
				$xml .= "<dlstate>" . $pdata["dlstate"] . "</dlstate>";

			if (isset($pdata["checknumber"]))
				$xml .= "<checknumber>" . $pdata["checknumber"] . "</checknumber>";
				
			if (isset($pdata["accounttype"]))
				$xml .= "<accounttype>" . $pdata["accounttype"] . "</accounttype>";

			$xml .= "</telecheck>";
		}


		### PERIODIC NODE ###

		if (isset($pdata["startdate"]))
		{
			$xml .= "<periodic>";

			$xml .= "<startdate>" . $pdata["startdate"] . "</startdate>";

			if (isset($pdata["installments"]))
				$xml .= "<installments>" . $pdata["installments"] . "</installments>";

			if (isset($pdata["threshold"]))
						$xml .= "<threshold>" . $pdata["threshold"] . "</threshold>";

			if (isset($pdata["periodicity"]))
						$xml .= "<periodicity>" . $pdata["periodicity"] . "</periodicity>";

			if (isset($pdata["pbcomments"]))
						$xml .= "<comments>" . $pdata["pbcomments"] . "</comments>";

			if (isset($pdata["action"]))
				$xml .= "<action>" . $pdata["action"] . "</action>";

			$xml .= "</periodic>";
		}


		### NOTES NODE ###

		if (isset($pdata["comments"]) || isset($pdata["referred"]))
		{
			$xml .= "<notes>";

			if (isset($pdata["comments"]))
				$xml .= "<comments>" . $pdata["comments"] . "</comments>";

			if (isset($pdata["referred"]))
				$xml .= "<referred>" . $pdata["referred"] . "</referred>";

			$xml .= "</notes>";
		}

		### ITEMS AND OPTIONS NODES ###
	
		if ($this->debugging)	// make it easy to see
		{						// LSGS doesn't mind whitespace
			reset($pdata);

			while (list ($key, $val) = each ($pdata))
			{
				if (is_array($val))
				{
					$otag = 0;
					$ostag = 0;
					$items_array = $val;
					$xml .= "\n<items>\n";

					while(list($key1, $val1) = each ($items_array))
					{
						$xml .= "\t<item>\n";

						while (list($key2, $val2) = each ($val1))
						{
							if (!is_array($val2))
								$xml .= "\t\t<$key2>$val2</$key2>\n";

							else
							{
								if (!$ostag)
								{
									$xml .= "\t\t<options>\n";
									$ostag = 1;
								}

								$xml .= "\t\t\t<option>\n";
								$otag = 1;
								
								while (list($key3, $val3) = each ($val2))
									$xml .= "\t\t\t\t<$key3>$val3</$key3>\n";
							}

							if ($otag)
							{
								$xml .= "\t\t\t</option>\n";
								$otag = 0;
							}
						}

						if ($ostag)
						{
							$xml .= "\t\t</options>\n";
							$ostag = 0;
						}
					$xml .= "\t</item>\n";
					}
				$xml .= "</items>\n";
				}
			}
		}

		else // !debugging
		{
			while (list ($key, $val) = each ($pdata))
			{
				if (is_array($val))
				{
					$otag = 0;
					$ostag = 0;
					$items_array = $val;
					$xml .= "<items>";

					while(list($key1, $val1) = each ($items_array))
					{
						$xml .= "<item>";

						while (list($key2, $val2) = each ($val1))
						{
							if (!is_array($val2))
								$xml .= "<$key2>$val2</$key2>";

							else
							{
								if (!$ostag)
								{
									$xml .= "<options>";
									$ostag = 1;
								}

								$xml .= "<option>";
								$otag = 1;
								
								while (list($key3, $val3) = each ($val2))
									$xml .= "<$key3>$val3</$key3>";
							}

							if ($otag)
							{
								$xml .= "</option>";
								$otag = 0;
							}
						}

						if ($ostag)
						{
							$xml .= "</options>";
							$ostag = 0;
						}
					$xml .= "</item>";
					}
				$xml .= "</items>";
				}
			}
		}

		$xml .= "</order>";

		return $xml;
	}
}
?>
=====================================================

Open in new window

0
 
Ray PaseurCommented:
This cannot be correct - line 172 was identified in the error message above, but it has no function call in the code snippet.
0
 
sdugarAuthor Commented:
Code Below for file : lphp.php
<?php


		/* lphp.php  LINKPOINT PHP MODULE */
	
		/* A php interlocutor CLASS for
		LinkPoint: LINKPOINT LSGS API using
		libcurl, liblphp.so and liblpssl.so
		v3.0.005  20 Aug. 2003  smoffet */
		
		
# Copyright 2003 LinkPoint International, Inc. All Rights Reserved.
# 
# This software is the proprietary information of LinkPoint International, Inc.
# Use is subject to license terms.


	### YOU REALLY DO NOT NEED TO EDIT THIS FILE! ###


class lphp
{
	var $debugging;

	###########################################
	#
	#	F U N C T I O N    p r o c e s s ( ) 
	#
	#	process a hash table or XML string 
	#	using LIBLPHP.SO and LIBLPSSL.SO
	#
	###########################################

	function process($data)
	{
		$using_xml = 0;
		$webspace = 1;

		if (isset($data["webspace"]))
		{
			if ($data["webspace"] == "false") // if explicitly set to false, don't use html output
				$webspace = 0;
		}

		if ( isset($data["debugging"]) || isset($data["debug"]) )
		{
			if ($data["debugging"] == "true" || $data["debug"] == "true"  )
			{
				$this->debugging = 1;
				
				# print out incoming hash
				if ($webspace)	// use html-friendly output
				{
					echo "at process, incoming data: <br>";
				
					while (list($key, $value) = each($data))
						 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n";
				}
				else      // don't use html output
				{
					echo "at process, incoming data: \n";
					
					while (list($key, $value) = each($data))
						echo "$key = $value\n"; 
				}

				reset($data); 
			}
		}

		if (isset($data["xml"])) // if XML string is passed in, we'll use it
		{
			$using_xml = 1;
			$xml = $data["xml"];
		}
		else
		{
			//  otherwise convert incoming hash to XML string
			$xml = $this->buildXML($data);
		}

		// then set up transaction variables
		$key	= $data["keyfile"];
		$host	= $data["host"];
		$port	= $data[port];


		# FOR PERFORMANCE, Use the 'extensions' statement in your php.ini to load
		# this library at PHP startup, then comment out the next seven lines 

		// load library
		if (!extension_loaded('liblphp'))
		{
			if (!dl('liblphp.so'))
			{
				exit("cannot load liblphp.so, bye\n");
			}
		}

		if ($this->debugging)
		{
			if ($webspace)
				echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>";    
			else
				echo "\nsending xml string:\n$xml\n\n";
		}

		// send transaction to LSGS
		$retstg = send_stg($xml, $key, $host, $port);


		if (strlen($retstg) < 4)
			exit ("cannot connect to lsgs, exiting");
		
		if ($this->debugging)
		{	
			if ($this->webspace)	// we're web space
				echo "<br>server responds:<br>" . htmlspecialchars($retstg) . "<br><br>";
			else						// not html output
				echo "\nserver responds:\n $retstg\n\n";
		}
	
		if ($using_xml != 1)
		{
			// convert xml response back to hash
			$retarr = $this->decodeXML($retstg);
			
			// and send it back to caller
			return ($retarr);
		}
		else
		{
			// send server response back
			return $retstg;
		}
	}


	#####################################################
	#
	#	F U N C T I O N    c u r l _ p r o c e s s ( ) 
	#
	#	process hash table or xml string table using 
	#	curl, either with PHP built-in curl methods 
	#	or binary executable curl
	#
	#####################################################
	
	function curl_process($data)
	{
		$using_xml = 0;
		$webspace = 1;

		if (isset($data["webspace"]))
		{
			if ($data["webspace"] == "false") // if explicitly set to false, don't use html output
				$webspace = 0;
		}

		if (isset($data["debugging"]) || isset($data["debug"]) )
		{
			if ($data["debugging"] == "true" || $data["debug"] == "true" )
			{
				$this->debugging = 1;

				# print out incoming hash
				if ($webspace)	// use html-friendly output
				{
					echo "at curl_process, incoming data: <br>";

					while (list($key, $value) = each($data))
						 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n";
				}
				else      // don't use html output
				{
					echo "at curl_process, incoming data: \n";
					
					while (list($key, $value) = each($data))
						echo "$key = $value\n";
				}

				reset($data); 
			}
		}

		if (isset($data["xml"])) // if XML string is passed in, we'll use it
		{
			$using_xml = 1;
			$xml = $data["xml"];
		}
		else
		{
			// otherwise convert incoming hash to XML string
			$xml = $this->buildXML($data);
		}

		if ($this->debugging)
		{
			if ($webspace)
				echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>";    
			else
				echo "\nsending xml string:\n$xml\n\n";
		}

		// set up transaction variables
		$key = $data["keyfile"];
		$port = $data["port"];
		$host = "https://".$data["host"].":".$port."/LSGSXML";


		if (isset($data["cbin"])) //using BINARY curl methods
		{
			if ($data["cbin"] == "true")
			{
				if (isset($data["cpath"]))
					$cpath = $data["cpath"];
						
				else // curl path has not been set, try to find curl binary
				{
					if (getenv("OS") == "Windows_NT")
						$cpath = "c:\\curl\\curl.exe";
					else
						$cpath = "/usr/bin/curl";
				}

				// look for $cargs variable, otherwise use default curl arguments
				if (isset($data["cargs"]))
					$args = $data["cargs"];
				else
					$args = "-m 300 -s -S";		// default curl args; 5 min. timeout


				# TRANSACT #

				if (getenv("OS") == "Windows_NT")
				{
					if ($this->debugging)
						$result = exec ("$cpath -v -d \"$xml\" -E $key  -k $host", $retarr, $retnum);
					else
						$result = exec ("$cpath -d \"$xml\" -E $key  -k $host", $retarr, $retnum);
				}
				
				else	//*nix string
				{
					if ($this->debugging)
						$result = exec ("'$cpath' $args -v -E '$key' -d '$xml' '$host'", $retarr, $retnum);
					else
						$result = exec ("'$cpath' $args -E '$key' -d '$xml' '$host'", $retarr, $retnum);
				}

				# EVALUATE RESPONSE #

				if (strlen($result) < 2)    // no response
				{
					$result = "<r_approved>FAILURE</r_approved><r_error>Could not connect.</r_error>"; 
					return $result;
				}

				if ($this->debugging)
				{
					if ($this->webspace)
						echo "<br>server responds:<br>" . htmlspecialchars($result) . "<br><br>";
					else						// non html output
						echo "\nserver responds:\n $result\n\n";
				}

				if ($using_xml == 1)
				{ 
					// return xml string straight from server
					return ($result);
				}
				else
				{
					// convert xml response back to hash
					$retarr = $this->decodeXML($result);
					
					// and send it back to caller. Done.
					return ($retarr);
				}
			}
		}

		else	// using BUILT-IN PHP curl methods
		{
			$ch = curl_init ();
			curl_setopt ($ch, CURLOPT_URL,$host);
			curl_setopt ($ch, CURLOPT_POST, 1); 
			curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml);
			curl_setopt ($ch, CURLOPT_SSLCERT, $key);
			curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
			curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
#			curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
#			curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

			if ($this->debugging)
				curl_setopt ($ch, CURLOPT_VERBOSE, 1);

			#  use curl to send the xml SSL string
			$result = curl_exec ($ch);

			curl_close($ch);

			if (strlen($result) < 2)    # no response
			{
				$result = "<r_approved>FAILURE</r_approved><r_error>Could not connect.</r_error>"; 
				return $result;
			}

			if ($this->debugging)
			{	
				if ($webspace)	// html-friendly output
					echo "<br>server responds:<br>" . htmlspecialchars($result) . "<br><br>";
				else
					echo "\nserver responds:\n $result\n\n";
			}

			if ($using_xml)
			{
				# send xml response back
				return $result;
			}
			else
			{
				#convert xml response to hash
				$retarr = $this->decodeXML($result);
				
				# and send it back
				return ($retarr);
			}
		}
	}


	#############################################	
	#
	#	F U N C T I O N   d e c o d e X M L ( ) 
	#
	#	converts the LSGS response xml string	
	#	to a hash of name-value pairs
	#
	#############################################

	function decodeXML($xmlstg)
	{
		preg_match_all ("/<(.*?)>(.*?)\</", $xmlstg, $out, PREG_SET_ORDER);
		
		$n = 0;
		while (isset($out[$n]))
		{
			$retarr[$out[$n][1]] = strip_tags($out[$n][0]);
			$n++; 
		}

		return $retarr;
	}


	############################################
	#
	#	F U N C T I O N    b u i l d X M L ( ) 
	#
	#	converts a hash of name-value pairs
	#	to the correct XML format for LSGS
	#
	############################################

	function buildXML($pdata)
	{

//		while (list($key, $value) = each($pdata))
//			 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<br>\n";


		### ORDEROPTIONS NODE ###
		$xml = "<order><orderoptions>";

		if (isset($pdata["ordertype"]))
			$xml .= "<ordertype>" . $pdata["ordertype"] . "</ordertype>";

		if (isset($pdata["result"]))
			$xml .= "<result>" . $pdata["result"] . "</result>";

		$xml .= "</orderoptions>";


		### CREDITCARD NODE ###
		$xml .= "<creditcard>";

		if (isset($pdata["cardnumber"]))
			$xml .= "<cardnumber>" . $pdata["cardnumber"] . "</cardnumber>";

		if (isset($pdata["cardexpmonth"]))
			$xml .= "<cardexpmonth>" . $pdata["cardexpmonth"] . "</cardexpmonth>";

		if (isset($pdata["cardexpyear"]))
			$xml .= "<cardexpyear>" . $pdata["cardexpyear"] . "</cardexpyear>";

		if (isset($pdata["cvmvalue"]))
			$xml .= "<cvmvalue>" . $pdata["cvmvalue"] . "</cvmvalue>";

		if (isset($pdata["cvmindicator"]))
			$xml .= "<cvmindicator>" . $pdata["cvmindicator"] . "</cvmindicator>";

		if (isset($pdata["track"]))
			$xml .= "<track>" . $pdata["track"] . "</track>";

		$xml .= "</creditcard>";


		### BILLING NODE ###
		$xml .= "<billing>";

		if (isset($pdata["name"]))
			$xml .= "<name>" . $pdata["name"] . "</name>";

		if (isset($pdata["company"]))
			$xml .= "<company>" . $pdata["company"] . "</company>";

		if (isset($pdata["address1"]))
			$xml .= "<address1>" . $pdata["address1"] . "</address1>";
		elseif (isset($pdata["address"]))
			$xml .= "<address1>" . $pdata["address"] . "</address1>";

		if (isset($pdata["address2"]))
			$xml .= "<address2>" . $pdata["address2"] . "</address2>";

		if (isset($pdata["city"]))
			$xml .= "<city>" . $pdata["city"] . "</city>";
			
		if (isset($pdata["state"]))
			$xml .= "<state>" . $pdata["state"] . "</state>";
			
		if (isset($pdata["zip"]))
			$xml .= "<zip>" . $pdata["zip"] . "</zip>";

		if (isset($pdata["country"]))
			$xml .= "<country>" . $pdata["country"] . "</country>";

		if (isset($pdata["userid"]))
			$xml .= "<userid>" . $pdata["userid"] . "</userid>";

		if (isset($pdata["email"]))
			$xml .= "<email>" . $pdata["email"] . "</email>";

		if (isset($pdata["phone"]))
			$xml .= "<phone>" . $pdata["phone"] . "</phone>";

		if (isset($pdata["fax"]))
			$xml .= "<fax>" . $pdata["fax"] . "</fax>";

		if (isset($pdata["addrnum"]))
			$xml .= "<addrnum>" . $pdata["addrnum"] . "</addrnum>";

		$xml .= "</billing>";

		
		## SHIPPING NODE ##
		$xml .= "<shipping>";

		if (isset($pdata["sname"]))
			$xml .= "<name>" . $pdata["sname"] . "</name>";

		if (isset($pdata["saddress1"]))
			$xml .= "<address1>" . $pdata["saddress1"] . "</address1>";

		if (isset($pdata["saddress2"]))
			$xml .= "<address2>" . $pdata["saddress2"] . "</address2>";

		if (isset($pdata["scity"]))
			$xml .= "<city>" . $pdata["scity"] . "</city>";

		if (isset($pdata["sstate"]))
			$xml .= "<state>" . $pdata["sstate"] . "</state>";
		elseif (isset($pdata["state"]))
			$xml .= "<state>" . $pdata["sstate"] . "</state>";

		if (isset($pdata["szip"]))
			$xml .= "<zip>" . $pdata["szip"] . "</zip>";
		elseif (isset($pdata["sip"]))
			$xml .= "<zip>" . $pdata["zip"] . "</zip>";

		if (isset($pdata["scountry"]))
			$xml .= "<country>" . $pdata["scountry"] . "</country>";

		if (isset($pdata["scarrier"]))
			$xml .= "<carrier>" . $pdata["scarrier"] . "</carrier>";

		if (isset($pdata["sitems"]))
			$xml .= "<items>" . $pdata["sitems"] . "</items>";

		if (isset($pdata["sweight"]))
			$xml .= "<weight>" . $pdata["sweight"] . "</weight>";

		if (isset($pdata["stotal"]))
			$xml .= "<total>" . $pdata["stotal"] . "</total>";

		$xml .= "</shipping>";


		### TRANSACTIONDETAILS NODE ###
		$xml .= "<transactiondetails>";

		if (isset($pdata["oid"]))
			$xml .= "<oid>" . $pdata["oid"] . "</oid>";

		if (isset($pdata["ponumber"]))
			$xml .= "<ponumber>" . $pdata["ponumber"] . "</ponumber>";

		if (isset($pdata["recurring"]))
			$xml .= "<recurring>" . $pdata["recurring"] . "</recurring>";

		if (isset($pdata["taxexempt"]))
			$xml .= "<taxexempt>" . $pdata["taxexempt"] . "</taxexempt>";

		if (isset($pdata["terminaltype"]))
			$xml .= "<terminaltype>" . $pdata["terminaltype"] . "</terminaltype>";

		if (isset($pdata["ip"]))
			$xml .= "<ip>" . $pdata["ip"] . "</ip>";

		if (isset($pdata["reference_number"]))
			$xml .= "<reference_number>" . $pdata["reference_number"] . "</reference_number>";

		if (isset($pdata["transactionorigin"]))
			$xml .= "<transactionorigin>" . $pdata["transactionorigin"] . "</transactionorigin>";

		if (isset($pdata["tdate"]))
			$xml .= "<tdate>" . $pdata["tdate"] . "</tdate>";

		$xml .= "</transactiondetails>";


		### MERCHANTINFO NODE ###
		$xml .= "<merchantinfo>";

		if (isset($pdata["configfile"]))
			$xml .= "<configfile>" . $pdata["configfile"] . "</configfile>";

		if (isset($pdata["keyfile"]))
			$xml .= "<keyfile>" . $pdata["keyfile"] . "</keyfile>";

		if (isset($pdata["host"]))
			$xml .= "<host>" . $pdata["host"] . "</host>";

		if (isset($pdata["port"]))
			$xml .= "<port>" . $pdata["port"] . "</port>";

		if (isset($pdata["appname"]))
			$xml .= "<appname>" . $pdata["appname"] . "</appname>";

		$xml .= "</merchantinfo>";



		### PAYMENT NODE ###
		$xml .= "<payment>";

		if (isset($pdata["chargetotal"]))
			$xml .= "<chargetotal>" . $pdata["chargetotal"] . "</chargetotal>";

		if (isset($pdata["tax"]))
			$xml .= "<tax>" . $pdata["tax"] . "</tax>";

		if (isset($pdata["vattax"]))
			$xml .= "<vattax>" . $pdata["vattax"] . "</vattax>";

		if (isset($pdata["shipping"]))
			$xml .= "<shipping>" . $pdata["shipping"] . "</shipping>";

		if (isset($pdata["subtotal"]))
			$xml .= "<subtotal>" . $pdata["subtotal"] . "</subtotal>";

		$xml .= "</payment>";


		### CHECK NODE ### 


		if (isset($pdata["voidcheck"]))
		{
			$xml .= "<telecheck><void>1</void></telecheck>";
		}
		elseif (isset($pdata["routing"]))
		{
			$xml .= "<telecheck>";
			$xml .= "<routing>" . $pdata["routing"] . "</routing>";

			if (isset($pdata["account"]))
				$xml .= "<account>" . $pdata["account"] . "</account>";

			if (isset($pdata["bankname"]))
				$xml .= "<bankname>" . $pdata["bankname"] . "</bankname>";
	
			if (isset($pdata["bankstate"]))
				$xml .= "<bankstate>" . $pdata["bankstate"] . "</bankstate>";

			if (isset($pdata["ssn"]))
				$xml .= "<ssn>" . $pdata["ssn"] . "</ssn>";

			if (isset($pdata["dl"]))
				$xml .= "<dl>" . $pdata["dl"] . "</dl>";

			if (isset($pdata["dlstate"]))
				$xml .= "<dlstate>" . $pdata["dlstate"] . "</dlstate>";

			if (isset($pdata["checknumber"]))
				$xml .= "<checknumber>" . $pdata["checknumber"] . "</checknumber>";
				
			if (isset($pdata["accounttype"]))
				$xml .= "<accounttype>" . $pdata["accounttype"] . "</accounttype>";

			$xml .= "</telecheck>";
		}


		### PERIODIC NODE ###

		if (isset($pdata["startdate"]))
		{
			$xml .= "<periodic>";

			$xml .= "<startdate>" . $pdata["startdate"] . "</startdate>";

			if (isset($pdata["installments"]))
				$xml .= "<installments>" . $pdata["installments"] . "</installments>";

			if (isset($pdata["threshold"]))
						$xml .= "<threshold>" . $pdata["threshold"] . "</threshold>";

			if (isset($pdata["periodicity"]))
						$xml .= "<periodicity>" . $pdata["periodicity"] . "</periodicity>";

			if (isset($pdata["pbcomments"]))
						$xml .= "<comments>" . $pdata["pbcomments"] . "</comments>";

			if (isset($pdata["action"]))
				$xml .= "<action>" . $pdata["action"] . "</action>";

			$xml .= "</periodic>";
		}


		### NOTES NODE ###

		if (isset($pdata["comments"]) || isset($pdata["referred"]))
		{
			$xml .= "<notes>";

			if (isset($pdata["comments"]))
				$xml .= "<comments>" . $pdata["comments"] . "</comments>";

			if (isset($pdata["referred"]))
				$xml .= "<referred>" . $pdata["referred"] . "</referred>";

			$xml .= "</notes>";
		}

		### ITEMS AND OPTIONS NODES ###
	
		if ($this->debugging)	// make it easy to see
		{						// LSGS doesn't mind whitespace
			reset($pdata);

			while (list ($key, $val) = each ($pdata))
			{
				if (is_array($val))
				{
					$otag = 0;
					$ostag = 0;
					$items_array = $val;
					$xml .= "\n<items>\n";

					while(list($key1, $val1) = each ($items_array))
					{
						$xml .= "\t<item>\n";

						while (list($key2, $val2) = each ($val1))
						{
							if (!is_array($val2))
								$xml .= "\t\t<$key2>$val2</$key2>\n";

							else
							{
								if (!$ostag)
								{
									$xml .= "\t\t<options>\n";
									$ostag = 1;
								}

								$xml .= "\t\t\t<option>\n";
								$otag = 1;
								
								while (list($key3, $val3) = each ($val2))
									$xml .= "\t\t\t\t<$key3>$val3</$key3>\n";
							}

							if ($otag)
							{
								$xml .= "\t\t\t</option>\n";
								$otag = 0;
							}
						}

						if ($ostag)
						{
							$xml .= "\t\t</options>\n";
							$ostag = 0;
						}
					$xml .= "\t</item>\n";
					}
				$xml .= "</items>\n";
				}
			}
		}

		else // !debugging
		{
			while (list ($key, $val) = each ($pdata))
			{
				if (is_array($val))
				{
					$otag = 0;
					$ostag = 0;
					$items_array = $val;
					$xml .= "<items>";

					while(list($key1, $val1) = each ($items_array))
					{
						$xml .= "<item>";

						while (list($key2, $val2) = each ($val1))
						{
							if (!is_array($val2))
								$xml .= "<$key2>$val2</$key2>";

							else
							{
								if (!$ostag)
								{
									$xml .= "<options>";
									$ostag = 1;
								}

								$xml .= "<option>";
								$otag = 1;
								
								while (list($key3, $val3) = each ($val2))
									$xml .= "<$key3>$val3</$key3>";
							}

							if ($otag)
							{
								$xml .= "</option>";
								$otag = 0;
							}
						}

						if ($ostag)
						{
							$xml .= "</options>";
							$ostag = 0;
						}
					$xml .= "</item>";
					}
				$xml .= "</items>";
				}
			}
		}

		$xml .= "</order>";

		return $xml;
	}
}
?>

Open in new window

0
 
sdugarAuthor Commented:
code below for file : linkpoint_api.php
<?php
/**
 * 
 * @author    Jared De Blander <jared@iofast.com>
 * @author    James Ballenger <james@iofast.com>
 * @copyright (c) 2008
 * @version   $Rev: 67 $
 * @internal  $Id: linkpoint_api.php 67 2008-10-21 16:37:43Z jared0x90 $
 * @link      http://code.google.com/p/jared0x90-php/source/browse/trunk/osCommerce/catalog/includes/modules/payment/linkpoint_api.php
 *
 * osCommerce, Open Source E-Commerce Solutions
 * http://www.oscommerce.com
 * Copyright (c) 2003 osCommerce
 * Released under the GNU General Public License Version 3
 *
 *  ********* TEST CARDS *********
 * For testing purposes, you can use any of the card numbers listed below. The
 * test card numbers will not result in any charges to the card. Use these card
 * numbers with any expiration date in the future.
 *
 * - Visa Level 2 - 4275330012345675 (replies with a referral message)
 * - JCB - 3566007770003510
 * - Discover - 6011000993010978
 * - MasterCard - 5424180279791765
 * - Visa - 4005550000000019 or 4111111111111111
 * 
 *      It should be noted that 4005550000000019 does not reply with a referral message
 *      on a PREAUTH and in fact gets approved. Only when a SALE is ran does it return
 *      a referral. The other cards we have tested return the same preauth/sale messages
 *      and this one is unique in its behavior.
 * 
 * - MasterCard Level 2 - 5404980000008386
 * - Diners - 36555565010005
 * - Amex - 372700997251009
 *
 *
 * Extended by Jared De Blander and James Ballenger of www.iofast.com
 * 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * 
 *                       ***** PLEASE READ *****
 *               __                                            __
 *        ____  / /__  ____ _________     ________  ____ _____/ /
 *       / __ \/ / _ \/ __ `/ ___/ _ \   / ___/ _ \/ __ `/ __  / 
 *      / /_/ / /  __/ /_/ (__  )  __/  / /  /  __/ /_/ / /_/ /  
 *     / .___/_/\___/\__,_/____/\___/  /_/   \___/\__,_/\__,_/   
 *    /_/                                                        
 * 
 * Due to the popularity of this file and the number of requests we receive for
 * help we have added this short information section. Unfortunately we simply do 
 * not have the time to answer everyone and give one on one help as we both are
 * full time employees for iofast and are typically working well beyond normal 
 * working hours to get our own work done.
 * 
 * As most recently pointed out by "shellyky" on the osCommerce forum starting in 
 * version 1.2 we have forced email records of all CC authorizations/sales both
 * outbound and inbound data. If you'd like to disable this simply search this file
 * for the term mail( and comment out the lines. It is our preference to keep a
 * detailed record of transactions in our email (with the vitals removed) so that
 * we can quickly look up past transactions - gotta love GMail. 
 * 
 * If you would like to hire iofast to perform any kind of diagnostic, installation or 
 * code improvement work on this module or have other osCommerce or PHP related projects
 * you'd like for us to take a look at feel free to contact us at sales@iofast.com. You can 
 * find our rates and other services at:
 * 
 * http://www.iofast.com/iofast_services.php
 * 
 * Most of the errors we see are related to incorrect installation, improper use/ copying 
 * of files into the correct paths, port 1129 not being open (many hosting companies block this) 
 * or not reading the directions to realize that "Secure Credit Card Transaction" is how the text 
 * will appear in the payment module section of the oscommerce website.
 * 
 * The PEM file is also a file that people seem to corrupt or mess up pretty often. It's possible
 * people are uploaded in ASCII mode or it has invalid permissions for your web server to be 
 * able to access it. Either way try uploading it again and check which transfer mode your
 * FTP client is uploading this file in.
 * 
 * Trying to use the linkpoint module in debug or test mode does not currently work.
 * We plan to implement this in the future but at present all of our testing is performed with
 * the linkpoint provided test cards and/or real credit cards and small order totals (for final
 * validation).
 * 
 * Lastly here are some useful links to the linkpoint website should you be interested
 * in working on this module:
 * 
 * LinkPoint API Documentation:
 * 
 * http://www.linkpoint.com/support/sup_index.htm
 * 
 * To go to the API guide directly (This could change 10/21/2008):
 * 
 * http://www.linkpoint.com/product_solutions/internet/linkpointselectapi/LinkPointAPIv3_6.pdf
 * 
 * LinkPoint API Downloads:
 * 
 * http://www.linkpoint.com/viewcart/down_index.htm
 * 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *   
 *
 * Version 1.3.4
 * Changes/Fixes
 * ----------------
 * 1. Increaed verbosity in output.
 * 2. Created new status messages for referral (states that there is a referral code)
 * 3. Created new status message for duplcate transaction, tells customer to wait 1 minute and try again
 * 4. Address, zip & cvv messages changed so that status OK means acceptec but not verified (such as an X code)
 *    Verified means Y (address and zip) or M (cvv and expiration)
 * 5. Adds status of card accepted or not accepted
 * 6. Checks if AVS info exists before attempting to verify against it.
 * 7. Addition of the PLEASE READ section. I suggest you go read it.
 * 
 * Version 1.3.3
 * Changes/Fixes
 * ----------------
 * 1. Forced tax to a $0.00 value to assist with level 2 compliance.
 *
 * Version 1.3.2
 * Changes/Fixes
 * ----------------
 * 1. Cleaned up the file a bit for posting to the SVN
 *
 * Version 1.3.1
 * Changes/Fixes
 * ----------------
 * 1. Removed some of the unset commands to prevent processing transactions in
 *    a class less than level 2.
 * 2. Now available on the Google Code SVN at the link above.
 *
 * Version 1.3
 * Changes/Fixes
 * ----------------
 * 1. Changed to a $1.00 pre-auth and a full amount sale to prevent customers from
 *    accruing excessive holds on their cards from preauths that the bank approved
 *    but we chose to fail based on invalid card info.
 *
 *  Version 1.2b Patch
 *  Changes/Fixes
 *  ----------------
 *  1. More filtering on XML data. A line like richmond � + &, Virginia 123455
 *     � + will work after filtering.  Linkpoint will fail transactions with �
 *     and & in the company name if these are not filtered.
 *
 *  Version 1.2a Patch
 *  Changes/Fixes
 *  ----------------
 *  1.  Changed SALE transaction to POSTAUTH. SALE / PREAUTH creates 2 sets of
 *      'charges' on a credit card even though the first charge (PREAUTH) is not
 *      actually completed. When speaking with LinkPoint initially they did not
 *      state that this methodology would create two seperate charges.
 *  2.  Mail outbound data w/ vital CC details removed to store owner for debugging.
 *  3.  RFC Time/Date stamp subject lines for inbound and outbound data emails
 *
 *  Version 1.2 Patch
 *  Changes/Fixes
 *  ----------------
 *  1.  Most of the bulk code changes occur around lines 289-355.
 *  2.  Preauth verifictaion is now FORCED and CHECKED before a SALE is processed. If preauth passes, sale will be automatically processed. The linkpoint panel will show your preauth and sale events.
 *  3.  If preauth fails detailed error descriptions are given to the user based on the AVS/CVV & Expiration return code from the preauth.
 *  4.  Name is still pulled from BILLING info and is therefore pointless to have a card holder name so the text box was removed.
 *  5.  Commented out line 254 to prevent linkpoint from sending unecessary automated receipts to customers
 *  6.  Commented out line 71 and 74-77. The JavaScript to handle card name is not needed as it was never used.
 *  7.  CVV code is actually used now. This code was never being passed.
 *  8.  Store owner email address receives an email containing the preauth response values. See line 302 to change this.
 *  9.  Added a spot for you to put a CVV helper popup. Feel free to use the images from iofast.com. See line 108.
 *  10. Filter & symbol in company name as it is not allowed by linkpoint. They claimed to be getting us a full list of disallowed symbols but never heard back from them.
 *  11. Cleaned up and properly formatted most of the code using tab spacing.
 **/
class linkpoint_api {
  var $code, $title, $description, $enabled, $cc_type, $transtype, $transmode, $zipcode, $states, $bstate, $sstate;
  // class constructor
  function linkpoint_api() {
    global $order;
    $this->code = 'linkpoint_api';
    $this->title = MODULE_PAYMENT_LINKPOINT_API_TEXT_TITLE;
    $this->description = MODULE_PAYMENT_LINKPOINT_API_TEXT_DESCRIPTION;
    $this->enabled = ((MODULE_PAYMENT_LINKPOINT_API_STATUS == 'True') ? true : false);
    $this->sort_order = MODULE_PAYMENT_LINKPOINT_API_SORT_ORDER;
    $this->states = $this->_state_list();
    if ((int)MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID > 0) {
      $this->order_status = MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID;
    }
    if (is_object($order)) $this->update_status();
  }

  // class methods
  function filterLinkPoint($strToFilter){
    $strToFilter=str_replace("&", " and ", $strToFilter);
    $strToFilter=str_replace("�", "u", $strToFilter);

    return $strToFilter;
  }

  //in string check
  function in_string($haystack,$needle){
    if(stristr($haystack, $needle) === FALSE){
      return false;
    }else{
      return true;
    }
  }

  function update_status() {
    global $order;
    if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_LINKPOINT_API_ZONE > 0) ) {
      $check_flag = false;
      $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_LINKPOINT_API_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
      while ($check = tep_db_fetch_array($check_query)) {
        if ($check['zone_id'] < 1) {
          $check_flag = true;
          break;
        } elseif ($check['zone_id'] == $order->billing['zone_id']) {
          $check_flag = true;
          break;
        }
      }
      if ($check_flag == false) {
        $this->enabled = false;
      }
    }
  }

  function javascript_validation() {
    $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .
    //            '    var cc_owner = document.checkout_payment.linkpoint_api_cc_owner.value;' . "\n" .
            '    var cc_number = document.checkout_payment.linkpoint_api_cc_number.value;' . "\n" .
    //            '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .
    //            '      error_message = error_message + "' . MODULE_PAYMENT_LINKPOINT_API_TEXT_JS_CC_OWNER . '";' . "\n" .
    //            '      error = 1;' . "\n" .
    //            '    }' . "\n" .
            '    if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .
            '      error_message = error_message + "' . MODULE_PAYMENT_LINKPOINT_API_TEXT_JS_CC_NUMBER . '";' . "\n" .
            '      error = 1;' . "\n" .
            '    if (cc_number == "" || cc_number.length < 3) {' . "\n" .
            '      error_message = error_message + "' . MODULE_PAYMENT_LINKPOINT_API_TEXT_JS_CVV_NUMBER . '";' . "\n" .
            '      error = 1;' . "\n" .                                             
            '    }' . "\n" .
            '  }' . "\n";

    return $js;
  }

  function selection() {
    global $order;

    for ($i=1; $i<13; $i++) {
      $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%m - %B',mktime(0,0,0,$i,1,2000)));
    }

    $today = getdate();
    for ($i=$today['year']; $i < $today['year']+10; $i++) {
      $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));
    }
    $selection = array('id' => $this->code,
                         'module' => $this->title,
                         'fields' => array(array('title' => '<img src="'.DIR_WS_IMAGES.'cclogos.gif"><br><br>',
    //                                                 'field' => '<br><br><br>'.tep_draw_input_field('linkpoint_api_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),
                                                 'field' => ''),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_NUMBER,
                                                 'field' => tep_draw_input_field('linkpoint_api_cc_number')),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_EXPIRES,
                                                 'field' => tep_draw_pull_down_menu('linkpoint_api_cc_expires_month', $expires_month) . '&nbsp;' . tep_draw_pull_down_menu('linkpoint_api_cc_expires_year', $expires_year)),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_CHECK_VALUE,
    //                                                 'field' => tep_draw_input_field('linkpoint_api_cc_cvm', '', 'size="4" maxlength="4"') . '&nbsp;&nbsp;(last 3 or 4 digits on back of credit card)<br>' . '&nbsp;&nbsp;</small>'),
                                                'field' => tep_draw_input_field('linkpoint_api_cc_cvm', '', 'size="4" maxlength="4"') . '<img src="spacer.gif" width="13" height="1"><a href="javascript:popupWindow(\''.DIR_WS_IMAGES.'cvv2.html\')" class="articleLink"><img src="'.DIR_WS_IMAGES.'cvv.gif" title="Visa/Mastercard" alt="Visa/Mastercard" align="top" border="0"><img src="spacer.gif" width="5" height="1" border="0"><img src="'.DIR_WS_IMAGES.'cvv-amex.gif" align="top" alt="American Express" title="American Express" border="0"><img src="spacer.gif" width="15" height="1" border="0">Where?</a>')));

    return $selection;
  }

  function pre_confirmation_check() {
    global $HTTP_POST_VARS;

    include(DIR_WS_CLASSES . 'cc_validation.php');

    $cc_validation = new cc_validation();
    $result = $cc_validation->validate($HTTP_POST_VARS['linkpoint_api_cc_number'], $HTTP_POST_VARS['linkpoint_api_cc_expires_month'], $HTTP_POST_VARS['linkpoint_api_cc_expires_year']);
    $error = '';
    switch ($result) {
      case -1:
        $error = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4), strlen($cc_validation->cc_number) );
        break;
      case -2:
      case -3:
      case -4:
        $error = TEXT_CCVAL_ERROR_INVALID_DATE;
        break;
      case false:
        $error = TEXT_CCVAL_ERROR_INVALID_NUMBER;
        break;
    }
    if ( ($result == false) || ($result < 1) ) {
      $payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&linkpoint_api_cc_expires_month=' . $HTTP_POST_VARS['linkpoint_api_cc_expires_month'] . '&linkpoint_api_cc_expires_year=' . $HTTP_POST_VARS['linkpoint_api_cc_expires_year'] . '&linkpoint_api_cc_cvm=' . $HTTP_POST_VARS['linkpoint_api_cc_cvm'];
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false));
    }
    $this->cc_card_type = $cc_validation->cc_type;
    $this->cc_card_number = $cc_validation->cc_number;
    $this->cc_expiry_month = $cc_validation->cc_expiry_month;
    $this->cc_expiry_year = $cc_validation->cc_expiry_year;
    $this->cc_cvm = $HTTP_POST_VARS['linkpoint_api_cc_cvm'];
    $this->cc_nocvm = $HTTP_POST_VARS['linkpoint_api_cc_nocvm'];
  }

  function confirmation() {
    global $HTTP_POST_VARS, $order;
    $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,
                            'fields' => array(array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_OWNER,
                                                    'field' => $order->billing['firstname'] . ' ' . $order->billing['lastname']),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_NUMBER,
                                                    'field' => substr($this->cc_card_number, 0, 4) . str_repeat('X', (strlen($this->cc_card_number) - 8)) . substr($this->cc_card_number, -4)),
    array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_CREDIT_CARD_EXPIRES,
                                                    'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['linkpoint_api_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['linkpoint_api_cc_expires_year'])))));
    return $confirmation;
  }

  function process_button() {
    global $HTTP_SERVER_VARS, $order, $customer_id;
    $sequence = rand(1, 1000);
    $process_button_string = tep_draw_hidden_field('cc_owner', $_POST['cc_owner']) .
    tep_draw_hidden_field('cc_expires', $this->cc_expiry_month . substr($this->cc_expiry_year, -2)) .
    tep_draw_hidden_field('cc_expires_month', $this->cc_expiry_month) .
    tep_draw_hidden_field('cc_expires_year', substr($this->cc_expiry_year, -2)) .
    tep_draw_hidden_field('cc_type', $this->cc_card_type) .
    tep_draw_hidden_field('cc_number', $this->cc_card_number) .
    tep_draw_hidden_field('userid', $customer_id) .
    tep_draw_hidden_field('cc_cvv', $this->cc_cvm);
    //                               tep_draw_hidden_field('cc_cvv', $_POST['cc_cvmvalue']);

    if ($order->billing['country']['iso_code_2'] == 'US') {
      $this->bstate = $this->states[strtoupper($order->billing['state'])];
      if ($this->bstate == '') {
        $this->bstate = $order->billing[state];
      }
      $process_button_string .= tep_draw_hidden_field('bstate', $this->bstate);
    } else {
      $process_button_string .= tep_draw_hidden_field('bstate', $order->billing[state]);
    }

    if ($order->delivery['country']['iso_code_2'] == 'US') {
      $this->sstate = $this->states[strtoupper($order->delivery['state'])];
      if ($this->sstate == '') {
        $this->sstate = $order->delivery[state];
      }
      $process_button_string .= tep_draw_hidden_field('sstate', $this->sstate);
    } else {
      $process_button_string .= tep_draw_hidden_field('sstate', $order->delivery[state]);
    }
    return $process_button_string;
  }

  function before_process() {
    global $_POST, $_SERVER, $order, $cart, $db, $lp_response_array, $lp_order_id, $lpOrderID;

    require(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/linkpoint_api/lphp.php');

    $order->info['cc_type'] = $_POST['cc_type'];
    $order->info['cc_owner'] = $_POST['cc_owner'];
    $order->info['cc_cvv'] = $_POST['cc_cvv'];

    $mylphp = new lphp;

    // Build Info to send to Gateway

    $myorder["host"]       = MODULE_PAYMENT_LINKPOINT_API_SERVER;
    $myorder["port"]       = "1129";
    $myorder["keyfile"]=(DIR_FS_CATALOG. DIR_WS_MODULES . 'payment/linkpoint_api/' . MODULE_PAYMENT_LINKPOINT_API_LOGIN . '.pem');
    $myorder["configfile"] = MODULE_PAYMENT_LINKPOINT_API_LOGIN;        // Store number

    $myorder["ordertype"]  = strtoupper(MODULE_PAYMENT_LINKPOINT_API_AUTHORIZATION_MODE);

    switch (MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE) {
      case "Live": $myorder["result"] = "LIVE"; break;
      case "Test": $myorder["result"] = "GOOD"; break;
      case "Decline": $myorder["result"] = "DECLINE"; break;
    }

    $myorder["transactionorigin"] = "ECI";           // For credit card retail txns, set to RETAIL, for Mail order/telephone order, set to MOTO, for e-commerce, leave out or set to ECI
    //  $myorder["oid"]               = "";  // Order ID number must be unique. If not set, gateway will assign one.
    $myorder["ponumber"]          = "1002";  // Needed for business credit cards
    $myorder["taxexempt"]         = "Y";  // Needed for business credit cards
    $myorder["terminaltype"]      = "UNSPECIFIED";    // Set terminaltype to POS for an electronic cash register or integrated POS system, STANDALONE for a point-of-sale credit card terminal, UNATTENDED for a self-service station, or UNSPECIFIED for e-commerce or other applications
    $myorder["ip"]                = $_SERVER['REMOTE_ADDR'];

    //  $myorder["subtotal"]    = $order->info['subtotal'];
    $myorder["tax"]         = '0.00'; //$order->info['tax'];
    //  $myorder["shipping"]    = $order->info['shipping_cost'];
    $grantotal = number_format($order->info['total'], 2);
    //in version 1.3 we are only going to pre-auth $1.00
    //$myorder["chargetotal"] = str_replace(",", "", $grantotal);
    $myorder["chargetotal"] = "1.00";

    // CARD INFO
    $myorder["cardnumber"]   = $_POST['cc_number'];
    $myorder["cardexpmonth"] = $_POST['cc_expires_month'];
    $myorder["cardexpyear"]  = $_POST['cc_expires_year'];
    if (empty($_POST['cc_cvv'])) {
      $myorder["cvmindicator"] = "not_provided";
    }
    else {
      $myorder["cvmindicator"] = "provided";
    }
    $myorder["cvmvalue"]  = $_POST['cc_cvv'];

    // BILLING INFO
    $myorder["userid"]   = $_POST['userid'];
    $myorder["name"]     = $this->filterLinkPoint($order->billing['firstname'] . ' ' . $order->billing['lastname']);
    $myorder["company"]  = $this->filterLinkPoint($order->billing['company']);
    $myorder["address1"] = $this->filterLinkPoint($order->billing['street_address']);
    $myorder["address2"] = $this->filterLinkPoint($order->billing['suburb']);
    $myorder["city"]     = $this->filterLinkPoint($order->billing['city']);
    $myorder["state"]    = $this->filterLinkPoint($_POST['bstate']);
    $myorder["country"]  = $this->filterLinkPoint($order->billing['country']['iso_code_2']);
    $myorder["phone"]    = $this->filterLinkPoint($order->customer['telephone']);
    //  $myorder["email"]    = $order->customer['email_address'];  //Prevents email address from being sent to linkpoint because they will use it to send an automated receipt to the customer that is uncessary based on the osCommerce system
    $myorder["addrnum"]  = $this->filterLinkPoint($order->billing['street_address']);   // Required for AVS. If not provided, transactions will downgrade.
    $myorder["zip"]      = $this->filterLinkPoint($order->billing['postcode']);  // Required for AVS. If not provided, transactions will downgrade.

    // SHIPPING INFO
    $myorder["sname"]     = $this->filterLinkPoint($order->delivery['firstname'] . ' ' . $order->delivery['lastname']);
    $myorder["saddress1"] = $this->filterLinkPoint($order->delivery['street_address']);
    $myorder["saddress2"] = $this->filterLinkPoint($order->delivery['suburb']);
    $myorder["scity"]     = $this->filterLinkPoint($order->delivery['city']);
    $myorder["sstate"]    = $this->filterLinkPoint($_POST['sstate']);
    $myorder["szip"]      = $this->filterLinkPoint($order->delivery['postcode']);
    $myorder["scountry"]  = $this->filterLinkPoint($order->delivery['country']['iso_code_2']);

    // description needs to be limited to 100 chars
    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
      $api = htmlentities($this->filterLinkPoint($order->products[$i]['name']), ENT_QUOTES, 'UTF-8');
      if (strlen($api) > '100') {
        $descrip = substr($api, 0, 100);
      } else {
        $descrip = $api;
      }
      $iprice = number_format($order->products[$i]['price'], 2);
      $items = array (
          'id'      => $order->products[$i]['id'],
          'description'   => $descrip,
          'quantity'    => $order->products[$i]['qty'],
          'price'   => str_replace(",", "", $iprice) 
      );
      $myorder["items"][$i] = $items;
    }

    // MISC
    //  $myorder["comments"] = "Repeat customer. Ship immediately.";
    $myorder["debugging"] = strtolower(MODULE_PAYMENT_LINKPOINT_API_DEBUG);  // for development only - not intended for production use

    //BACKUP TRANSACTION  BEGIN PREAUTH CODE!
    $realorder=$myorder;
    //added in 1.3 set the real order charge total to the full amount
    $myorder["ordertype"]  = "PREAUTH"; //make sure this is a preauth

    //BEGIN MAIL OUTBOUND DATA v1.3
    $debugoutputorder=$myorder;
    unset($debugoutputorder["cardnumber"]);
    unset($debugoutputorder["cvmvalue"]);
    unset($debugoutputorder["cardexpmonth"]);
    unset($debugoutputorder["cardexpyear"]);
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG OUTBOUND PREAUTH ".date('r'), print_r($debugoutputorder,true));
    //END MAIL OUTBOUND DATA v1.3


    // Send PREAUTH transaction.
    $result = $mylphp->curl_process($myorder);  // use curl methods
    //restore the grand total

    $lpOrderID="Auth: ".$result["r_ordernum"].", AVS: ".$result["r_avs"];

    //mail inbound data v1.3
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG INBOUND PREAUTH ".date('r'), print_r($result,true));

    //perform verification work
    if($result["r_avs"][1]=="N" || $result["r_avs"][3]=="N" || $result["r_avs"][3]=="S" || $result["r_approved"] != "APPROVED") {
      $myerrdisplay='';
      if($result["r_approved"] != "APPROVED") {
        $newerr=split(":",$result["r_error"]);

        //Check if their was a 4th colon delimited section present.
        if(isset($newerr[3])){
          //Make sure it has at least 4 characters
          if(strlen($newerr[3])>3){
            //what happened w/ Address
            if($newerr[3][0]=="N"){
              $myerrdisplay.='Address did not match. ';
            }elseif($newerr[3][0]=="Y"){
              $myerrdisplay.='Address Verified. ';
            }else{
              $myerrdisplay.='Address OK. ';
            }

            //what happened w/ Zip
            if($newerr[3][1]=="N"){
              $myerrdisplay.='Zip did not match. ';
            } elseif($newerr[3][1]=="Y"){
              $myerrdisplay.='Zip Verified. ';
            } else {
              $myerrdisplay.='Zip OK. ';
            }

            //what happened w/ CVV
            //1.3 - Added Test for r_avs=S to Change CVV verification to reject no CVV as well as incorrect CVV.  Module would previously accept good or no CVV and reject bad CVV.
            if($newerr[3][3]=="N"){
              $myerrdisplay.='CVV or Expiration did not match. ';
            }elseif($newerr[3][3]=="S"){
              $myerrdisplay.='CVV Not Provided. ';
            }elseif($newerr[3][3]=="Y"){
              $myerrdisplay.='CVV and Expiration Verified. ';
            }else{
              $myerrdisplay.='CVV and Expiration OK. ';
            }
          }
        }

        //what happened w/ Approval
        if(strstr($result['r_error'], 'R:Referral')){
          $myerrdisplay.='Card not approved, please contact your bank for detailed information or use another card.  This transaction has issued a referral code. ';
        } elseif(strstr($result['r_error'], 'Duplicate transaction')){
          $myerrdisplay.='Duplicate Transaction, please wait 1 minute and try again. ';
        } else {
          $myerrdisplay.='Card not approved, please contact your bank for detailed information or use another card. ';
        }
      }else{
        //what happened w/ Address
        if($result["r_avs"][0]=="N"){
          $myerrdisplay.='Address did not match. ';
        }elseif($result["r_avs"][0]=="Y"){
          $myerrdisplay.='Address Verified. ';
        }else{
          $myerrdisplay.='Address OK. ';
        }

        //what happened w/ Zip
        if($result["r_avs"][1]=="N"){
          $myerrdisplay.='Zip did not match. ';
        } elseif($result["r_avs"][1]=="Y") {
          $myerrdisplay.='Zip Verified. ';
        } else {
          $myerrdisplay.='Zip OK. ';
        }

        //what happened w/ CVV
        //1.3 - Added Test for r_avs=S to Change CVV verification to reject no CVV as well as incorrect CVV.  Module would previously accept good or no CVV and reject bad CVV.
        if($result["r_avs"][3]=="N") {
          $myerrdisplay.='CVV or Expiration did not match. ';
        } elseif($result["r_avs"][3]=="S") {
          $myerrdisplay.='CVV Not Provided. ';
        } elseif($result["r_avs"][3]=="Y") {
          $myerrdisplay.='CVV and Expiration Verified. ';
        } else {
          $myerrdisplay.='CVV and Expiration OK. ';
        }

        $myerrdisplay.='Card approved. ';
      }

      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=PREAUTHORIZATION FAILED - ' . urlencode($myerrdisplay. ' Please correct the listed problems and try again or contact us by phone to process this order.'), 'SSL', true, false));
    }


    //CHANGE FOR 1.3
    //build the real order
    $realorder["chargetotal"] = str_replace(",", "", $grantotal);
    $realorder["ordertype"] = "SALE";

    //BEGIN MAIL OUTBOUND DATA v1.3
    $debugoutputorder=$realorder;
    unset($debugoutputorder["cardnumber"]);
    unset($debugoutputorder["cvmvalue"]);
    unset($debugoutputorder["cardexpmonth"]);
    unset($debugoutputorder["cardexpyear"]);
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG OUTBOUND SALE ".date('r'), print_r($debugoutputorder,true));
    //END MAIL OUTBOUND DATA v1.3


    // Send the SALE transaction.
    $result = $mylphp->curl_process($realorder);  // use curl methods

    $lpOrderID.=", Sale: ".$result["r_ordernum"];

    //mail inbound data v1.3
    mail(STORE_OWNER_EMAIL_ADDRESS, "CC DEBUG INBOUND SALE ".date('r'), print_r($result,true));

    // - SGS-000001: D:Declined:P:
    //- SGS-005005: Duplicate transaction.
    //  Begin Transaction Status does not = APPROVED

    if ($myorder['debugging'] == 'true') {
      exit;
    }

    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'D:Declined')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_DECLINED_MESSAGE), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'R:Referral')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_DECLINED_MESSAGE), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'Duplicate transaction')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_DUPLICATE_MESSAGE), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" && strstr($result['r_error'], 'SGS')) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode($result["r_error"]), 'SSL', true, false));
    }
    if ($result["r_approved"] != "APPROVED" ) {
      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . ' - ' . urlencode(MODULE_PAYMENT_LINKPOINT_API_TEXT_ERROR_MESSAGE), 'SSL', true, false));
    }
    //  End Transaction Status does not = APPROVED
  }

  function after_process() {
    return false;
  }

  function get_error() {
    global $_GET;
    $error = array('title' => MODULE_PAYMENT_LINKPOINT_API_TEXT_ERROR,
      'error' => stripslashes(urldecode($_GET['error'])));
    return $error;
  }

  function check() {
    if (!isset($this->_check)) {
      $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_LINKPOINT_API_STATUS'");
      $this->_check = tep_db_num_rows($check_query);
    }
    return $this->_check;
  }

  function install() {
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Linkpoint API module', 'MODULE_PAYMENT_LINKPOINT_API_STATUS', 'True', 'Do you want to accept Linkpoint payments?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Store Number', 'MODULE_PAYMENT_LINKPOINT_API_LOGIN', '000001', 'The 6 or 7 digit store number for LinkPoint. For Yourpay accounts you must enter your 10 digit store number.', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('LinkPoint Transaction Mode', 'MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE', 'Live', '<strong>Live:</strong> Use for live transactions<br /><strong>Test:</strong> Use for test transactions', '6', '0', 'tep_cfg_select_option(array(\'Live\', \'Test\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Authorization Type', 'MODULE_PAYMENT_LINKPOINT_API_AUTHORIZATION_MODE', 'Preauth', 'Preauth will reserve the funds on the credit card. Sale will immediately charge the card.', '6', '0', 'tep_cfg_select_option(array(\'Preauth\', \'Sale\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('LinkPoint server', 'MODULE_PAYMENT_LINKPOINT_API_SERVER', 'secure.linkpt.net', 'LinkPoint secure server', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Debugging', 'MODULE_PAYMENT_LINKPOINT_API_DEBUG', 'False', 'Only use for troubleshooting errors.', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_LINKPOINT_API_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_LINKPOINT_API_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
  }

  function remove() {
    tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }

  function keys() {
    return array( 'MODULE_PAYMENT_LINKPOINT_API_STATUS', 'MODULE_PAYMENT_LINKPOINT_API_LOGIN', 'MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE', 'MODULE_PAYMENT_LINKPOINT_API_AUTHORIZATION_MODE', 'MODULE_PAYMENT_LINKPOINT_API_SERVER', 'MODULE_PAYMENT_LINKPOINT_API_DEBUG', 'MODULE_PAYMENT_LINKPOINT_API_SORT_ORDER', 'MODULE_PAYMENT_LINKPOINT_API_ZONE', 'MODULE_PAYMENT_LINKPOINT_API_ORDER_STATUS_ID');
  }

  function _state_list() {
    $list = array('ALABAMA' => 'AL',
        'ALASKA' => 'AK' ,
        'ARIZONA' => 'AZ' ,
        'ARKANSAS' => 'AR' ,
        'CALIFORNIA' => 'CA' ,
        'COLORADO' => 'CO' ,
        'CONNECTICUT' => 'CT' ,
        'DELAWARE' => 'DE' ,
        'DISTRICT OF COLUMBIA' => 'DC' ,
        'FLORIDA' => 'FL' ,
        'GEORGIA' => 'GA' ,
        'HAWAII' => 'HI' ,
        'IDAHO' => 'ID' ,
        'ILLINOIS' => 'IL' ,
        'INDIANA' => 'IN' ,
        'IOWA' => 'IA' ,
        'KANSAS' => 'KS' ,
        'KENTUCKY' => 'KY' ,
        'LOUISIANA' => 'LA' ,
        'MAINE' => 'ME' ,
        'MARYLAND' => 'MD' ,
        'MASSACHUSETTS' => 'MA' ,
        'MICHIGAN' => 'MI' ,
        'MINNESOTA' => 'MN' ,
        'MISSISSIPPI' => 'MS' ,
        'MISSOURI' => 'MO' ,
        'MONTANA' => 'MT' ,
        'NEBRASKA' => 'NE' ,
        'NEVADA' => 'NV' ,
        'NEW HAMPSHIRE' => 'NH' ,
        'NEW JERSEY' => 'NJ' ,
        'NEW MEXICO' => 'NM' ,
        'NEW YORK' => 'NY' ,
        'NORTH CAROLINA' => 'NC' ,
        'NORTH DAKOTA' => 'ND' ,
        'OHIO' => 'OH' ,
        'OKLAHOMA' => 'OK' ,
        'OREGON' => 'OR' ,
        'PENNSYLVANIA' => 'PA' ,
        'RHODE ISLAND' => 'RI' ,
        'SOUTH CAROLINA' => 'SC' ,
        'SOUTH DAKOTA' => 'SD' ,
        'TENNESSEE' => 'TN' ,
        'TEXAS' => 'TX' ,
        'UTAH' => 'UT' ,
        'VERMONT' => 'VT' ,
        'VIRGINIA' => 'VA' ,
        'WASHINGTON' => 'WA' ,
        'WEST VIRGINIA' => 'WV' ,
        'WISCONSIN' => 'WI' ,
        'WEST VIRGINIA' => 'WV' ,
        'WYOMING' => 'WY');
    return $list;
  }
}
?>

Open in new window

0
 
sdugarAuthor Commented:
Please check now i pasted the whole code as it is by copting from page.I am sure you will get line 172 now.

regards,
Sunny
0
 
Ray PaseurCommented:
OK, the lphp class has the offending thing on line 172.  But according to the copyright, this script is several years old.  Have you looked for the latest version?  It might be a better way to get past this issue - just upgrade and collect all the bug fixes of the last 6 years.
0
 
sdugarAuthor Commented:
the copy has bug fixed  as many is using the same.

I agree your point.but this is the latest file i managed to get from Oscommerce Modules.

regards,
Sunny
0
 
sdugarAuthor Commented:
can you put some light for the problem.Do i need to install SSL on server to get it work.

regards,
Sunny
0
 
Ray PaseurCommented:
You might try this...

Remove the debug statements and see if it works.

Or go into the function curl_process($data) at line 149 of the lphp script.  Add a var_dump() to see what is in $data.  The statements at line 171 and 172 look like this:

while (list($key, $value) = each($data))
    echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n";

Unfortunately, that causes the script to fail.  The var_dump() function can show you which element of the $data array is not a string.
0
 
sdugarAuthor Commented:
Hi,

I have tested that already .The value is getting passed properly in string in the array.

regards,
Sunny
0
 
Ray PaseurCommented:
I cannot see any reason why SSL would be implicated in this particular failure.  

I tried running this and the object looks like it is OK.  But there are fields in the object that are, themselves, empty objects.  And whatever code created this XML might be inspected to see if it should not be putting a NULL string instead.  Or the code that interprets this XML may be creating an array instead of a NULL string.  Look at billing->company and billing->address2
<?php // RAY_temp_xml_example_244.php
error_reporting(E_ALL);
echo "<pre>";

// THE XML FROM THE POST AT EE
$xml = <<<XML
<order><orderoptions><ordertype>PREAUTH</ordertype><result>LIVE</result></orderoptions><creditcard><cardnumber>4111111111111111</cardnumber><cardexpmonth>01</cardexpmonth><cardexpyear>14</cardexpyear><cvmvalue>692</cvmvalue><cvmindicator>provided</cvmindicator></creditcard><billing><name>sunny jain</name><company></company><address1>richfield drive</address1><address2></address2><city>san jose</city><state>CA</state><zip>700055</zip><country>US</country><userid>4</userid><phone>9830098300</phone><addrnum>richfield drive</addrnum></billing><shipping><name>sunny jain</name><address1>richfield drive</address1><address2></address2><city>san jose</city><state>CA</state><zip>700055</zip><country>US</country></shipping><transactiondetails><ponumber>1002</ponumber><taxexempt>Y</taxexempt><terminaltype>UNSPECIFIED</terminaltype><ip>122.163.182.184</ip><transactionorigin>ECI</transactionorigin></transactiondetails><merchantinfo><configfile>1306468</configfile><keyfile>/home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/1306468.pem</keyfile><host>secure.linkpt.net</host><port>1129</port></merchantinfo><payment><chargetotal>1.00</chargetotal><tax>0.00</tax></payment> <items> <item> <id>78</id> <description>testing</description> <quantity>1</quantity> <price>0.50</price> </item> </items> </order>
XML;

// MAKE AN OBJECT AND VISUALIZE IT
$obj = SimpleXML_Load_String($xml);
var_dump($obj);

Open in new window

0
 
Ray PaseurCommented:
Please add the var_dump($data) in the function curl_process($data) near line 149 of the lphp script.  If you do it this way, it will be easier to read.

echo "<pre>";
var_dump($data);
die('DONE');

Please copy and paste that output into the code snippet here, thanks.
0
 
sdugarAuthor Commented:
Hi,

I did as you mentioned and received the following array pasted below in code.
array(38) {
  ["host"]=>
  string(17) "secure.linkpt.net"
  ["port"]=>
  string(4) "1129"
  ["keyfile"]=>
  string(84) "/home/hsrgnh9/public_html/catalog/includes/modules/payment/linkpoint_api/1306468.pem"
  ["configfile"]=>
  string(7) "1306468"
  ["ordertype"]=>
  string(7) "PREAUTH"
  ["result"]=>
  string(4) "LIVE"
  ["transactionorigin"]=>
  string(3) "ECI"
  ["ponumber"]=>
  string(4) "1002"
  ["taxexempt"]=>
  string(1) "Y"
  ["terminaltype"]=>
  string(11) "UNSPECIFIED"
  ["ip"]=>
  string(13) "122.162.43.17"
  ["tax"]=>
  string(4) "0.00"
  ["chargetotal"]=>
  string(4) "1.00"
  ["cardnumber"]=>
  string(16) "4111111111111111"
  ["cardexpmonth"]=>
  string(2) "01"
  ["cardexpyear"]=>
  string(2) "11"
  ["cvmindicator"]=>
  string(8) "provided"
  ["cvmvalue"]=>
  string(3) "111"
  ["userid"]=>
  string(1) "4"
  ["name"]=>
  string(10) "sunny jain"
  ["company"]=>
  string(0) ""
  ["address1"]=>
  string(15) "richfield drive"
  ["address2"]=>
  string(0) ""
  ["city"]=>
  string(8) "san jose"
  ["state"]=>
  string(2) "CA"
  ["country"]=>
  string(2) "US"
  ["phone"]=>
  string(10) "9830098300"
  ["addrnum"]=>
  string(15) "richfield drive"
  ["zip"]=>
  string(6) "700055"
  ["sname"]=>
  string(10) "sunny jain"
  ["saddress1"]=>
  string(15) "richfield drive"
  ["saddress2"]=>
  string(0) ""
  ["scity"]=>
  string(8) "san jose"
  ["sstate"]=>
  string(2) "CA"
  ["szip"]=>
  string(6) "700055"
  ["scountry"]=>
  string(2) "US"
  ["items"]=>
  array(1) {
    [0]=>
    array(4) {
      ["id"]=>
      int(78)
      ["description"]=>
      string(7) "testing"
      ["quantity"]=>
      string(1) "1"
      ["price"]=>
      string(4) "0.50"
    }
  }
  ["debugging"]=>
  string(4) "true"
}
DONE

Open in new window

0
 
Ray PaseurCommented:
Now we may be getting somewhere!  The ["items"] is an array of arrays.  Look near the bottom of the var_dump() output.  This is what is causing the error message about "string expected, array given" and in turn that error message is getting sent before the header() commands are executed.  It is a law of HTTP that all headers must be complete before any browser output (even whitespace).

In the SimpleXML object we created above, "items" can have more than one "item" - and this makes sense for a shopping cart.  I cannot believe that this has not been fixed some time in the last 6 years.

Here are the choices, as I see it.  Try it without using the debug statements so it skips the bad code.  Or modify it to use var_dump() but not to die().  Or test the elements to make sure you do not send an array to a string function.

  ["items"]=>
  array(1) {
    [0]=>
    array(4) {
      ["id"]=>
      int(78)
      ["description"]=>
      string(7) "testing"
      ["quantity"]=>
      string(1) "1"
      ["price"]=>
      string(4) "0.50"
    }
  }
0
 
sdugarAuthor Commented:
Dear Ray,

The warning message is getting created in debug mode and that is not response from linkpoint.

When we remove debug mode we are not getting any wrror from linkpoint only gets message CC is declined.

regards,
Sunny
0
 
Ray PaseurCommented:
Yes, that makes sense because the credit card number is 4111111111111111.
0
 
sdugarAuthor Commented:
yes this is test card and getting declined.But the real card also get same message .
0
 
Ray PaseurCommented:
Well, we have gotten past the PHP errors in debug mode, which was the subject of this question.  I doubt if I can help you understand what LinkPoint may be doing about the credit cards.  Cards can and do get declined for a variety of reasons.  The payment provider probably will not tell the merchant what the reason would be, however they might tell you to capture the card if possible.  You might start by using var_dump() to see all the data returned to you with the "declined" condition, and work from there.  Also, you may want to contact LinkPoint directly.  The decision to accept or decline a card is made inside their software, so they would be the ones to ask about this.

Best of luck with the project, ~Ray
0
 
nsonbatyCommented:
please check line 30 in your original message

addrnum = richfield drive

I think it should be numbers not text
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 12
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now