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 12-13-2007 18:25:03

hoonandy
Member
Registered: 06-13-2007
Posts: 51

HSBC Shipping address

Hi guys, at the moment the HSBC checkout module in CCP6 does not pass over the shipping address as filled out in the CCP shopping cart, it passes the billing address from the checkout into both the billing and shipping addresses in HSBC. What we would like to do is pass over the correct shipping address in HSBC so that that can be security checked also.

The original code in the HSBC checkout module is as follows:-

<?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 HSBC should be in the
// | following format:
// |
// | HSBC Store ID
// +--

// +--
// | 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.
// +--

$app      = $this->globals('khxc.app');
$eol      = $this->globals('khxc.eol');
$order    = $this->globals('ecom.order_summary');
$tmp=array();
$private_path       = $this->globals('khxc.path_private');

if ($this->debug) {$this->debugger("hsbcform: Private Path '{$private_path}'");}
require_once($private_path . '/apps/' . $app . '/GBU_OLP/ext/hsbc_crypto.php');

// +--
// | 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('khxc.url_ssl') . '/relay/' . $app . '.php';

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

$olpform = array('url'    => 'https://www.cpi.hsbc.com/servlet',
                 'button' => 'Continue',
                 'fields' => array());



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

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

$olpform['fields']['HIDDEN'][] = array('name'  => 'CpiDirectResultUrl',
                                       'value' => $url_relay);
$tmp[1] = $url_relay;

$olpform['fields']['HIDDEN'][] = array('name'  => 'CpiReturnUrl',
                                       'value' => $url_relay);
$tmp[2] = $url_relay;

$tmp[3] = 'P';
$olpform['fields']['HIDDEN'][] = array('name'  => 'Mode',
                                       'value' => $tmp[3]);

$tmp[4] = $order['order']['id'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'OrderId',
                                       'value' => $tmp[4]);

$amount = $order['order']['ordertotal'] * 100;
$tmp[5] = $amount;
$olpform['fields']['HIDDEN'][] = array('name'  => 'PurchaseAmount',
                                       'value' => $amount);

$tmp[6] = 'Capture';
$olpform['fields']['HIDDEN'][] = array('name'  => 'TransactionType',
                                       'value' => $tmp[6]);

$tmp[7] = $order['order']['epochorder']."000";
$olpform['fields']['HIDDEN'][] = array('name'  => 'TimeStamp',
                                       'value' => $tmp[7]);

$tmp[8] = $order['order']['fname'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingFirstName',
                                       'value' => $order['order']['fname'] );

$tmp[9] = $order['order']['lname'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingLastName',
                                       'value' => $order['order']['lname']);

$tmp[10] = $order['order']['addone'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingAddress1',
                                       'value' => $order['order']['addone']);

$tmp[11] = $order['order']['addtwo'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingAddress2',
                                       'value' => $order['order']['addtwo']);

$tmp[12] = $order['order']['city'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingCity',
                                       'value' => $order['order']['city']);

$tmp[13] = $order['order']['stateprov'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingCounty',
                                       'value' => $order['order']['stateprov']);

// +--
// | Load the DB class.
// +--

if (!($this->KHXC_DB)) {

     $this->KHXC_DB =& $this->quick_object('KHXC_DB','khxc','KHXC_DB_1');

     if ($this->IsError($this->KHXC_DB)) {return $this->KHXC_DB;}

} // End of if statement.
// Need to find the HSBC Country code
$table = $app . '_country';

$column_string = $this->KHXC_DB->table_column_string($table);

if ($this->IsError($column_string)) {return $column_string;}

$sql   = "SELECT {$column_string} FROM {$table} WHERE id=";
$sql  .= $this->KHXC_DB->quote($order['order']['country']);

$result = $this->KHXC_DB->sql_do(array('sql'   => $sql,
                                       'table' => $table,
                                       'order' => array('id' => 'ASC')));

if ($this->IsError($result)) {return $result;}


// +--
// | Loop through and see if we get a hit on a response code field.
// +--
foreach ($result as $num => $row) {

     $tmp[14] = $row['hsbccode'];

}
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingCountry',
                                       'value' => $tmp[14]);

