PayPal Pro Config & KB

Ok. I have a solution from the help desk.



First off. I want to make clear that even though I messed around with the certificate method I was never going to get anywhere because I had already setup API credentials back in 2007 using the signature method so therefore any cert I downloaded was incomplete with no key information and just overall an invalid pem file. In order to use the certificate method I believe I would have to delete my API credentials and start over selecting the certificate method. I could not do this because I have other stores running on CRELoaded that can only use the signature method.



So, the signature method now works perfectly. Here’s how this went down.



When trying my signature method using my old tried and proven API credentials from PayPal I receive this error in the logs (I’m not pasting all of the post data from the logs but only the final error):


[quote]Response: HTTPS: libcurl error(35): error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure[/quote]The response from the help desk was this:


[quote]It is a well-known problem in standard CS-Cart. In order to fix it you should replace the “paypal_pro.php” file located in the “payments” directory of your CS-Cart instalaltion with the file attached to this message. Please check it and let us know the result.

Thank you.



Sincerely yours

Pavel Zyukin,

Technical support engineer

[/quote]The file he had attached (which I will post a difference in just a minute) worked perfectly. I am appreciative of their quick help but had to take a bit of exception with the ‘well known’ remark as a couple of the ‘veteran’ users above didn’t have an answer … well, just read my response:


[quote] Ok… the new file you gave me works perfectly. Thank you for your help.

Now… not to be combative but I spent HOURS searching the forums, KB and Google and never found an answer to this so I might have to take exception to the ‘well known’ remark. I posted to the forum at the link in this ticket with a few veteran forum users responding but no solution. You can bet I’ll post the solution now.

Also, I had just downloaded this 2.0.12 on Feb 12 so it’s not like it’s an old installation.

Where would I find reference to this problem so maybe I can help myself better in the future?

Again, I appreciate your help.



[/quote]So, anyway, it’s fixed. But my problem is as I stated above. My install was only a few weeks old and I couldn’t find the solution to this on my own and it sure wasn’t from a lack of trying. Thus endeth the whining…



So what was changed?



Lines 67-82 of the new /payments/paypal_pro.php file are:



```php $sandbox = ($processor_data[‘params’][‘mode’] == ‘test’) ? ‘.sandbox’ : ‘’;



if (!empty($processor_data[‘params’][‘authentication_method’]) && $processor_data[‘params’][‘authentication_method’] == ‘signature’) {

$paypal_signature = ‘’ . $processor_data[‘params’][‘signature’] . ‘’;

$paypal_sslcertpath = ‘’;

$paypal_url = “https://api-3t:443$sandbox.paypal.com/2.0/”;

} else {

$paypal_signature = ‘’;

$paypal_sslcertpath = DIR_ROOT . ‘/payments/certificates/’ . $processor_data[‘params’][‘certificate_filename’];







$paypal_url = “https://api:443$sandbox.paypal.com/2.0/”;





} ```The old file reads like this:



```php



if (!empty($processor_data[‘params’][‘authentication_method’]) && $processor_data[‘params’][‘authentication_method’] == ‘signature’) {

$paypal_signature = ‘’ . $processor_data[‘params’][‘signature’] . ‘’;

$paypal_sslcertpath = ‘’;



} else {

$paypal_signature = ‘’;

$paypal_sslcertpath = DIR_ROOT . ‘/payments/certificates/’ . $processor_data[‘params’][‘certificate_filename’];

}



if ($processor_data[‘params’][‘mode’] == ‘test’) {

$paypal_url = “https://api.sandbox.paypal.com:443/2.0/”;

} else {

$paypal_url = “https://api.paypal.com:443/2.0/”;

} ```



Actually less coding. This dovetails nicely with the little information I could find on the PayPal dev forums but was quite frankly over my head to correct on my own.



Any way. Hope this might help someone. If I could attach a file here I would. Maybe I’ll copy paste the file in full in the next post.

Here’s the full paypal_pro.php file that support provided me to fix this problem. Notice that it has no date within the file in the //$Id$ line like the old file which said:


