Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 07-07-2015 07:07:02

kev
Member
Registered: 03-16-2009
Posts: 399

patch for SagePay version 3.0 did not work - any ideas?

I used the code that is being referred to as the patch for Sagepay version 3.0 and got this error message from Europacart following transaction processing by SagePay.

"Checkout

The following error occurred while attempting to process your transaction:

A complete common gateway interface request was not received by the online processor. The request was missing all required parameters."



Not sure why this message is displaying as the transaction went through then I voided the payment as it is a test transaction.

The code used is below (https://forum.kryptronic.com/viewtopic.php?id=32425):

<?php

// +--
// | Get a few global variables.
// +--

$eol      = $this->globals('core.eol');
$order    = $this->globals('ecom.order_summary');

// +--
// | Create the SHIPPING address array.
// +--

$ship_addy = array('lname'      => $order['order']['lname'],
                   'fname'      => $order['order']['fname'],
                   'addone'     => $order['order']['addone'],
                   'addtwo'     => $order['order']['addtwo'],
                   'city'       => $order['order']['city'],
                   'stateprov'  => $order['order']['stateprov'],
             'postalcode' =>$order['order']['postalcode'],
                   'country'    => $order['order']['country']);

foreach ($order['items'] as $num => $item) {

     if ($item['shipstatus'] != 'N') {

          $ship_addy = array('lname'      => $item['lname'],
                             'fname'      => $item['fname'],
                             'addone'     => $item['addone'],
                             'addtwo'     => $item['addtwo'],
                             'city'       => $item['city'],
                             'stateprov'  => $item['stateprov'],
                             'postalcode' => $item['postalcode'],
                             'country'    => $item['country']);

          break 1;

     } // End of if statement.

} // End of foreach statement.


// +--
// | Load delivery country abbreviation
// +--

$CORE_App =& $this->quick_object('CORE_App','core');

$stateprovabbs = $CORE_App->get_stateprov_abbs();
$countryabbs   = $CORE_App ->get_country_abbs();

if (!(empty($stateprovabbs[$ship_addy['stateprov']])))      {$ship_addy['stateprov']      = $stateprovabbs[$ship_addy['stateprov']];}
if (!(empty($stateprovabbs[$order['order']['stateprov']]))) {$order['order']['stateprov'] = $stateprovabbs[$order['order']['stateprov']];}

if (!(empty($countryabbs[$ship_addy['country']])))      {$ship_addy['country']      = $countryabbs[$ship_addy['country']];}
if (!(empty($countryabbs[$order['order']['country']]))) {$order['order']['country'] = $countryabbs[$order['order']['country']];}

// +--
// | Printable form instructions.
// +--

$instructions = "After verifying your order information and clicking the 'Continue' button, you will be directed to our online processing partner's secure site to enter your payment information. Once your payment information is entered and verified, you will be directed back to this web site for your order confirmation.";

// +--
// | Create our relay URL.
// +--

$url_relay  = $this->globals('core.url_ssl') . '/utilities/ecomrelay.php';
$url_bad    = $url_relay . '?SAGEPAYtrans=' . $order['order']['id'] . '&SAGEPAYresp=FAILED';
$url_ok     = $url_relay . '?SAGEPAYtrans=' . $order['order']['id'] . '&SAGEPAYresp=OK';

// +--
// | Set up the olpform array.
// +--

$olpform = array('url'    => 'https://live.sagepay.com/gateway/service/vspform-register.vsp',
                 'button' => 'Continue',
                 'fields' => array());

// +--
// | Create the SagePay Form Hash Field.
// +--

$stuff  = "VendorTxCode=" . $order['order']['id'] . "&";
$stuff .= "Amount=" . $order['order']['ordertotal'] . "&";
$stuff .= "Currency=" . $this->globals('core_settings.core.basecurrency') . "&";
$stuff .= "Description=" . "Online Order" . "&";
$stuff .= "SuccessURL=" . $url_ok . "&";
$stuff .= "FailureURL=" . $url_bad . "&";
$stuff .= "CustomerName=" . $order['order']['fname'] . ' ' . $order['order']['lname'] . "&";
$stuff .= "CustomerEmail=" . $order['order']['email'] . "&";
$stuff .= "VendorEmail=" . $this->globals('core_settings.core.siteowneremail') . "&";

$stuff .= "BillingSurname=" . $order['order']['lname'] . "&";
$stuff .= "BillingFirstnames=" . $order['order']['fname'] . "&";
$stuff .= "BillingAddress1=" . $order['order']['addone'] . "&";
$stuff .= "BillingAddress2=" . $order['order']['addtwo'] . "&";
$stuff .= "BillingCity=" . $order['order']['city'] . "&";
$stuff .= "BillingState=" . $order['order']['stateprov'] . "&";
$stuff .= "BillingPostCode=" . substr(preg_replace('/[^A-Za-z0-9]/','',$order['order']['postalcode']),0,10) . "&";
$stuff .= "BillingCountry=" . $order['order']['country'] . "&";

if ($order['order']['phone']) {  $stuff .= "BillingPhone=" . $order['order']['phone'] . "&";}

$stuff .= "DeliverySurname=" . $ship_addy['lname'] . "&";
$stuff .= "DeliveryFirstnames=" . $ship_addy['fname'] . "&";
$stuff .= "DeliveryAddress1=" . $ship_addy['addone'] . "&";
$stuff .= "DeliveryAddress2=" . $ship_addy['addtwo'] . "&";
$stuff .= "DeliveryCity=" . $ship_addy['city'] . "&";
$stuff .= "DeliveryState=" . $ship_addy['stateprov'] . "&";
$stuff .= "DeliveryPostCode=" . substr(preg_replace('/[^A-Za-z0-9]/','',$ship_addy['postalcode']),0,10) . "&";
$stuff .= "DeliveryCountry=" . $ship_addy['country'] . "&";
$stuff .= "AllowGiftAid=0&ApplyAVSCV2=0&Apply3DSecure=0";

$blockSize = 16;
$padd      = "";
$length    = $blockSize - (strlen($stuff) % $blockSize);

for ($i = 1; $i <= $length; $i++) {$padd .= chr($length);} $stuff .= $padd;

$crypt  = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $order['gateway']['transkey'], $stuff, MCRYPT_MODE_CBC, $order['gateway']['transkey']);
$crypt = "@" . strtoupper(bin2hex($crypt));

