====== PHP Hosted Subscriptions ======
**Settings file (nuvei_account.inc):**
----
\\
**Subscription redirect (nuvei_subscription.php):**
0). Format: DD-MM-YYYY
$host =''; # This is your host eg. http://localhost:8000
$dateTime = requestDateTime();
# Verification string
$requestHash = subscriptionRequestHash($subscriptionMerchantRef,$secureCardMerchantRef, $dateTime, $startDate);
$requestURL = $host."/merchant/subscriptionpage/".$subscriptionAction;
# Write the HTML of the submission form
echo "Submitting Subscription setup request to Nuvei...';
?>
----
\\
Subscription URL **(nuvei_subscription_response.php)** (URL for this page is setup as “**Subscription URL**” through Terminal Setup in the SelfCare ):
----
\\
**Helper file (nuvei_subscription_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');
}
# This is used to generate the Authorisation Request Hash.
function subscriptionRequestHash($merchantRef, $secureCardMerchantRef, $dateTime, $startDate) {
global $terminalId, $secret;
return md5($terminalId . $merchantRef . $secureCardMerchantRef . $dateTime . $startDate . $secret);
}
# This function is used to validate that the MPI Response Hash from the server is correct.
# If subscriptionResponseHashIsValid(...) != $_REQUEST["HASH"] then an error should be shown and the Subscription registration should fail.
function subscriptionResponseHashIsValid($responseCode, $responseText, $subscriptionMerchantRef, $dateTime, $responseHash) {
global $terminalId, $secret;
return (md5($terminalId . $responseCode . $responseText . $subscriptionMerchantRef . $dateTime . $secret)==$responseHash);
}
?>