Differences

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

Link to this comparison view

Both sides previous revision Previous revision
developer:sample_codes:php_xml_payments [2017/11/07 10:52]
127.0.0.1 external edit
developer:sample_codes:php_xml_payments [2019/12/12 10:30]
branko
Line 36: Line 36:
 <?php <?php
  
-require('​%gatewaySampleFileName_account.inc'​);​+require('​worldnet_account.inc'​);​
 require('​gateway_tps_xml.php'​);​ require('​gateway_tps_xml.php'​);​
  
Line 46: Line 46:
 $cvv = '';​ #​ (optional) 3 digit (4 for AMEX cards) security digit on the back of the card. $cvv = '';​ #​ (optional) 3 digit (4 for AMEX cards) security digit on the back of the card.
 $issueNo = '';​ #​ (optional) Issue number for Switch and Solo cards. $issueNo = '';​ #​ (optional) Issue number for Switch and Solo cards.
-$email = '';​ #​ (optional) If this is sent then %Gateway ​will send a receipt to this e-mail address.+$email = '';​ #​ (optional) If this is sent then WorldNet ​will send a receipt to this e-mail address.
 $mobileNumber = "";​ #​ (optional) Cardholders mobile phone number for sending of a receipt. Digits only, Include international prefix. $mobileNumber = "";​ #​ (optional) Cardholders mobile phone number for sending of a receipt. Digits only, Include international prefix.
  
Line 66: Line 66:
 $conversionRate = '';​ #​ (optional) This is the currency conversion rate returned in the rate request. $conversionRate = '';​ #​ (optional) This is the currency conversion rate returned in the rate request.
  
-# 3D Secure reference. Only include if you have verified 3D Secure throuugh the %Gateway ​MPI and received an MPIREF back. +# 3D Secure reference. Only include if you have verified 3D Secure throuugh the WorldNet ​MPI and received an MPIREF back. 
-$mpiref = '';​ #​ This should be blank unless instructed otherwise by %Gateway+$mpiref = '';​ #​ This should be blank unless instructed otherwise by WorldNet
-$deviceId = '';​ #​ This should be blank unless instructed otherwise by %Gateway.+$deviceId = '';​ #​ This should be blank unless instructed otherwise by WorldNet.
  
 $autoready = '';​ #​ (optional) (Y/N) Whether or not this transaction should be marked with a status of "​ready"​ as apposed to "​pending"​. $autoready = '';​ #​ (optional) (Y/N) Whether or not this transaction should be marked with a status of "​ready"​ as apposed to "​pending"​.
-$multicur = false; # This should be false unless instructed otherwise by %Gateway.+$multicur = false; # This should be false unless instructed otherwise by WorldNet.
  
-$description = '';​ #​ (optional) This can is a description for the transaction that will be available in the merchant notification e-mail and in the %SelfCare ​system.+$description = '';​ #​ (optional) This can is a description for the transaction that will be available in the merchant notification e-mail and in the Self Care system.
 $autoReady = '';​ #​ (optional) Y or N. Automatically set the transaction to a status of Ready in the batch. If not present the terminal default will be used. $autoReady = '';​ #​ (optional) Y or N. Automatically set the transaction to a status of Ready in the batch. If not present the terminal default will be used.
  
Line 84: Line 84:
 if($mobileNumber != ""​) $auth->​SetMobileNumber($mobileNumber);​ if($mobileNumber != ""​) $auth->​SetMobileNumber($mobileNumber);​
 if($description != ""​) $auth->​SetDescription($description);​ if($description != ""​) $auth->​SetDescription($description);​
- +
 if($issueNo != ""​) $auth->​SetIssueNo($issueNo);​ if($issueNo != ""​) $auth->​SetIssueNo($issueNo);​
 if($address1 != ""​ && $address2 != ""​ && $postcode != ""​) $auth->​SetAvs($address1,​$address2,​$postcode);​ if($address1 != ""​ && $address2 != ""​ && $postcode != ""​) $auth->​SetAvs($address1,​$address2,​$postcode);​
 if($country != ""​) $auth->​SetCountry($country);​ if($country != ""​) $auth->​SetCountry($country);​
 if($phone != ""​) $auth->​SetPhone($phone);​ if($phone != ""​) $auth->​SetPhone($phone);​
- +
 if($mpiref != ""​) $auth->​SetMpiRef($mpiref);​ if($mpiref != ""​) $auth->​SetMpiRef($mpiref);​
 if($deviceId != ""​) $auth->​SetDeviceId($deviceId);​ if($deviceId != ""​) $auth->​SetDeviceId($deviceId);​
