Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous 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/07/25 13:16]
branko
Line 31: Line 31:
 <?php <?php
  
-# This is the file that contains the account settings for %Gateway.+# This is the file that contains the account settings for Gateway.
 require('​%gatewaySampleFileName_account.inc'​);​ require('​%gatewaySampleFileName_account.inc'​);​
  
-# This is a helper file for integrating to the %Gateway HPP in PHP.+# This is a helper file for integrating to the Gateway HPP in PHP.
 require('​%gatewaySampleFileName_securecard_functions.inc'​);​ require('​%gatewaySampleFileName_securecard_functions.inc'​);​
  
 $secureCardAction = '';​ #​ "​register"​ or "​update"​. $secureCardAction = '';​ #​ "​register"​ or "​update"​.
 $secureCardMerchantRef = '';​ #​ Unique Merchant Reference for this card. Length is limited to 48 chars. $secureCardMerchantRef = '';​ #​ Unique Merchant Reference for this card. Length is limited to 48 chars.
-$host = '';​ #​ This is your host eg. http://​localhost:​8000 
 $dateTime = requestDateTime();​ $dateTime = requestDateTime();​
  
 # Verification string # Verification string
 $requestHash = secureCardRequestHash($secureCardMerchantRef,​ $dateTime, $secureCardAction);​ $requestHash = secureCardRequestHash($secureCardMerchantRef,​ $dateTime, $secureCardAction);​
-$requestURL = $host."/​merchant/​securecardpage";​+ 
 +# Request URL for the gateway 
 +$requestURL = $gateway."/​merchant/​securecardpage";​ 
 # Write the HTML of the submission form # Write the HTML of the submission form
-echo "<​html><​body><​form id='%gatewaySampleFileNamesecurecardform' action='"​ . $requestURL . "'​ method='​post'>​\n";​+echo "<​html><​body><​form id='gatewaysecurecardform' action='"​ . $requestURL . "'​ method='​post'>​\n";​
 writeHiddenField("​ACTION",​ $secureCardAction);​ writeHiddenField("​ACTION",​ $secureCardAction);​
 writeHiddenField("​TERMINALID",​ $terminalId);​ writeHiddenField("​TERMINALID",​ $terminalId);​
Line 53: Line 55:
 writeHiddenField("​HASH",​ $requestHash);​ writeHiddenField("​HASH",​ $requestHash);​
  
-# Write the JavaScript that will submit the form to %Gateway. +# Write the JavaScript that will submit the form to Gateway. 
-echo '</​form>​Submitting SecureCard request to %Gateway...<​script language="​JavaScript">​document.getElementById("​%gatewaySampleFileNamesecurecardform"​).submit();</​script></​body></​html>';​+echo '</​form>​Submitting SecureCard request to Gateway...<​script language="​JavaScript">​document.getElementById("​gatewaysecurecardform"​).submit();</​script></​body></​html>';​
  
 ?> ?>
- 
 </​file>​ </​file>​
  
Line 69: Line 70:
 <?php <?php
  
-# This is the file that contains the account settings for %Gateway.+# This is the file that contains the account settings for Gateway.
 require('​%gatewaySampleFileName_account.inc'​);​ require('​%gatewaySampleFileName_account.inc'​);​
  
-# This is a helper file for integrating to the %Gateway HPP in PHP.+# This is a helper file for integrating to the Gateway HPP in PHP.
 require('​%gatewaySampleFileName_securecard_functions.inc'​);​ require('​%gatewaySampleFileName_securecard_functions.inc'​);​
  
 if($_REQUEST["​RESPONSECODE"​] != "​A"​) echo 'AN ERROR OCCURED! Your SecureCard request failed. Error message: ' . $_REQUEST["​RESPONSETEXT"​];​ if($_REQUEST["​RESPONSECODE"​] != "​A"​) echo 'AN ERROR OCCURED! Your SecureCard request failed. Error message: ' . $_REQUEST["​RESPONSETEXT"​];​
-elseif(secureCardResponseHashIsValid($_REQUEST["​RESPONSECODE"​],​ $_REQUEST["​RESPONSETEXT"​],​ $_REQUEST["​MERCHANTREF"​],​ $_REQUEST["​CARDREFERENCE"​],​ $_REQUEST["​DATETIME"​],​ $_REQUEST["​HASH"​])) {+ 
 +if(secureCardResponseHashIsValid($_REQUEST["​RESPONSECODE"​],​ $_REQUEST["​RESPONSETEXT"​],​ $_REQUEST["​MERCHANTREF"​],​ $_REQUEST["​CARDREFERENCE"​],​ $_REQUEST["​DATETIME"​],​ $_REQUEST["​HASH"​])) {
  switch($_REQUEST["​RESPONSECODE"​]) {  switch($_REQUEST["​RESPONSECODE"​]) {
  case "​A"​ : # SecureCard registration suceeded. You should store the following details against the user account:  case "​A"​ : # SecureCard registration suceeded. You should store the following details against the user account:
Line 91: Line 93:
 } else { } else {
  echo '​SECURECARD REGISTRATION FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to inform them of this error.';​  echo '​SECURECARD REGISTRATION FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to inform them of this error.';​
- if(isset($_REQUEST["​ORDERID"​])) echo '​Please quote %Gateway Terminal ID: ' . $terminalId . ', and SecureCard Merchant Reference: ' . $_REQUEST["​MERCHANTREF"​] . ' when mailling or calling.';​+ if(isset($_REQUEST["​ORDERID"​])) echo '​Please quote Gateway Terminal ID: ' . $terminalId . ', and SecureCard Merchant Reference: ' . $_REQUEST["​MERCHANTREF"​] . ' when mailling or calling.';​
 } }
  
 ?> ?>
 +
  
 </​file>​ </​file>​
Line 105: Line 108:
  
 <?php <?php
- 
-# This function returns the URL that should be used as the "​action"​ for the form posting the %Gateway'​s servers. 
-function secureCardURL() { 
- global $gateway, $testAccount;​ 
- $url = '​https://';​ 
- if($testAccount) $url .= '​test';​ 
- switch (strtolower($gateway)) { 
- default : 
- case '​%gatewaySampleFileName' ​ : $url .= '​payments';​ break; 
- case '​cashflows'​ : $url .= '​cashflows';​ break; 
- } 
- $url .= '​.%gatewayTestURL/​merchant/​securecardpage';​ 
- return $url; 
-} 
  
 # This simply reduces the PHP code required to build the form. # This simply reduces the PHP code required to build the form.
 function writeHiddenField($fieldName,​ $fieldValue) { function writeHiddenField($fieldName,​ $fieldValue) {
- echo "<​input type='​hidden'​ name='"​ . $fieldName . "'​ value='"​ . $fieldValue . "'​ />\r";+ echo "<​input type='​hidden'​ name='"​ . $fieldName . "'​ value='"​ . $fieldValue . "'​ />";​
 } }
  
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International