[QUOTE]// $Id: paypal_pro.php 8621 2010-01-15 12:05:18Z 2tl $[/QUOTE]



It may well be in current downloads so do a ‘difference’ on your file to verify this:



```php
/***************************************************************************

  •                                                                      *
  • Copyright (c) 2009 Simbirsk Technologies Ltd. All rights reserved. *
  •                                                                      *
  • This is commercial software, only users who have purchased a valid *
  • license and accept to the terms of the License Agreement can install *
  • and use this program. *
  •                                                                      *

****************************************************************************

  • PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE *
  • “copyright.txt” FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. *

    ****************************************************************************/





    //

    // $Id$

    //



    if ( !defined(‘AREA’) ) { die(‘Access denied’); }



    include_once(DIR_PAYMENT_FILES . ‘cmpi.php’);



    $use_cardinal = (!empty($processor_data[‘params’][‘use_cardinal’]) && $processor_data[‘params’][‘use_cardinal’] == ‘Y’) ? true : false;

    if ($use_cardinal) {

    if (!defined(‘CMPI_PROCESSED’)) {

    fn_cmpi_lookup($processor_data, $order_info);

    }

    } else {

    define(‘DO_DIRECT_PAYMENT’, true);

    }



    if (defined(‘DO_DIRECT_PAYMENT’)) {



    $processor_error[‘avs’] = array(

    “A” => “Address Address only (no ZIP)”,

    “B” => “International ‘A’. Address only (no ZIP)”,

    “C” => “International ‘N’”,

    “D” => “International ‘X’. Address and Postal Code”,

    “E” => “Not allowed for MOTO (Internet/Phone) transactions”,

    “F” => “UK-specific X Address and Postal Code”,

    “G” => “Global Unavailable”,

    “I” => “International Unavailable”,

    “N” => “None”,

    “P” => “Postal Code only (no Address)”,

    “R” => “Retry”,

    “S” => “Service not Supported”,

    “U” => “Unavailable”,

    “W” => “Nine-digit ZIP code (no Address)”,

    “X” => “Exact match. Address and five-digit ZIP code”,

    “Y” => “Address and five-digit ZIP”,

    “Z” => “Five-digit ZIP code (no Address)”

    );



    $processor_error[‘cvv’] = array(

    “M” => “Match”,

    “N” => “No match”,

    “P” => “Not Processed”,

    “S” => “Service not Supported”,

    “U” => “Unavailable”,

    “X” => “No response”

    );



    $paypal_username = $processor_data[‘params’][‘username’];

    $paypal_password = $processor_data[‘params’][‘password’];



    $sandbox = ($processor_data[‘params’][‘mode’] == ‘test’) ? ‘.sandbox’ : ‘’;



    if (!empty($processor_data[‘params’][‘authentication_method’]) && $processor_data[‘params’][‘authentication_method’] == ‘signature’) {

    $paypal_signature = ‘’ . $processor_data[‘params’][‘signature’] . ‘’;

    $paypal_sslcertpath = ‘’;

    $paypal_url = “https://api-3t:443$sandbox.paypal.com/2.0/”;

    } else {

    $paypal_signature = ‘’;

    $paypal_sslcertpath = DIR_ROOT . ‘/payments/certificates/’ . $processor_data[‘params’][‘certificate_filename’];

    $paypal_url = “https://api:443$sandbox.paypal.com/2.0/”;

    }



    $paypal_notify_url = ‘’;

    $paypal_payment_action = ‘Sale’; // FIXME: Should be configurable

    $paypal_currency = $processor_data[‘params’][‘currency’];

    //Order Total

    $paypal_total = fn_format_price($order_info[‘total’]);

    $paypal_order_id = $processor_data[‘params’][‘order_prefix’].(($order_info[‘repaid’]) ? ($order_id .‘_’. $order_info[‘repaid’]) : $order_id);



    //Credit Card

    $paypal_card_types = array (

    ‘vis’ => ‘Visa’,

    ‘amx’ => ‘Amex’,

    ‘dsc’ => ‘Discover’,

    ‘mcd’ => ‘MasterCard’,

    ‘sol’ => ‘Solo’,

    ‘swi’ => ‘Switch’,

    );



    $paypal_card = $paypal_card_types[$order_info[‘payment_info’][‘card’]];

    $paypal_card_number = $order_info[‘payment_info’][‘card_number’];

    $paypal_card_exp_month = $order_info[‘payment_info’][‘expiry_month’];

    $paypal_card_exp_year = ‘20’ . $order_info[‘payment_info’][‘expiry_year’];

    $paypal_card_cvv2 = !empty($order_info[‘payment_info’][‘cvv2’]) ? $order_info[‘payment_info’][‘cvv2’] : ‘’;



    $paypal_cc_start = ‘’;

    if (!empty($order_info[‘payment_info’][‘start_month’])) {

    $paypal_card_start_month = $order_info[‘payment_info’][‘start_month’];

    $paypal_card_start_year = ‘20’ . $order_info[‘payment_info’][‘start_year’];



    $paypal_cc_start = <<
    $paypal_card_start_month

    $paypal_card_start_year

    EOT;

    }



    $paypal_cc_issue = ‘’;

    if (!empty($order_info[‘payment_info’][‘issue_number’])) {

    $paypal_card_issue_number = $order_info[‘payment_info’][‘issue_number’];

    $paypal_cc_issue = <<
    $paypal_card_issue_number

    EOT;

    }



    $paypal_3dsecure = ‘’;

    if ($use_cardinal) {

    $fields = array(‘eci_flag’, ‘pares’, ‘xid’, ‘cavv’, ‘enrolled’);

    foreach ($fields as $field) {

    $_SESSION[‘cmpi’][$field] = isset($_SESSION[‘cmpi’][$field]) ? $_SESSION[‘cmpi’][$field] : ‘’;

    }



    $paypal_3dsecure = <<


    {$_SESSION[‘cmpi’][‘pares’]}

    {$_SESSION[‘cmpi’][‘enrolled’]}

    {$_SESSION[‘cmpi’][‘cavv’]}

    {$_SESSION[‘cmpi’][‘eci_flag’]}

    {$_SESSION[‘cmpi’][‘xid’]}



    EOT;

    }



    $paypal_request = <<

http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“XML Schema”>

soap:Header





$paypal_username

$paypal_password

$paypal_signature







soap:Body





59.00



$paypal_payment_action



$paypal_total

ST_ShoppingCart_DP_US

$paypal_notify_url



{$order_info[‘s_firstname’]} {$order_info[‘s_lastname’]}

{$order_info[‘s_address’]}

{$order_info[‘s_address_2’]}

{$order_info[‘s_city’]}

{$order_info[‘s_state’]}

{$order_info[‘s_zipcode’]}

{$order_info[‘s_country’]}



$paypal_order_id





$paypal_card

$paypal_card_number

$paypal_card_exp_month

$paypal_card_exp_year

$paypal_cc_start

$paypal_cc_issue



verified

{$order_info[‘email’]}



{$order_info[‘b_firstname’]}

{$order_info[‘b_lastname’]}



{$order_info[‘b_country’]}



{$order_info[‘b_address’]}

{$order_info[‘b_address_2’]}

{$order_info[‘b_city’]}

{$order_info[‘b_state’]}

{$order_info[‘b_country’]}

{$order_info[‘b_zipcode’]}





$paypal_card_cvv2



{$_SERVER[‘REMOTE_ADDR’]}

$paypal_3dsecure











EOT;



$post = explode(“\n”, $paypal_request);

list ($headers,$response_data) = fn_https_request(‘POST’, $paypal_url, $post, ‘’, ‘’, ‘text/xml’, ‘’, $paypal_sslcertpath);



$paypal_response = array();

$paypal_response[‘reason_text’] = ‘’;



if (strpos($response_data, ‘
if (preg_match(‘!]>([^>]+)!‘, $response_data, $matches)) {

$paypal_response[‘reason_text’] = $matches[1];

}



$paypal_response[‘order_status’] = ‘F’; // FIXME. Shouldn’t be hardcoded

}



if (strpos($response_data, ‘
if (preg_match(’!]
>([^>]+)!’, $response_data, $matches)) {

$paypal_response[‘reason_text’] = $matches[1];

}



$paypal_response[‘order_status’] = ‘F’; // FIXME. Shouldn’t be hardcoded

}



if (preg_match(‘/([^>]+)/’, $response_data, $matches)) {

$paypal_response[‘transaction_id’] = $matches[1];

$paypal_response[‘order_status’] = ‘P’;

}

if (preg_match(‘!]+>([^>]+)!’, $response_data, $matches)) {

$paypal_response[‘avs_code’] = $matches[1];

if (empty($processor_error[‘avs’][trim($paypal_response[‘avs_code’])])) {

$paypal_response[‘order_status’] = ‘F’;

$paypal_response[‘reason_text’] .= ‘AVS Verification failed’; // FIXME!!!

}

}

if (preg_match(‘!]+>([^>]+)!’, $response_data, $matches)) {

$paypal_response[‘cvv_code’] = $matches[1];

if (empty($processor_error[‘cvv’][trim($paypal_response[‘cvv_code’])])) {

$paypal_response[‘order_status’] = ‘F’;

$paypal_response[‘reason_text’] .= ‘CVV Verification failed’; // FIXME!!!

}

}



if (empty($paypal_response[‘order_status’])) {

$paypal_response[‘order_status’] = ‘F’;

}



if (empty($paypal_response[‘reason_text’])) {

$paypal_response[‘reason_text’] = ‘’;

}



$pp_response = array();

$pp_response[‘order_status’] = $paypal_response[‘order_status’];

$pp_response[‘reason_text’] = $paypal_response[‘reason_text’];

$pp_response[‘transaction_id’] = (!empty($paypal_response[‘transaction_id’])) ? $paypal_response[‘transaction_id’] : ‘’;



$pp_response[‘descr_avs’] = (!empty($paypal_response[‘avs_code’])) ? $processor_error[‘avs’][$paypal_response[‘avs_code’]] : ‘’;

$pp_response[‘descr_cvv’] = (!empty($paypal_response[‘cvv_code’])) ? $processor_error[‘cvv’][$paypal_response[‘cvv_code’]] : ‘’;



} // if (defined(‘DO_DIRECT_PAYMENT’))



if (!empty($_SESSION[‘cmpi’][‘auth_error’])) {

$pp_response[‘order_status’] = ‘F’;

$pp_response[‘reason_text’] = (isset($pp_response[‘reason_text’]) ? $pp_response[‘reason_text’] . “\n” : ‘’) . ‘3DSecure authentication failed’;

}



if (isset($_SESSION[‘cmpi’][‘err_desc’]) && is_array($_SESSION[‘cmpi’][‘err_desc’])) {

$transaction_id = !empty($_SESSION[‘cmpi’][‘transaction_id’]) ? $_SESSION[‘cmpi’][‘transaction_id’] : ‘’;

foreach ($_SESSION[‘cmpi’][‘err_desc’] as $k => $desc) {

if ($desc) {

$pp_response[‘reason_text’] = (isset($pp_response[‘reason_text’]) ? $pp_response[‘reason_text’] . “\n” : ‘’) . '3DSecure error: ’ . $_SESSION[‘cmpi’][‘err_no’][$k] . ': ’ . $desc;

if ($transaction_id) {

$pp_response[‘reason_text’] .= ’ (Transaction ID: ’ . $transaction_id . ‘)’;

}

}

}

}



?> ```

