====== PHP Hosted Subscriptions ======
**Settings file (%gatewaySampleFileName_account.inc):**
----
\\
**Subscription redirect (%gatewaySampleFileName_subscription.php):**
0). Format: DD-MM-YYYY
$dateTime = requestDateTime();
# Verification string
$requestHash = subscriptionRequestHash($subscriptionMerchantRef,$secureCardMerchantRef, $dateTime, $startDate);
# Request URL for the Gateway
$requestURL = $gateway."/merchant/subscriptionpage/".$subscriptionAction;
# Write the HTML of the submission form
echo "Submitting Subscription setup request to Gateway...';
?>
----
\\
Subscription URL **(%gatewaySampleFileName_subscription_response.php)** (URL for this page is setup as “**Subscription URL**” through Terminal Setup in the %SelfCare ):
----
\\
**Helper file (%gatewaySampleFileName_subscription_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');
}
# 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);
}
?>