Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
developer:sample_codes:php_hosted_secure_cards [2017/11/02 11:00]
127.0.0.1 external edit
developer:sample_codes:php_hosted_secure_cards [2019/03/22 15:54]
thiago123
Line 75: Line 75:
 require('​%gatewaySampleFileName_securecard_functions.inc'​);​ require('​%gatewaySampleFileName_securecard_functions.inc'​);​
  
-if($_REQUEST["RESPONSECODE"] != "A") echo 'AN ERROR OCCURED! Your SecureCard request failedError message: ​' . $_REQUEST["​RESPONSETEXT"​]+$secureCardAction = ''; ​           # "register" ​or "update". 
-elseif(secureCardResponseHashIsValid($_REQUEST["​RESPONSECODE"​], $_REQUEST["​RESPONSETEXT"​], $_REQUEST["​MERCHANTREF"​],​ $_REQUEST["​CARDREFERENCE"​],​ $_REQUEST["​DATETIME"​],​ $_REQUEST["​HASH"​])) { +$secureCardMerchantRef = ''; ​   # Unique Merchant Reference for this cardLength is limited to 48 chars. 
- switch($_REQUEST["RESPONSECODE"]) { +$dateTime = requestDateTime()
- case "​A"​ : SecureCard registration suceeded. You should store the following details against ​the user account: + 
- $secureCardMerchantRef ​= $_REQUEST["MERCHANTREF"]+# Verification string 
- $secureCardCardRef = $_REQUEST["CARDREFERENCE"]+$requestHash = secureCardRequestHash($secureCardMerchantRef, $dateTime, $secureCardAction); 
- $secureCardCardType = $_REQUEST["CARDTYPE"]+$requestURL = $gateway."/​merchant/​securecardpage"; 
- $secureCardMaskedCardNumber = $_REQUEST["MASKEDCARDNUMBER"]; +Write the HTML of the submission form 
- $secureCardCardCardExpiry = $_REQUEST["​CARDEXPIRY"​]+echo "<​html><​body><​form id='​%gatewaySampleFileNamesecurecardform'​ action='"​ . $requestURL . "' method='​post'>​\n"; 
- echo ​"Success! Card Type: " . $secureCardCardType . ", ​Masked Card number: " . $secureCardMaskedCardNumber . ", expires (MMYY): " . $secureCardCardCardExpiry+writeHiddenField("ACTION", $secureCardAction)
- break; +writeHiddenField("TERMINALID", $terminalId)
- default ​ : # SecureCard registration failed. +writeHiddenField("MERCHANTREF"$secureCardMerchantRef)
- echo '​SECURECARD REGISTRATION FAILED! Error Code: ' . $_REQUEST["RESPONSECODE"] . 'Response text: ' . $_REQUEST["​RESPONSETEXT"​] . '​.'​+writeHiddenField("DATETIME", $dateTime); 
- } +writeHiddenField("HASH", $requestHash)
-} else { + 
- echo '​SECURECARD REGISTRATION FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' ​to inform them of this error.'; +# Write the JavaScript that will submit the form to %Gateway
- if(isset($_REQUEST["​ORDERID"​])) ​echo 'Please quote %Gateway ​Terminal ID: ' ​$terminalId ​', and SecureCard Merchant Reference: ' ​$_REQUEST["MERCHANTREF"' when mailling or calling.'; +echo '</​form>​Submitting SecureCard request to %Gateway...<script language="JavaScript">​document.getElementById("​%gatewaySampleFileNamesecurecardform"​).submit();</​script></​body></​html>​';
-}+
  
 ?> ?>
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International