Brad-



Hopefully, you are getting the paypal_pro.php that will be part of 2.0.13 - it sounds like they recently fixed the problem but did not circulate their solution.



Bob

[quote name=‘indy0077’]If you do use this method as in the screen shots then it works fine with CSC.[/QUOTE]



you say “this” method, as in one, but you have 2 screen shots, one showing using a certificate, and the other screen shot shows using a signature method. this confuses me.



its one or the other , no?

[quote name=‘norm111’]you say “this” method, as in one, but you have 2 screen shots, one showing using a certificate, and the other screen shot shows using a signature method. this confuses me.



its one or the other , no?[/quote]

It’s still the same, just second one shows up after you will click on the link below.

I got PayPal pro to work like a charm in cs-cart 2.0.14



My situation:

using certificate method, certificate obtained from PayPal and uploaded to site in payments/certificates/ folder. its called cert_key_pem.txt



im using the api username and the password given by PayPal api process.



orders are processed and payments from users credit cards go straight to PayPal. it appears like you are using a credit card merchant account. seamless.



now question is client is currently not using a SSL certificate being under impression that as it goes to PayPal it is encrypted prior to sending. is this true? is date safe for all intensive purposes?



also, i don’t like the fact that the cart saves the credit card info in the order section. although it comes in handy if you have to resend the order or something.