// +--
// | Create the HIDDEN fields for the form.
// +--

$olpform['fields']['HIDDEN'][] = array('name'  => 'VPSProtocol',


                                       'value' => '3.00');

$olpform['fields']['HIDDEN'][] = array('name'  => 'TxType',
                                       'value' => 'DEFERRED');


$olpform['fields']['HIDDEN'][] = array('name'  => 'Vendor',
                                       'value' => $order['gateway']['userid']);


$olpform['fields']['HIDDEN'][] = array('name'  => 'Crypt',

                                       'value' => $crypt);


// +--
// | Create the DISPLAY fields for the form.
// +--

$olpform['fields']['DISPLAY'][] = array('type'   => 'PAYFORMCONTINUE',
                                        'params' => array('name'     => 'ecom_continue',
                                                          'required' => 1,
                                                          'display'  => 'Payment Information',
                                                          'desc'     => $instructions,
                                                          'option'   => 'Enter Payment Information'));

// +--
// | Globalize the $olpform array and return.
// +--

$this->globals('ecom.olpform',$olpform);

?>

Offline

 

#2 07-08-2015 05:34:44

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: patch for SagePay version 3.0 did not work - any ideas?

That message indicates that Sage didn't reply with both the order number and response code when returning to your site.  Check to be sure those fields are completed properly in your sage setup.


Nick Hendler

Offline

 

#3 07-10-2015 05:40:48

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: patch for SagePay version 3.0 did not work - any ideas?

this is the code I have been using for a number of weeks and have had no issues whatsoever.
It is for Sagepay Payment Form

Code:

<?php

