\r"; } # 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); } ?>