====== PHP HOSTED PAYMENTS WITH SECURECARD STORAGE ====== **Settings file (nuvei_account.inc):** ---- \\ **Payment page (nuvei_payment.php):**
\n"; writeHiddenField("TERMINALID", $terminalId); writeHiddenField("CURRENCY", $currency); writeHiddenField("ORDERID", $orderId); writeHiddenField("SECURECARDMERCHANTREF", $secureCardMerchantRef); writeHiddenField("AMOUNT", $amount); writeHiddenField("DATETIME", $dateTime); if(isset($cardholderName) && $cardholderName != '') writeHiddenField("CARDHOLDERNAME", $cardholderName); if(isset($postcode) && $postcode != '') { writeHiddenField("ADDRESS1", $address1); writeHiddenField("ADDERSS2", $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); 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 Nuvei. echo '
Submitting order to Nuvei for Payment...'; //var_dump(get_defined_vars()); ?>
---- \\ **Receipt page (nuvei_receipt_page.php):** ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if you will get charged for this order.'; if(isset($_REQUEST["ORDERID"])) echo 'Please quote Nuvei Terminal ID: ' . $terminalId . ', and Order ID: ' . $_REQUEST["ORDERID"] . ' when mailling or calling.'; } ?> ---- \\ ** Helper file (nuvei_hpp_functions.inc):** \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, $merchantRef, $secureCardCardRef, $cardType, $maskedCardNumber, $cardExpiry, $responseHash) { global $terminalId, $secret; return (md5($terminalId . $orderId . $amount . $dateTime . $responseCode . $responseText . $merchantRef . $secureCardCardRef . $cardType . $maskedCardNumber . $cardExpiry . $secret)==$responseHash); } ?> ---- \\ **Background Validation page (nuvei_validate.php):**