what is best way to prevent cards numbers being saved again?

If you do not want the credit card information saved, check "Remove CC info’ for each order status that should not save this information. For instance, if an order is in ‘Processed’ status (payment already made), there is no need to have the CC info.



Bob

[QUOTE]now question is client is currently not using a SSL certificate being under impression that as it goes to PayPal it is encrypted prior to sending. is this true? is date safe for all intensive purposes?[/QUOTE]



No… They need to invest in an SSL cert!



You claim you are using Paypal Payments Pro which is essentially a credit card payment gateway. Your customer is referring to traditional Paypal payments of which the customer is sent to Paypals site to complete the payment transaction, and then returned (hopefully) back to your site.

Payment processor response: Data type ‘’ mismatch in element ‘ExpMonth’



Any thoughts??

tblarson,



I am getting this exact response. Two failed orders because of this so far. Did you get a solution for this?



Data type ‘’ mismatch in element ‘ExpMonth’



This just started happening in the last 2 days.



Can anyone throw any light on this?

OK the problem was that I had been over-zealous in my pursuit of PCI compliance and had selected “Remove CC Info” for the “Open” order status. This meant that the credit card information supplied by the customer was being passed to the payment processor as “XXXX” thus causing the error.



Just thought I would post this for anyone experiencing the “mismatch in element 'ExpMonth” error.