- +
 if($multicur) $auth->​SetMultiCur();​ if($multicur) $auth->​SetMultiCur();​
 if($autoready) $auth->​SetAutoReady($autoready);​ if($autoready) $auth->​SetAutoReady($autoready);​
 if($isMailOrder) $auth->​SetMotoTrans();​ if($isMailOrder) $auth->​SetMotoTrans();​
- +
 # Perform the online authorisation and read in the result # Perform the online authorisation and read in the result
 $response = $auth->​ProcessRequestToGateway($secret,​$testAccount,​ $gateway); $response = $auth->​ProcessRequestToGateway($secret,​$testAccount,​ $gateway);
-  
  
  
-$expectedResponseHash = md5($terminalId . $response->​UniqueRef() . ($multicur == true ? $currency : ''​) . $amount . $response->​DateTime() . $response->​ResponseCode() . $response->​ResponseText() . $secret);+ 
 +$expectedResponseHash = md5($terminalId . $response->​UniqueRef() . ($multicur == true ? $currency : ''​) . $amount . $response->​DateTime() 
 +    ​. $response->​ResponseCode() . $response->​ResponseText() . $response->​BankResponseCode() . $secret);
  
 if($response->​IsError()) echo 'AN ERROR OCCURED! You transaction was not processed. Error details: ' . $response->​ErrorString();​ if($response->​IsError()) echo 'AN ERROR OCCURED! You transaction was not processed. Error details: ' . $response->​ErrorString();​
 elseif($expectedResponseHash == $response->​Hash()) { elseif($expectedResponseHash == $response->​Hash()) {
-  switch($response->​ResponseCode()) { +    ​switch($response->​ResponseCode()) { 
- case "​A"​ : # -- If using local database, update order as Authorised. +        case "​A"​ : # -- If using local database, update order as Authorised. 
- echo '​Payment Processed successfully. Thanks you for your order.';​ +            echo '​Payment Processed successfully. Thanks you for your order.';​ 
- $uniqueRef = $response->​UniqueRef();​ +            $uniqueRef = $response->​UniqueRef();​ 
- $responseText = $response->​ResponseText();​ +            $responseText = $response->​ResponseText();​ 
- $approvalCode = $response->​ApprovalCode();​ +            $approvalCode = $response->​ApprovalCode();​ 
- $avsResponse = $response->​AvsResponse();​ +            $avsResponse = $response->​AvsResponse();​ 
- $cvvResponse = $response->​CvvResponse();​ +            $cvvResponse = $response->​CvvResponse();​ 
- break; +            break; 
- case "​R"​ : +        case "​R"​ : 
- case "​D"​ : +        case "​D"​ : 
- case "​C"​ : +        case "​C"​ : 
- case "​S"​ :+        case "​S"​ :
  
- default ​ : # -- If using local database, update order as declined/​failed -- +        ​default ​ : # -- If using local database, update order as declined/​failed -- 
- echo '​PAYMENT DECLINED! Please try again with another card. Bank response: ' . $response->​ResponseText();​ +            echo '​PAYMENT DECLINED! Please try again with another card. Bank response: ' . $response->​ResponseText();​ 
- }+    }
 } else { } else {
- $uniqueReference = $response->​UniqueRef();​ +    ​$uniqueReference = $response->​UniqueRef();​ 
- echo '​PAYMENT FAILED: INVALID RESPONSE HASH. Please contact <a href="​mailto:'​ . $adminEmail . '">'​ . $adminEmail . '</​a>​ or call ' . $adminPhone . ' to clarify if you will get charged for this order.';​ +    echo '​PAYMENT FAILED: INVALID RESPONSE HASH. Please contact <a href="​mailto:'​ . $adminEmail . '">'​ . $adminEmail . '</​a>​ or call ' . $adminPhone . ' to clarify if you will get charged for this order.';​ 
- if(isset($uniqueReference)) echo '​Please quote %Gateway ​Terminal ID: ' . $terminalId . ', and Unique Reference: ' . $uniqueReference . ' when mailing or calling.';​ +    if(isset($uniqueReference)) echo '​Please quote WorldNet ​Terminal ID: ' . $terminalId . ', and Unique Reference: ' . $uniqueReference . ' when mailing or calling.';​ 
- }+}
  
 ?> ?>
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International