load_extension('mcrypt'); if ($this->IsError($mcrypt)) { $message = 'The mcrypt PHP extension is not loaded. The HSBC module requires the mcrypt PHP extension to be loaded in order to function. This script attempted to change this value at runtime, however the current server configuration did not permit the script to make this runtime change. Contact your server administrator and request that the mcrypt PHP extension be loaded at run time.'; print '

' . $this->xhtml_encode($message) . '

' . $eol . $eol; return false; } // End of if statement. // +-- // | Make sure that the mhash extension is loaded. // +-- $extension = 'hash'; $extension_load = $this->load_extension($extension); if ($this->IsError($extension_load)) { $extension = 'mhash'; $extension_load = $this->load_extension($extension); } // End of if statement. if ($this->IsError($extension_load)) { $message = 'The hash and mhash PHP extensions could not be loaded. This '; $message .= 'processing module requires either the hash or mhash PHP '; $message .= 'extensions to be loaded in order to function. This script '; $message .= 'attempted to load these extensions at runtime, however the current '; $message .= 'server configuration did not permit the script to make this '; $message .= 'runtime change. Contact your server administrator and request '; $message .= 'that either the hash or mhahs PHP extensions be loaded at run time.'; print '

' . $this->xhtml_encode($message) . '

' . $eol . $eol; return false; } // End of if statement. // +-- // | Get a few global variables. // +-- $eol = $this->globals('core.eol'); $order = $this->globals('ecom.order_summary'); $tmp = array(); $public_path = $this->globals('core.path_public'); @require_once($public_path . '/utilities/hsbccrypto.php'); $hsbcobject = new HSBC(); // +-- // | 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'; // +-- // | Set up the olpform array. // +-- $olpform = array('url' => 'https://www.cpi.hsbc.com/servlet', 'button' => 'Continue', 'fields' => array()); // +-- // | Load the DB class. // +-- $hsbccode = ''; $CORE_DB =& $this->quick_object('CORE_DB','core','CORE_DB_1'); if (!($this->IsError($CORE_DB))) { $table = 'core_country'; $column_string = $CORE_DB->table_column_string($table); if (!($this->IsError($column_string))) { $sql = "SELECT {$column_string} FROM {$table} WHERE id="; $sql .= $CORE_DB->quote($order['order']['country']); $result = $CORE_DB->sql_do(array('sql' => $sql, 'table' => $table, 'order' => array('id' => 'ASC'))); if ((!($this->IsError($result))) && (!(empty($result[0]['hsbccode'])))) { $hsbccode = $result[0]['hsbccode']; } // End of if statement. } // End of if statement. } // End of if statement. // +-- // | Create the HIDDEN fields for the form. // +-- $tmp[0] = $order['gateway']['userid']; $olpform['fields']['HIDDEN'][] = array('name' => 'StorefrontId', 'value' => $tmp[0]); $tmp[1] = $url_relay; $olpform['fields']['HIDDEN'][] = array('name' => 'CpiDirectResultUrl', 'value' => $tmp[1]); $tmp[2] = $url_relay; $olpform['fields']['HIDDEN'][] = array('name' => 'CpiReturnUrl', 'value' => $tmp[2]); $tmp[3] = 'T'; $olpform['fields']['HIDDEN'][] = array('name' => 'Mode', 'value' => $tmp[3]); $tmp[4] = $order['order']['id']; $olpform['fields']['HIDDEN'][] = array('name' => 'OrderId', 'value' => $tmp[4]); $tmp[5] = $order['order']['ordertotal'] * 100; $olpform['fields']['HIDDEN'][] = array('name' => 'PurchaseAmount', 'value' => $tmp[5]); $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] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['fname']); $olpform['fields']['HIDDEN'][] = array('name' => 'BillingFirstName', 'value' => $tmp[8]); $tmp[9] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['lname']); $olpform['fields']['HIDDEN'][] = array('name' => 'BillingLastName', 'value' => $tmp[9]); $tmp[10] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['addone']); $olpform['fields']['HIDDEN'][] = array('name' => 'BillingAddress1', 'value' => $tmp[10]); $tmp[11] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['addtwo']); $olpform['fields']['HIDDEN'][] = array('name' => 'BillingAddress2', 'value' => $tmp[11]); $tmp[12] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['city']); $olpform['fields']['HIDDEN'][] = array('name' => 'BillingCity', 'value' => $tmp[12]); $tmp[13] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['stateprov']); $olpform['fields']['HIDDEN'][] = array('name' => 'BillingCounty', 'value' => $tmp[13]); $tmp[14] = $hsbccode; $olpform['fields']['HIDDEN'][] = array('name' => 'BillingCountry', 'value' => $tmp[14]); $tmp[15] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['postalcode']); $olpform['fields']['HIDDEN'][] = array('name' => 'BillingPostal', 'value' => $tmp[15]); $tmp[16] = preg_replace('/[^0-9a-zA-Z\@\. ]/','',$order['order']['email']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShopperEmail', 'value' => $tmp[16]); $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] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['addone']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingAddress1', 'value' => $tmp[19]); $tmp[20] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['addtwo']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingAddress2', 'value' => $tmp[20]); $tmp[21] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['city']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingCity', 'value' => $tmp[21]); $tmp[22] = $hsbccode; $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingCountry', 'value' => $tmp[22]); $tmp[23] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['stateprov']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingCounty', 'value' => $tmp[23]); $tmp[24] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['fname']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingFirstName', 'value' => $tmp[24]); $tmp[25] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['lname']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingLastName', 'value' => $tmp[25]); $tmp[26] = preg_replace('/[^0-9a-zA-Z ]/','',$order['order']['postalcode']); $olpform['fields']['HIDDEN'][] = array('name' => 'ShippingPostal', 'value' => $tmp[26]); $xtmp = array(); foreach ($tmp as $key => $value) {if ($value != '') {$xtmp[] = $value;}} $tmp = $xtmp; unset($xtmp); foreach ($olpform['fields']['HIDDEN'] as $num => $data) { if ($data['value'] == '') {unset($olpform['fields']['HIDDEN'][$num]);} } $orderhash = $hsbcobject->GenerateHash($tmp, $order['gateway']['transkey']); unset($tmp); $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); ?>