globals('core.eol'); $order = $this->globals('ecom.order_summary'); // +-- // | Make sure that the mcrypt extension is loaded. // +-- $mcrypt = $this->load_extension('mcrypt'); if ($this->IsError($mcrypt)) { $message = 'The mcrypt PHP extension is not loaded. This processing 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. // +-- // | Create the SHIPPING address array. // +-- $ship_addy = array('fname' => $order['order']['fname'], 'lname' => $order['order']['lname'], 'addone' => $order['order']['addone'], 'addtwo' => $order['order']['addtwo'], 'city' => $order['order']['city'], 'stateprov' => $order['order']['stateprov'], 'postalcode' => $order['order']['postalcode'], 'country' => $order['order']['country'], 'countryabb' => $order['order']['countryabb'], 'stateabbus' => $order['order']['stateabbus']); $CORE_App =& $this->quick_object('CORE_App','core'); $countryabbs = $CORE_App->get_country_abbs(); $stateprovabbs = $CORE_App->get_stateprov_abbs(); foreach ($order['items'] as $num => $item) { if ($item['shipstatus'] != 'N') { $countryabb = $order['order']['countryabb']; $stateabbus = $order['order']['stateabbus']; if (!(empty($countryabbs[$item['country']]))) {$countryabb = $countryabbs[$item['country']];} if (!(empty($stateprovabbs[$item['stateprov']]))) {$stateabbus = $stateprovabbs[$item['stateprov']];} $ship_addy = array('fname' => $item['fname'], 'lname' => $item['lname'], 'addone' => $item['addone'], 'addtwo' => $item['addtwo'], 'city' => $item['city'], 'stateprov' => $item['stateprov'], 'postalcode' => $item['postalcode'], 'country' => $item['country'], 'countryabb' => $countryabb, 'stateabbus' => $stateabbus); break 1; } // End of if statement. } // End of foreach statement. // +-- // | 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', '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 .= "BillingPostCode=" . $order['order']['postalcode'] . "&"; $stuff .= "BillingCountry=" . $order['order']['countryabb'] . "&"; if ($order['order']['country'] == 'United States') {$stuff .= "BillingState=" . $order['order']['stateabbus'] . "&";} 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 .= "DeliveryPostCode=" . $ship_addy['postalcode'] . "&"; $stuff .= "DeliveryCountry=" . $ship_addy['countryabb'] . "&"; if ($ship_addy['country'] == 'United States') {$stuff .= "DeliveryState=" . $ship_addy['stateabbus'] . "&";} $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' => 'PAYMENT'); $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); ?>