// +--
// | This processor integration references an external
// | URL for processing.  All external processing gateways
// | work in the same manner.  An order information array
// | is made available globally under the the global name
// | 'ecom.order_summary'.
// |
// | This must set a global variable named 'ecom.olpform'
// | which contains the form information to be posted to
// | the external gateway URL.
// |
// | Anything printed within this code will be printed
// | above the form instructions on the payment information
// | page.
// +--

// +--
// | The username entered for Protx form should be in the
// | vendor name:
// |
// +--

// +--
// | THERE IS NO NEED TO EDIT THE CODE BELOW THIS POINT TO
// | ACTIVATE THIS INTEGRATION.  ONLY EDIT THIS CODE TO MODIFY
// | HOW THIS INTEGRATION WORKS.  BE SURE YOU KNOW WHAT YOU'RE
// | DOING!
// +--

// +--
// | Get a few global variables.
// +--

$eol      = $this->globals('core.eol');
$order    = $this->globals('ecom.order_summary');


// +--
// | Printable form instructions.
// +--

$instructions = "After verifying your order information and clicking the 'Continue' button, you will be directed to our online processing partner's secure site to enter your payment information. Once your payment information is entered and verified, you will be directed back to this web site for your order confirmation.";

// +--
// | Create our relay URL.
// +--

$url_relay  = $this->globals('core.url_ssl') . '/utilities/ecomrelay.php';
$url_bad    = $url_relay . '?PROTXtrans=' . $order['order']['id'] . '&PROTXresp=FAILED';
$url_ok     = $url_relay . '?PROTXtrans=' . $order['order']['id'] . '&PROTXresp=OK';

// +--
// | Set up the olpform array.
// +--

$olpform = array('url'    => 'https://live.sagepay.com/gateway/service/vspform-register.vsp',
                 'button' => 'CONTINUE TO SECURE PAYMENT',
                 'fields' => array());

// +--
// | Create the Protx Form Hash Field.
// +--

$stuff  = "VendorTxCode=" . $order['order']['id'] . "&";
$stuff .= "Amount=" . $order['order']['ordertotal'] . "&";
$stuff .= "Currency=" . $this->globals('core_settings.core.basecurrency') . "&";
$stuff .= "Description=" . "Online Order" . "&";
$stuff .= "SuccessURL=" . $url_ok . "&";
$stuff .= "FailureURL=" . $url_bad . "&";
$stuff .= "CustomerEmail=" . $order['order']['email'] . "&";
$stuff .= "VendorEmail=" . $this->globals('core_settings.core.siteowneremail') . "&";
$stuff .= "BillingSurname=". $order['order']['lname'] . "&";
$stuff .= "BillingFirstnames=" . $order['order']['fname'] . "&";
$stuff .= "BillingAddress1=" . $order['order']['addone'] . "&";
$stuff .= "BillingAddress2=" . $order['order']['addtwo'] . "&";
$stuff .= "BillingCity=". $order['order']['city'] ."&";
//$stuff .= "BillingState=". $order['order']['stateprov'] . "&";
$stuff .= "BillingCountry=". $order['order']['countryabb'] . "&";
$stuff .= "BillingPostCode=" . $order['order']['postalcode'] . "&";
$stuff .= "DeliverySurname=". $order['items'][0]['lname'] . "&";
$stuff .= "DeliveryFirstnames=". $order['items'][0]['fname'] . "&";
$stuff .= "DeliveryAddress1=" . $order['items'][0]['addone'] . "&";
$stuff .= "DeliveryAddress2=" . $order['items'][0]['addtwo'] . "&";
$stuff .= "DeliveryCity=". $order['items'][0]['city'] ."&";
$stuff .= "DeliveryCountry=". $order['order']['countryabb'] . "&";
$stuff .= "DeliveryPostCode=" . $order['items'][0]['postalcode'] . "&";

//if ($order['order']['phone']) {  $stuff .= "ContactNumber=" . $order['order']['phone'] . "&";}

//if ($order['order']['fax']) {$stuff .= "ContactFax=" . $order['order']['fax'] . "&";}