This problem is recurring intermittently. I just lost a $100 order from a very frustrated customer. I have no idea how to fix this. This is the second customer in three days that has not been able to place an order because of this error.



Anyone any ideas?

OK I submitted a ticket to helpdesk and this was their response:


[QUOTE]It looks like a bug in the current CS-Cart version. Our engineers are working on it and we will contact you as soon as possible.[/QUOTE]



Hopefully this will be sooner rather than later…as in hours not days or weeks.

Helpdesk responded within 24 hours. That’s good.



This was their response:



Thank you for your time and patience.

In order to resolve the problem, you should replace the following part of code:


[QUOTE]$cart[‘payment_info’] = array_merge($cart[‘extra_payment_info’], $cart[‘payment_info’]);[/QUOTE]



with this one


[QUOTE]$cart[‘payment_info’] = array_merge($cart[‘payment_info’], $cart[‘extra_payment_info’]);[/QUOTE]



in the “checkout.tpl” file located in the “controllers/customer” directory of your CS-Cart installation. Please check it and let us know the result.



Hopefully that fixes it.

Someone have the fix for paypal_express.php ? because i have the same problems


[quote name=‘creativeuser’]Someone have the fix for paypal_express.php ? because i have the same problems[/quote]

Seems like an SSL issue [url]https://www.x.com/message/70347[/url]

[quote name=‘kingsleypress’]Helpdesk responded within 24 hours. That’s good.



This was their response:



Thank you for your time and patience.

In order to resolve the problem, you should replace the following part of code:







with this one







in the “checkout.tpl” file located in the “controllers/customer” directory of your CS-Cart installation. Please check it and let us know the result.



Hopefully that fixes it.[/QUOTE]







Sorry to drag up an old one but I am now having this issue. Any ideas anyone? Date Mismatch that is!