$tmp[15] = $order['order']['postalcode'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'BillingPostal',
                                       'value' => $order['order']['postalcode']);
$tmp[16] = $this->globals('khxc_user.id');
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShopperEmail',
                                       'value' => $this->globals('khxc_user.id'));
$tmp[17] = '826';
$olpform['fields']['HIDDEN'][] = array('name'  => 'PurchaseCurrency',
                                       'value' => $tmp[17]);
$tmp[18] = 'Online Order';
$olpform['fields']['HIDDEN'][] = array('name'  => 'OrderDesc',
                                       'value' => $tmp[18]);

$tmp[19] = $order['order']['addone'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingAddress1',
                                       'value' => $order['order']['addone']);

$tmp[20] = $order['order']['addtwo'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingAddress2',
                                       'value' => $order['order']['addtwo']);

$tmp[21] = $order['order']['city'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCity',
                                       'value' => $order['order']['city']);
$tmp[22] = '826';
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCountry',
                                       'value' => $tmp[22]);


$tmp[23] = $order['order']['stateprov'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCounty',
                                       'value' => $order['order']['stateprov']);
$tmp[24] = $order['order']['fname'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingFirstName',
                                       'value' => $order['order']['fname'] );

$tmp[25] = $order['order']['lname'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingLastName',
                                       'value' => $order['order']['lname']);
$tmp[26] = $order['order']['postalcode'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingPostal',
                                       'value' => $order['order']['postalcode']);
                                      



if ($this->debug) {$this->debugger("HSBC: Order Hash Array: " . print_r($tmp,1));}

$orderhash = generateHash($tmp, $order['gateway']['transkey']);
unset($tmp);
if ($this->debug) {$this->debugger("HSBC: Order Hash: '{$orderhash}'");}

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

// +--
// | 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);

?>






I notice that the shipping address information that we need is in the $order = $this->globals('ecom.order_summary');    array, so i am wondering why we cant substitute in $order['items']['0']['addone']  and $order['items']['0']['addtwo']  etc, assuming that all items are shipped to the same address ofcourse, which is how we have it set up. So we would substitute the following into the code at the shiping addy bit near the bottom....

$tmp[19] = $order['items']['0']['addone'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingAddress1',
                                       'value' => $order['items']['0']['addone']);

$tmp[20] = $order['items']['0']['addtwo'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingAddress2',
                                       'value' => $order['items']['0']['addtwo']);

$tmp[21] = $order['items']['0']['city'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCity',
                                       'value' => $order['items']['0']['city']);
$tmp[22] = '826';
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCountry',
                                       'value' => $tmp[22]);


$tmp[23] = $order['items']['0']['stateprov'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCounty',
                                       'value' => $order['items']['0']['stateprov']);
$tmp[24] = $order['items']['0']['fname'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingFirstName',
                                       'value' => $order['items']['0']['fname']);

$tmp[25] = $order['items']['0']['lname'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingLastName',
                                       'value' => $order['items']['0']['lname']);
$tmp[26] = $order['items']['0']['postalcode'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingPostal',
                                       'value' => $order['items']['0']['postalcode']);
                                      




When testing this however, the HSBC system throws it straight back to CCP6 with an error. Any ideas Howard or anyone, because when i echo out all the array values that ive substituted the i get the data back that i want... when it goes into the hsbc module to get sent to hsbc thouugh it doesnt work, cant really see where its going wrong? Thanks in advance, Andy

Offline

 

#2 12-14-2007 11:33:19

GreenbarnWeb
Banned
Registered: 09-23-2003
Posts: 2743
Website

Re: HSBC Shipping address

Hi

It looks like you are doing the right thing for the shipping address, you would need to contact HSBC to find out why they are rejecting the post to their website

Offline

 

#3 02-11-2008 09:58:55

innerwolf
Member
From: Leicester UK
Registered: 03-21-2007
Posts: 118
Website

Re: HSBC Shipping address

Andy

