\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 mpiRequestHash($orderId, $cardNumber, $cardExpiry, $cardType, $amount, $dateTime) { global $terminalId, $secret; return md5($terminalId . $orderId . $cardNumber . $cardExpiry . $cardType . $amount . $dateTime . $secret); } # This function is used to validate that the MPI Response Hash from the server is correct. # If mpiResponseHashIsValid(...) != $_REQUEST["HASH"] then an error should be shown and the 3D Secure should not be validated. function mpiResponseHashIsValid($result, $mpiRef, $orderId, $dateTime, $responseHash) { global $secret; return (md5($result . $mpiRef . $orderId . $dateTime . $secret)==$responseHash); } ?>