$stuff .= "AllowGiftAid=0&ApplyAVSCV2=0&Apply3DSecure=0";

//$crypt = base64_encode(SimpleXor($stuff,$order['gateway']['transkey']));

$blockSize = 16;
$padd      = "";
$length    = $blockSize - (strlen($stuff) % $blockSize);

for ($i = 1; $i <= $length; $i++) {$padd .= chr($length);} $stuff .= $padd;

$crypt  = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $order['gateway']['transkey'], $stuff, MCRYPT_MODE_CBC, $order['gateway']['transkey']);
$crypt = "@" . strtoupper(bin2hex($crypt));

// +--
// | Create the HIDDEN fields for the form.
// +--

$olpform['fields']['HIDDEN'][] = array('name'  => 'Vendor',
                                       'value' => $order['gateway']['userid']);

$olpform['fields']['HIDDEN'][] = array('name'  => 'VPSProtocol',
                                       'value' => '3.0');

$olpform['fields']['HIDDEN'][] = array('name'  => 'TxType',
                                       'value' => 'PAYMENT');

$olpform['fields']['HIDDEN'][] = array('name'  => 'Crypt',
                                       'value' => $crypt);


// +--
// | Create the DISPLAY fields for the form.
// +--

$olpform['fields']['HIDDEN'][] = array('type'   => 'PAYFORMCONTINUE',
                                        'params' => array('name'     => 'ecom_continue',
                                                          'required' => 1,
                                                          'display'  => 'Payment Information',
                                                          'desc'     => $instructions,
                                                          'option'   => 'Enter Payment Information'));

// +--
// | Globalize the $olpform array and return.
// +--

$this->globals('ecom.olpform',$olpform);

function simpleXor($InString, $Key) {

  $KeyList = array();
  $output = "";

  for($i = 0; $i < strlen($Key); $i++){
    $KeyList[$i] = ord(substr($Key, $i, 1));
  }

  for($i = 0; $i < strlen($InString); $i++) {
    $output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)]));
  }

  return $output;
}

?>

Note that this has been adapted for my needs and may not suit your requirements.

Use at your own risk or wait for Nicks proper code.


Rob

Offline

 

#4 07-24-2015 08:57:11

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: patch for SagePay version 3.0 did not work - any ideas?

Kryptronic has released updated code for SagePay V3.  Please review the link below for information on how to apply the updated code to your gateway integration:

https://central.kryptronic.com/public/n … 2015A.html


Nick Hendler

Offline

 

#5 07-28-2015 03:47:14

Hotplugs
Member
Registered: 07-01-2014
Posts: 23

Re: patch for SagePay version 3.0 did not work - any ideas?

Is this valid for Europacart 8 also?  It only mentions 7 and it's getting close to crunch time now.

Offline

 

#6 07-28-2015 07:26:06

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: patch for SagePay version 3.0 did not work - any ideas?

Yes, this update applies to all V7 and V8 software.


Nick Hendler

Offline

 

#7 07-30-2015 05:18:31

mixer25
Member
From: Ireland
Registered: 04-02-2006
Posts: 601

Re: patch for SagePay version 3.0 did not work - any ideas?

Just did the new Patch on Eurocart 8and I am getting this error when I have inserted the code and try to submit:

Method Not Implemented

POST to /myshop/admin.php not supported.

Any ideas?

Offline

 

#8 07-30-2015 06:57:41

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: patch for SagePay version 3.0 did not work - any ideas?

Report this error to your host.  They may be blocking large post requests.  As a workaround, you might be able to use a utility like PHPMyAdmin to update the form content in the ecom_gateway table directly.


Nick Hendler

Offline

 

#9 07-30-2015 11:12:08

mixer25
Member
From: Ireland
Registered: 04-02-2006
Posts: 601

Re: patch for SagePay version 3.0 did not work - any ideas?

Thanks Nick, Correct!

I was hitting a Mod Security rule. I've disabled that now and it worked!

Offline

 

Board footer