Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

3rd Party Merchant Accounts


Guest

Recommended Posts

Hi,

 

I have a client that is operating an osCommerce Cart. He wants to use LinkPoint as his merchant service and credit card processing entity.

 

http://www.linkpoint.com is the web address. They have API or a wrapper has anyone had any experience with incorporating a 3rd Party Merchant Account?

 

Thanks

Link to comment
Share on other sites

The Bear,

Thanks for pointing out those links to MGodwin! I forgot to do so, sorry. I am trying to installe the Cardservices contribution. My client will use the linkpoint gateway along with Card Services as their merchant provider.

 

I have now got everything installed and everything seems to work fine, well ALMOST.

 

I am gettin a problem relating to Curl. I don't really understand why or what because I am not a network specialist. I have contacted my hosting compnay to see if they need to set permissions for me to use the Curl. Or I might just have to specify the exact directroy of the Curl.

 

Does anyone know by the way... If a customer uses Visa or Mastercard. Do they have to specify that or will it work with either. (or other cards involved in the merchant agreement?

Link to comment
Share on other sites

So, I am not doing so well... :cry: Maybe someone could help me? I got the Curl problem solved but now I have a new problem. I wonder if it relates to me using the 2.2MS1 version rather than the 2.2CVS version. When reading the installation guide the main file that is spoken of is the Linkpoint lphp.php3 instead of the newly re-named (and FREE!) lpphp.php file.

 

Anyhow, the problem I am getting is:

 

There has been an error processing you credit card, please try again.: Element 'zip' is not valid for content model: 'All(weight?,items?,carrier?,total?,name?,address1?,address2?,city?,state?,zip?,country?)' (line 1, col 826)

 

Plus I am getting an error when a customer places an invalid expiration date (for instance an expired date):

 

Fatal error: Call to undefined function: get_error() in /home/crs/checkout_payment.php on line 171

 

I also had to add to the language/english/linkpoint.php the following code (and it helped in the Java pop-up alert):

 

define('MODULE_PAYMENT_LINKPOINT_TEXT_JS_CC_OWNER', ' * You must specify your name as it appears on your card.');

 

Does anyone know what is happening here?

Link to comment
Share on other sites

So, I am not doing so well... :cry: Maybe someone could help me? I got the Curl problem solved but now I have a new problem. I wonder if it relates to me using the 2.2MS1 version rather than the 2.2CVS version. When reading the installation guide the main file that is spoken of is the Linkpoint lphp.php3 instead of the newly re-named (and FREE!) lpphp.php file.

 

Anyhow, the problem I am getting is:

 

There has been an error processing you credit card, please try again.: Element 'zip' is not valid for content model: 'All(weight?,items?,carrier?,total?,name?,address1?,address2?,city?,state?,zip?,country?)' (line 1, col 826)

The message indicates that for some reason they are thinking that the zip field should be the model field. Check their documentation to see if they did not reorganize their field order.

 

Plus I am getting an error when a customer places an invalid expiration date (for instance an expired date):

 

Fatal error: Call to undefined function: get_error() in /home/crs/checkout_payment.php on line 171

Verify that your catalog/includes/modules/payment/linkpoint.php file there is a get_error() function defined.

 

I also had to add to the language/english/linkpoint.php the following code (and it helped in the Java pop-up alert):

 

define('MODULE_PAYMENT_LINKPOINT_TEXT_JS_CC_OWNER', ' * You must specify your name as it appears on your card.');

 

Does anyone know what is happening here?

It sounds like a few thing have changed in osC since the contribution was last updated.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Thanks Jim!

I got that get_error problem solved:

Fatal error: Call to undefined function: get_error() in /home/crs/checkout_payment.php on line 171

The linkpoint.php file had an output_error instead of the get_error. I changed the output_error to get_error and sure enough it worked!

 

I am still working on the zip problem. I did however do some progress in understanding the problem. Just to be curious I commented out all the parameters that had to do with "zip" and to my surprise EVERYTHING WORKED! But of course this isn't an ideal situation since I am not getting the zip codes added to the Linkpoint order.

 

So then I decided to check what happened if I commented out one of the zip codes. i.e "bzip" and "szip". When I commented out the "szip" everything still worked and the billing zip was recorded in the Linkpoint order.

 

However when I included the "szip" again I got the error:

Fatal error: Call to undefined function: get_error() in /home/crs/checkout_payment.php on line 171

 

So I called Linkpoint up and they said that another gentleman from New Zeeland had just called in and had the exact same problem. So I assume it might be something wrong on Linkpoints part. Anyhow, they said they would call me back as soon as their API specialist gets to it.

 

That's it, so I am just waiting for now. Hopefully they will solve it quick. I might very well install the Header tag contribution now. Just to keep myself busy and on task. *ha,ha*

 

Thanks again for your input, I will report back here when I get everything to work.

Link to comment
Share on other sites

I am glad to hear that you are on the way to resolving your problem.

 

If it is not too much to ask, how about updating the contribution files after you receive a response from LinkPoint and get all of the problems resolved?

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Sure, I can update the contribution files. I'd prefer to have someone professional look at what I've changed before I'd feel right about updating anything. My experience in PHP and MySQL, not even mentioning this type of secure payment gateway is very, very slim.

 

Jim, are you using the Linkpoint? Maybe you would care to have a look at the files once I get everything to work?

 

I did contact Tim Wasson who contributed the last updated file and he gave me some feedback similar to yours. I promised I would keep him updated on my progress. Maybe he'll have a look at the file changes and post a new and updated contribution?

 

Anyhow, I have to wait to hear back from Linkpoint. I'll let you know what's happening on that front.

Link to comment
Share on other sites

No, I do not use LinkPoint.

 

Tim would be the best person to have a look at your files or the information that you receive to do a proper update.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

No reply yet from Linkpoint regarding the mysterious "szip" problem. I figured out that this isn't that "big" of a deal. I can always find the shipping zip code in the osc admin panel...

 

Another thing that has alerted me while doing test orders :!:

 

In the Credit Card Owner input field...it doesn't matter what I type in?? Let's say I type in "Alligator" the order will still be processed under my personl account name!! In other words...I type in alligator an use the test Visa number with a valid expiration date...I will see the order as Thomas N. in the Linkpoint report.

 

This isn't so bad EXCEPT for that the customer won't know it. What if they try to use a credit card of a friend (with permission). They type in their friend's name and his/her credit card number with a valid expiration date. Now they think everything is going well since the credit card in question is in good standard. However they will get a return result : Credit card name and number doesn't match!

 

They try it again, and again, and again! without realizing that osCommerce is actually using their name when posting it to the payment gateway.

 

Therefore, I would like to implement what PSiGate has done. They simply don't include an input field for the name but rather extract the osCommerce name into the table cell. Now, you can't go wrong! Even someone with lesser information will realize they will have to go into their Account Manager and change their name as it appears on their Credit Card (which in most cases should be their complete name).

 

Now, I'm trying to figure out how to do this...PSiGate did it like this:

 

      if (MODULE_PAYMENT_PSIGATE_INPUT_MODE == 'Local') {

       $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,

                             'fields' => array(array('title' => MODULE_PAYMENT_PSIGATE_TEXT_CREDIT_CARD_OWNER,

                                                     'field' => $order->billing['firstname'] . ' ' . $order->billing['lastname']),

                                               array('title' => MODULE_PAYMENT_PSIGATE_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_PSIGATE_TEXT_CREDIT_CARD_EXPIRES,

                                                     'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['psigate_cc_expires_month'], 1, '20' . $HTTP_POST_VARS['psigate_cc_expires_year'])))));

 

The important code above being: 'field' => $order->billing['firstname'] . ' ' . $order->billing['lastname']),

 

while iPayment does it so that the name is automatically extracted to an input field. (which I think is deceiving since if you try to change this to "Friend's name" it still won't process the form as friend's name):

 

'field' => tep_draw_input_field('ipayment_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),

 

I tried to change the Linkpoint field to a similar that PSiGate has:

 

      $selection = array('id' => $this->code,

                        'module' => $this->title,

                        'fields' => array(array('title' => MODULE_PAYMENT_LINKPOINT_TEXT_CREDIT_CARD_OWNER,

                                                'field' => $order->customer['firstname'] . ' ' . $order->customer['lastname']),

                                          array('title' => MODULE_PAYMENT_LINKPOINT_TEXT_CREDIT_CARD_NUMBER,

                                                'field' => tep_draw_input_field('cc_number')),

                                          array('title' => MODULE_PAYMENT_LINKPOINT_TEXT_CREDIT_CARD_EXPIRES,

                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year))));

 

but it won't work! I changed the $order->billing to $order->customer because it seemed like there wasn't a billing parameter in the database query for Linkpoint. ex:

$process_button_string = tep_draw_hidden_field('x_Login', MODULE_PAYMENT_LINKPOINT_LOGIN) .

                              tep_draw_hidden_field('x_Card_Num', $this->cc_card_number) .

                              tep_draw_hidden_field('x_Exp_Month', $HTTP_POST_VARS['cc_expires_month']) .

                              tep_draw_hidden_field('x_Exp_Year', $HTTP_POST_VARS['cc_expires_year']) .

                              tep_draw_hidden_field('x_Exp_Date', $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year']) .

                              tep_draw_hidden_field('x_Amount', round($order->info['total'],2) ) .

                              tep_draw_hidden_field('x_ADC_Relay_Response', 'TRUE') .

                              tep_draw_hidden_field('x_ADC_URL', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', false)) .

                              tep_draw_hidden_field('x_Method', MODULE_PAYMENT_LINKPOINT_METHOD) .

                              tep_draw_hidden_field('x_Version', '3.0') .

                              tep_draw_hidden_field('x_Cust_ID', $customer_id) .

                              tep_draw_hidden_field('x_Email_Customer', (MODULE_PAYMENT_LINKPOINT_EMAIL == '1'? 'TRUE': 'FALSE')) .

                              tep_draw_hidden_field('x_Email_Merchant', (MODULE_PAYMENT_LINKPOINT_EMAIL_MERCHANT == '1'? 'TRUE': 'FALSE')) .

                              tep_draw_hidden_field('x_Cust_Name', $order->customer['firstname'] . ' ' . $order->customer['lastname']) .

                              tep_draw_hidden_field('x_first_name', $order->customer['firstname']) .

                              tep_draw_hidden_field('x_last_name', $order->customer['lastname']) .

                              tep_draw_hidden_field('x_address', $order->customer['street_address']) .

                              tep_draw_hidden_field('x_city', $order->customer['city']) .

                              tep_draw_hidden_field('x_state', $order->customer['state']) .

                              tep_draw_hidden_field('x_zip', $order->customer['postcode']) .

                              tep_draw_hidden_field('x_country', $order->customer['country']) .

                              tep_draw_hidden_field('x_phone', $order->customer['telephone']) .

                              tep_draw_hidden_field('x_email', $order->customer['email_address']) .

                              tep_draw_hidden_field('x_ship_to_name', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']) .

                              tep_draw_hidden_field('x_ship_to_first_name', $order->delivery['firstname']) .

                              tep_draw_hidden_field('x_ship_to_last_name', $order->delivery['lastname']) .

                              tep_draw_hidden_field('x_ship_to_address', $order->delivery['street_address']) .

                              tep_draw_hidden_field('x_ship_to_city', $order->delivery['city']) .

                              tep_draw_hidden_field('x_ship_to_state', $order->delivery['state']) .

                              tep_draw_hidden_field('x_ship_to_zip', $order->delivery['postcode']) .

                              tep_draw_hidden_field('x_ship_to_country', $order->delivery['country']) .

                              tep_draw_hidden_field('x_Customer_IP', $HTTP_SERVER_VARS['REMOTE_ADDR']);



     $process_button_string .= tep_draw_hidden_field(tep_session_name(), tep_session_id());

     return $process_button_string;

   }

Has anyone faced this problem? Would anyone be able to tell me how to get that customer name included automatically into the Credit Card Owner space?

 

Thanks!

Link to comment
Share on other sites

So, I think I might have solved the problem. The "problem" is partially me who is the problem with my problematicly bad understanding of php! :D

 

Anyhow, I decided to take a look at the "simple" cc payment module. I thought I didn't get the name extracted right because the old Linkpoint file wasn't accessing the database in the same way as the newer payment modules...

 

So I copied this piece of code from the cc payment module into the Linkpoint module:

 

// class methods

   function update_status() {

     global $order;



     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_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_CC_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.cc_owner.value;' . "n" .

           '    var cc_number = document.checkout_payment.cc_number.value;' . "n" .

           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "n" .

           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_TEXT_JS_CC_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('%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)));

     }

 

and I placed it in between the comments:

 

// class methods







and the







// This is for post-Nov-1 2.2 checkout systems

 

Looks like the credit card field looks fine now! Who knows if this is a proper fix? Gotta get to testing my do it yourself (and without understanding) fix!

Link to comment
Share on other sites

Actually, I blew up the idea of trying to fix the old linkpoint code. Instead I took the ipayment module and made it work with linkpoint. I need to contribute an update as soon as I have it fully operational.

 

As of now there is still that "szip" problem but I have been in touch with Linkpoint and they e-mailed me back today and said they might have found a duplicate entry of the szip. Anyhow I should have a new version of their lpphp file and will try that as soon as it comes.

 

I will inform how it goes here in this forum.

Link to comment
Share on other sites

I replied to you PM with this same question, answer it here if want to :?

 

I'm just now looking at the ipayments module and wondering does it do the CC transactions in the proper way:

 

#1 Pre-Authorization (reserve the funds 3-7 days)

#2 You ship the products to the customer and at this same time do the Post-Authorization / BillOrders (using the result codes of the Pre-Auth process to seal the deal and transfer funds)

 

Or does it also do it all at once like the linkpoint payment module does it?

 

I've also posted this question in the Contrib forum list:

 

Thanks

 

http://www.oscommerce.com/forums/viewtopic.php...light=linkpoint

Link to comment
Share on other sites

Well, for all of you who are wondering. Linkpoint got back with me and they fixed the problems I was having with the "szip" code. If you get the same error you should contact Linkpoint for a new lpphp file. They may have updated in their download???

 

Anyhow, me and Sorti have been working together a little in upgrading this module to better standards. I thought I'd include the code as it looks now (on my part). Sorti helped with including the "Extra Order Information" and the CVM values...plus much more...

 

I'm just generally interested to hear what other people think. If someone finds "not needed" stuff or any other mess, please let me know. The coding might not be very clean since I have patched together different scripts (and I'm not a PHP wizard). However, everything seems to work well. I get all the values to show up at Linkpoint Central and the credit card values are added to my database.

 

One major change with the module is that it now does not charge the sale right away. You are going to have to go into Linkpoint Central to post-authorize the sale. (which is very simple) or you could go with the old ApproveSale if you sell downloadable products etc.

 

This is the change:

 

$myresult=$mylpphp->ApproveSale($myorder);



to



$myresult=$mylpphp->CapturePayment($myorder);

 

Here's the entire module script:

 

 

 

<?php

/*

 $Id: linkpointms1.php



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2003 osCommerce



 Released under the GNU General Public License

*/



 class linkpointms1 {

   var $code, $title, $description, $enabled;



// class constructor

   function linkpointms1() {

     global $order;



     $this->code = 'linkpointms1';

     $this->title = MODULE_PAYMENT_LINKPOINTMS1_TEXT_TITLE;

     $this->description = MODULE_PAYMENT_LINKPOINTMS1_TEXT_DESCRIPTION;

     $this->sort_order = MODULE_PAYMENT_LINKPOINTMS1_SORT_ORDER;

     $this->enabled = ((MODULE_PAYMENT_LINKPOINTMS1_STATUS == 'True') ? true : false);

}



// class methods

   function update_status() {

     global $order;



     if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_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_CC_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.cc_owner.value;' . "n" .

           '    var cc_number = document.checkout_payment.cc_number.value;' . "n" .

           '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "n" .

           '      error_message = error_message + "' . MODULE_PAYMENT_CC_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_CC_TEXT_JS_CC_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('%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' => MODULE_PAYMENT_LINKPOINTMS1_TEXT_CREDIT_CARD_OWNER,

                                                'field' => tep_draw_input_field('cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),

                                          array('title' => MODULE_PAYMENT_LINKPOINTMS1_TEXT_CREDIT_CARD_NUMBER,

                                                'field' => tep_draw_input_field('cc_number') . tep_image(DIR_WS_IMAGES . 'credit_cards.gif', 'Credit cards we accept: Visa, Mastercard, American Express, Discover. Your credit card type is detected automatically.', '110', '15')),

                                          array('title' => MODULE_PAYMENT_LINKPOINTMS1_TEXT_CREDIT_CARD_EXPIRES,

                                                'field' => tep_draw_pull_down_menu('cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year)),

                                          array('title' => MODULE_PAYMENT_LINKPOINTMS1_TEXT_CREDIT_CARD_CHECKNUMBER,

                                                'field' => tep_draw_input_field('cc_checkcode', '', 'size="4" maxlength="4"') . '  ' . MODULE_PAYMENT_LINKPOINTMS1_CVS_NOT_PRESENT . tep_draw_checkbox_field('cc_checkcode', '0') . '  </small><a href="javascript:popupWindow('' . tep_href_link(FILENAME_POPUP_CVS_HELP) . '')">' . TEXT_SEARCH_CVS_HELP . '</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['cc_number'], $HTTP_POST_VARS['cc_expires_month'], $HTTP_POST_VARS['cc_expires_year']);



     $error = '';

     switch ($result) {

       case -1:

         $error = sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4));

         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) . '&cc_owner=' . urlencode($HTTP_POST_VARS['cc_owner']) . '&cc_expires_month=' . $HTTP_POST_VARS['cc_expires_month'] . '&cc_expires_year=' . $HTTP_POST_VARS['cc_expires_year'] . '&cc_checkcode=' . $HTTP_POST_VARS['cc_checkcode'];



       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;

   }



   function confirmation() {

     global $HTTP_POST_VARS;



     $confirmation = array('title' => $this->title . ': ' . $this->cc_card_type,

                           'fields' => array(array('title' => MODULE_PAYMENT_LINKPOINTMS1_TEXT_CREDIT_CARD_OWNER,

                                                   'field' => $HTTP_POST_VARS['cc_owner']),

                                             array('title' => MODULE_PAYMENT_LINKPOINTMS1_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_LINKPOINTMS1_TEXT_CREDIT_CARD_EXPIRES,

                                                   'field' => strftime('%B, %Y', mktime(0,0,0,$HTTP_POST_VARS['cc_expires_month'], 1, '20' . $HTTP_POST_VARS['cc_expires_year'])))));



     if (tep_not_null($HTTP_POST_VARS['cc_checkcode'])) {

       $confirmation['fields'][] = array('title' => MODULE_PAYMENT_LINKPOINTMS1_TEXT_CREDIT_CARD_CHECKNUMBER,

                                         'field' => $HTTP_POST_VARS['cc_checkcode']);

     }



     return $confirmation;

   }



   function process_button() {

     global $HTTP_POST_VARS, $HTTP_SERVER_VARS, $CardNumber, $order, $customer_id;





     $process_button_string = tep_draw_hidden_field('x_Cust_ID', $customer_id) .

           tep_draw_hidden_field('x_Login', MODULE_PAYMENT_LINKPOINTMS1_LOGIN) .

                              tep_draw_hidden_field('x_CC_expdate_month', $HTTP_POST_VARS['cc_expires_month']) .

                              tep_draw_hidden_field('x_CC_expdate_year', $HTTP_POST_VARS['cc_expires_year']) .

                              tep_draw_hidden_field('cc_number', $HTTP_POST_VARS['cc_number']) .

                              tep_draw_hidden_field('x_CC_cvmvalue', $HTTP_POST_VARS['cc_checkcode']) .

                              tep_draw_hidden_field('cc_owner', $HTTP_POST_VARS['cc_owner']) .

         tep_draw_hidden_field('cc_type', $this->cc_card_type) .

         tep_draw_hidden_field('cc_expires', $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year']) .

                              tep_draw_hidden_field('x_Email_address', $order->customer['email_address']) .

                              

         tep_draw_hidden_field('x_TotalAmount', sprintf("%01.2lf",$order->info['total']) ) .

         tep_draw_hidden_field('x_SubAmount', sprintf("%01.2lf",$order->info['subtotal']) ) .

         tep_draw_hidden_field('x_Shipping', sprintf("%01.2lf",$order->info['shipping_cost']) ) .

         tep_draw_hidden_field('x_Tax', sprintf("%01.2lf",$order->info['tax']) ) .

         tep_draw_hidden_field('x_ADC_Relay_Response', 'TRUE') .

                              tep_draw_hidden_field('x_Redirect_url', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL', true)) .

                              

                              tep_draw_hidden_field('x_Email_Customer', (MODULE_PAYMENT_LINKPOINTMS1_EMAIL == '1'? 'TRUE': 'FALSE')) .

                              tep_draw_hidden_field('x_Email_Merchant', (MODULE_PAYMENT_LINKPOINTMS1_EMAIL_MERCHANT == '1'? 'TRUE': 'FALSE')) .

         tep_draw_hidden_field('x_Billing_Address', $order->customer['street_address']) .

         tep_draw_hidden_field('x_Billing_Address_Verification', $order->customer['street_address']) .

                              tep_draw_hidden_field('x_Billing_City', $order->customer['city']) .

                              tep_draw_hidden_field('x_Billing_State', $order->customer['state']) .

                              tep_draw_hidden_field('x_Billing_Zip', $order->customer['postcode']) .

                              tep_draw_hidden_field('x_Billing_Country', $order->customer['country']) .

                                        

         tep_draw_hidden_field('x_Phone', $order->customer['telephone']) .

         tep_draw_hidden_field('x_Fax', $order->customer['fax']) .

                              tep_draw_hidden_field('x_Email', $order->customer['email_address']) .

                              tep_draw_hidden_field('x_Comments', $HTTP_POST_VARS['comments']) .

                  

         tep_draw_hidden_field('x_ship_to_name', $order->delivery['firstname'] . ' ' . $order->delivery['lastname']) .

                              tep_draw_hidden_field('x_ship_to_address', $order->delivery['street_address']) .

                              tep_draw_hidden_field('x_ship_to_city', $order->delivery['city']) .

                              tep_draw_hidden_field('x_ship_to_state', $order->delivery['state']) .

                              tep_draw_hidden_field('x_ship_to_zip', $order->delivery['postcode']) .

                              tep_draw_hidden_field('x_ship_to_country', $order->delivery['country']) .

                              tep_draw_hidden_field('x_Customer_IP', $HTTP_SERVER_VARS['REMOTE_ADDR']);



     return $process_button_string;

   }



   function before_process() {

     global $HTTP_POST_VARS;

   #	LINKPOINT CODE INSERTED HERE



 include "includes/linkpoint/lpphp.php"; // you will need to change this to lpphp.php file (supplied by linkpoint)



 $mylpphp=new lpphp;



 /****************    LinkPoint Info    *************************/



 $myorder["host"]=MODULE_PAYMENT_LINKPOINTMS1_SERVER;

 $myorder["port"]="1129";

 $myorder["storename"]=MODULE_PAYMENT_LINKPOINTMS1_LOGIN; // your store ID - supplied by linkpoint

 $myorder["keyfile"]="includes/linkpoint/" . MODULE_PAYMENT_LINKPOINTMS1_LOGIN . ".pem"; // you will need to change this to your pem file (supplied by linkpoint)

 $myorder["result"]=MODULE_PAYMENT_LINKPOINTMS1_MODE;

 $myorder["Ip"]=$HTTP_POST_VARS['x_Customer_IP'];

 /************    Convert Order Variables    ********************/

	 $myorder["userid"] = $HTTP_POST_VARS['x_Cust_ID'];

	 $myorder["cardNumber"] = $HTTP_POST_VARS['cc_number'];

	 $myorder["cardExpMonth"] = $HTTP_POST_VARS['x_CC_expdate_month'];

	 $myorder["cardExpYear"] = $HTTP_POST_VARS['x_CC_expdate_year'];

	 $myorder["bname"] = $HTTP_POST_VARS['cc_owner'];

	 

	 $myorder["email"] = $HTTP_POST_VARS['x_Email_address'];

	 $myorder["phone"] = $HTTP_POST_VARS['x_Phone'];

	 $myorder["fax"] = $HTTP_POST_VARS['x_Fax'];

	 $myorder["comments"] = $HTTP_POST_VARS['x_Comments'];

     

	 $myorder["baddr1"] = $HTTP_POST_VARS['x_Billing_Address'];

	 $myorder["addrnum"] = $HTTP_POST_VARS['x_Billing_Address_Verification'];

	 

	 $myorder["bcity"] = $HTTP_POST_VARS['x_Billing_City'];

	 $myorder["bstate"] = $HTTP_POST_VARS['x_Billing_State'];

	 $myorder["bzip"] = $HTTP_POST_VARS['x_Billing_Zip'];

	 $myorder["bcountry"]= 'US';



	 $myorder["sname"] = $HTTP_POST_VARS['x_ship_to_name'];

	 $myorder["saddr1"] = $HTTP_POST_VARS['x_ship_to_address'];

	 $myorder["scity"] = $HTTP_POST_VARS['x_ship_to_city'];

	 $myorder["sstate"] = $HTTP_POST_VARS['x_ship_to_state'];

	 $myorder["szip"] = $HTTP_POST_VARS['x_ship_to_zip'];

	 $myorder["scountry"]= 'US';



	 $myorder["oid"] = $HTTP_POST_VARS['x_Invoice_Num'];

	 $myorder["chargetotal"] = $HTTP_POST_VARS['x_TotalAmount'];

	 $myorder["subtotal"] = $HTTP_POST_VARS['x_SubAmount'];

	 $myorder["shipping"] = $HTTP_POST_VARS['x_Shipping'];

	 $myorder["tax"] = $HTTP_POST_VARS['x_Tax'];

	 

	 if (tep_not_null($HTTP_POST_VARS['x_CC_cvmvalue'])) {

	 $myorder["cvmindicator"] = 'cvm_provided';

	 $myorder["cvmvalue"] = $HTTP_POST_VARS['x_CC_cvmvalue'];

	 }

	 



 /****************    Begin Processing    ***********************/



 $myresult=$mylpphp->CapturePayment($myorder);        // send transaction for Pre-authorization. You must go and approve the orders in Linkpoint Central when you ship out. Alternatively you could change it to(according to US regulations, you are not suppose to charge until you ship...So maybe for instant sales such as Downloads?): $myresult=$mylpphp->ApproveSale($myorder);



     if ( (defined('MODULE_PAYMENT_LINKPOINTMS1_EMAIL')) && (MODULE_PAYMENT_LINKPOINTMS1_EMAIL != 'NONE') ) {

       $len = strlen($HTTP_POST_VARS['cc_number']);

       $new_cc = substr($HTTP_POST_VARS['cc_number'], 0, 4) . substr('XXXXXXXXXXXXXXXX', 0, $len-8) . substr($HTTP_POST_VARS['cc_number'], -4);

       $GLOBALS['cc_middle'] = substr($HTTP_POST_VARS['cc_number'], 4, $len-8);

       $GLOBALS['cc_number'] = $new_cc;

 $GLOBALS['AVSCode'] = $myresult[AVSCode];



 $GLOBALS['cc_approval_number'] = substr($myresult[AVSCode], 0, 6);

$GLOBALS['cc_reference_number'] = substr($myresult[AVSCode], 6, 10);



     switch (substr($myresult[AVSCode], 17, 1)) {

       case 'Y':$GLOBALS['cc_address_avs_message'] ="Matches Address on File";break;

       case 'N':$GLOBALS['cc_address_avs_message'] ="Does not Match Address on File";break;

       case 'X':$GLOBALS['cc_address_avs_message'] ="Address comparison not available";break;

       default:$GLOBALS['cc_address_avs_message'] ="Unknown Address Result";

    	 }



     switch (substr($myresult[AVSCode], 18, 1)) {

       case 'Y':$GLOBALS['cc_zipcode_avs_message'] ="Matches Zipcode on File";break;

       case 'N':$GLOBALS['cc_zipcode_avs_message'] ="Does not Match zipcode on File";break;

       case 'X':$GLOBALS['cc_zipcode_avs_message'] ="Zipcode comparison not available";break;

       default:$GLOBALS['cc_zipcode_avs_message'] ="Unknown zipcode Result";

    	 }



     switch (substr($myresult[AVSCode], 20, 1)) {

       case 'M':$GLOBALS['cc_cardcode_avs_message'] ="Matches cardcode on File";break;

       case 'N':$GLOBALS['cc_cardcode_avs_message'] ="Does not Match cardcode";break;

       case 'P':$GLOBALS['cc_cardcode_avs_message'] ="Not Processed";break;

       case 'S':$GLOBALS['cc_cardcode_avs_message'] ="Merchant has indicated that the card code is not present on the card";break;

       case 'U':$GLOBALS['cc_cardcode_avs_message'] ="Issuer is not certified and/or has not provided encryption keys";break;

       default:$GLOBALS['cc_cardcode_avs_message'] ="Unknown cardcode Result";

    	 }



     }



#	Returns:  statusCode 1 if successful, 0 or -1 if not

#    statusMessage An error message if an error occurred

#    AVSCode The AVS code returned by the transaction

#    trackingID An ID for tracking the order with the gateway

#	I STILL NEED TO SAVE THESE VALUES INTO THE DATABASE





#	LINKPOINT CODE ENDS HERE



        if ($myresult["statusCode"] != '1') {

       tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(MODULE_PAYMENT_LINKPOINTMS1_TEXT_ERROR_MESSAGE) . ': ' . $myresult["statusMessage"], 'SSL', true, false));

     }

   }

   function after_process() {

     global $insert_id, $HTTP_POST_VARS;

     // globals $CardName, $CardNumber;



if ( (defined('MODULE_PAYMENT_LINKPOINTMS1_EMAIL')) && (MODULE_PAYMENT_LINKPOINTMS1_EMAIL != 'NONE') ) { // send emails to other people

$message = 'AVSCode: ' . $GLOBALS[AVSCode] . "n" . 'Address: ' . $GLOBALS['cc_address_avs_message'] . "n" .'ZipCode: ' . $GLOBALS['cc_zipcode_avs_message'] . "n" .'CardCode: ' . $GLOBALS['cc_cardcode_avs_message'] . "n" . 'Order #:' . $insert_id . "nn" . 'Middle Credit Card Numbers: ' . $GLOBALS['cc_middle'] . "nn";

tep_mail('', MODULE_PAYMENT_LINKPOINTMS1_EMAIL, 'Extra Order Info', $message, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');

     }

  return false;

   }



   function get_error() {

     global $HTTP_GET_VARS;



     $error = array('title' => LINKPOINTMS1_ERROR_HEADING,

                    'error' => ((isset($HTTP_GET_VARS['error'])) ? stripslashes(urldecode($HTTP_GET_VARS['error'])) : LINKPOINTMS1_ERROR_MESSAGE));



     return $error;

   }



   function check() {

     if (!isset($this->_check)) {

       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_LINKPOINTMS1_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 Module', 'MODULE_PAYMENT_LINKPOINTMS1_STATUS', 'True', 'Do you want to accept Linkpoint payments?', '6', '1', '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 ('Linkpoint Login', 'MODULE_PAYMENT_LINKPOINTMS1_LOGIN', '000000', 'The account number used for the Linkpoint service', '6', '2', 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_LINKPOINTMS1_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, date_added) values ('LinkPoint Mode', 'MODULE_PAYMENT_LINKPOINTMS1_MODE', 'GOOD', 'GOOD=test, LIVE=charge the card', '6', '0', 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 Email', 'MODULE_PAYMENT_LINKPOINTMS1_EMAIL', '[email protected]', 'Email where to send the middle 8 number of the credit card. (NONE for not to send)', '6', '0', 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_LINKPOINTMS1_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_LINKPOINTMS1_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_LINKPOINTMS1_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_LINKPOINTMS1_STATUS', 'MODULE_PAYMENT_LINKPOINTMS1_LOGIN', 'MODULE_PAYMENT_LINKPOINTMS1_SERVER', 'MODULE_PAYMENT_LINKPOINTMS1_EMAIL', 'MODULE_PAYMENT_LINKPOINTMS1_ZONE', 'MODULE_PAYMENT_LINKPOINTMS1_ORDER_STATUS_ID', 'MODULE_PAYMENT_LINKPOINTMS1_MODE', 'MODULE_PAYMENT_LINKPOINTMS1_SORT_ORDER');

   }

 }

?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...