====== PHP Hosted Payments ====== **Settings file (%gatewaySampleFileName_account.inc):** ---- \\ **Payment page (%gatewaySampleFileName_payment.php):**
\n"; writeHiddenField("TERMINALID", $terminalId); writeHiddenField("CURRENCY", $currency); writeHiddenField("ORDERID", $orderId); writeHiddenField("AMOUNT", $amount); writeHiddenField("DATETIME", $dateTime); if(isset($cardholderName) && $cardholderName != '') writeHiddenField("CARDHOLDERNAME", $cardholderName); if(isset($postcode) && $postcode != '') { writeHiddenField("ADDRESS1", $address1); writeHiddenField("ADDRESS2", $address2); writeHiddenField("POSTCODE", $postcode); } if(isset($email) && $email != '') writeHiddenField("EMAIL", $email); if(isset($description) && $description != '') writeHiddenField("DESCRIPTION", $description); if(isset($autoReady) && $autoReady != '') writeHiddenField("AUTOREADY", $autoReady); if($receiptPageURL != '') writeHiddenField("RECEIPTPAGEURL", $receiptPageURL); if($validationURL != '') writeHiddenField("VALIDATIONURL", $validationURL); writeHiddenField("HASH", $requestHash); # You can also include any other custom fields here. Their contents will for included in the response POST to the receipt page. # writeHiddenField("Customer ID", '32856951'); # Write the JavaScript that will submit the form to Gateway. echo '
Submitting order to Gateway for Payment...'; ?>
---- \\ **Receipt page (%gatewaySampleFileName_receipt_page.php):** ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify.'; } } else { echo 'PAYMENT FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if you will get charged for this order.'; if(isset($_REQUEST["ORDERID"])) echo 'Please quote Gateway Terminal ID: ' . $terminalId . ', and Order ID: ' . $_REQUEST["ORDERID"] . ' when mailling or calling.'; } ?> ---- \\ **Helper file (%gatewaySampleFileName_hpp_functions.inc):** "; } # This generates a DATETIME value in the correct format expected in the request. function requestDateTime() { return date('d-m-Y:H:i:s:000'); } # If you are not using your own Order ID's and need to use unique random ones, this function will generate one for you. function generateUniqueOrderId() { $seconds = date('H')*3600+date('i')*60+date('s'); return date('zy') . $seconds; } # This is used to generate the Authorisation Request Hash. function authRequestHash($orderId, $amount, $dateTime) { global $terminalId, $secret, $receiptPageURL, $validationURL; return md5($terminalId . $orderId . $amount . $dateTime . $receiptPageURL . $validationURL . $secret); } # This function is used to validate that the Authorisation Response Hash from the server is correct. # If authResponseHashIsValid(...) != $_REQUEST["HASH"] then an error should be shown and the transaction should not be approved. function authResponseHashIsValid($orderId, $amount, $dateTime, $responseCode, $responseText, $responseHash) { global $terminalId, $secret; return (md5($terminalId . $orderId . $amount . $dateTime . $responseCode . $responseText . $secret)==$responseHash); } ?> ---- \\ **Background Validation page (%gatewaySampleFileName_validate.php):**