Have you made any headway with this? It is a problem I have been looking in to for some time but can't change the delviery address. Any changes I do make seems to kick you straight out of HSBC.

Cheers
Ady


wwwbritishdog.net - Dog Training Equipment and all that stuff
wwwinnerwolf.co.uk - For Dog and Owners, that Love the Great Outdoors
wwwpickledshrimp.co.uk - Kitewing, If there's Wind, Wing it!

Offline

 

#4 02-11-2008 12:47:42

hoonandy
Member
Registered: 06-13-2007
Posts: 51

Re: HSBC Shipping address

Hi Ady, yes i did manage to get this working... HSBC were useless in bug checking it though. It is basically how I described above, however i noticed that the hash code was getting jumbled up on each save, so when you duplicate the hsbc module and make the changes, re-enter your hash code. You should find it works then. If you dont, drop me a line and i'll take a gander! 

All the best, Andy

Offline

 

#5 02-18-2008 05:05:05

innerwolf
Member
From: Leicester UK
Registered: 03-21-2007
Posts: 118
Website

Re: HSBC Shipping address

Thanks Andy

I dropped your version of the code in and it seems to be working straight away. Luckily no problems with the hash code because I wasn't sure what you meant by it. But I'll keep an eye on it.

Thanks for your help in solving this problem.
Cheers, Ady


wwwbritishdog.net - Dog Training Equipment and all that stuff
wwwinnerwolf.co.uk - For Dog and Owners, that Love the Great Outdoors
wwwpickledshrimp.co.uk - Kitewing, If there's Wind, Wing it!

Offline

 

#6 12-17-2008 10:52:51

bbac
Member
From: Bristol, UK
Registered: 08-25-2008
Posts: 141

Re: HSBC Shipping address

hoonandy wrote:

$tmp[22] = '826';
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCountry',
                                       'value' => $tmp[22]);

This part of the HSBC payment code is badly written. It has a hard-coded value for "ShippingCountry" such that anyone ordering from outside the UK will fail to checkout because the HSBC gateway will see this as a fraudulent transaction (shipping and billing country do not match and addresses are nonsensical eg "Albuquerque, New Mexico 87106, United Kingdom").

The code to generate the "BillingCountry" ($tmp[14]) should be duplicated to find the Shipping Country value. As a quick fix you could say

Code:

$tmp[22] = $tmp[14];

which would be a lot better than the current situation (we restrict billing and shipping to the same address)

Last edited by bbac (12-17-2008 10:56:13)

Offline

 

#7 03-24-2009 04:39:17

jomtm
Member
Registered: 04-03-2008
Posts: 29

Re: HSBC Shipping address

Hi bbac,

I have exactly the same problem with orders outside of the UK. The shipping country defaults to UK within the HSBC gateway and the payments are automatically rejected.

I've tried adding the quick fix you mentioned but it returns an error in CCP.

Can anyone provide the full working code??

It's urgent so would be much appreciated.

Offline

 

#8 03-24-2009 05:03:22

bbac
Member
From: Bristol, UK
Registered: 08-25-2008
Posts: 141

Re: HSBC Shipping address

This section of my form display code for the HSBC gateway looks like this:

Code:

$tmp[21] = $order['order']['city'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCity',
                                       'value' => $order['order']['city']);

//$tmp[22] = '826';
$tmp[22] = $tmp[14];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCountry',
                                       'value' => $tmp[22]);

$tmp[23] = $order['order']['stateprov'];
$olpform['fields']['HIDDEN'][] = array('name'  => 'ShippingCounty',
                                       'value' =>


Hope this helps

Offline

 

#9 03-24-2009 09:42:26

jomtm
Member
Registered: 04-03-2008
Posts: 29

Re: HSBC Shipping address

Thanks!

Offline

 

#10 03-25-2009 03:39:53

scottc
Member
Registered: 08-06-2007
Posts: 93
Website

Re: HSBC Shipping address

I have the same problem with HSBC.

Andy, is there any chance you can post all the correct code and instructions that deals with this problem?

Thanks in advance.

Scott

Offline

 

Board footer