These docs are for v3.2.6. Click to read the latest docs for v4.3.0.

Read payment response

Response data comes encrypted as POST request to the Return URL registered in 2C2P PGW Dashboard.

👍

Download Sample Code

PHP Code

Read POST message and decrypt response message
Transaction result will be posted to Merchant's Return URL
To setup Merchant's Return URL, Login to Merchant Dashboard, under Account / Options / Payment Result URL.
and SET 'Server-to-server 3DS API - Frontend return URL' & 'Server-to-server 3DS API - Backend return URL'.

URL Path Name Description
Server-to-server 3DS API - Frontend return URL User will be redirected to this URL when transaction completes to view transaction result page.
Server-to-server 3DS API - Backend return URL A duplicate record of transaction result will be sent to Merchant's backend URL for backend processing.

Read POST message

<?php 
  $response = $_REQUEST["paymentResponse"]; 
	echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>"; 
?>

Complete Code

Copy & Paste below code to 'result.php' file, and put this file in your Web Server and register the URL in Merchant Dashboard as 'return URL'.

<?php 
	$response = $_REQUEST["paymentResponse"]; 
	
	//Decode response with base64
	$reponsePayLoadXML = base64_decode($response);
	
	//Parse ResponseXML
	$xmlObject =simplexml_load_string($reponsePayLoadXML) or die("Error: Cannot create object");
	
	//Decode payload with base64 to get the Reponse
	$payloadxml = base64_decode($xmlObject->payload);
	
	//Get the signature from the ResponseXML
	$signaturexml = $xmlObject->signature;
	
	$secretKey = "7jYcp4FxFdf0";	//Get SecretKey from 2C2P PGW Dashboard

	//Encode the payload
	$base64EncodedPayloadResponse=base64_encode($payloadxml);
	//Generate signature based on "payload"
	$signatureHash = strtoupper(hash_hmac('sha256', $base64EncodedPayloadResponse ,$secretKey, false));
	
	//Compare the response signature with payload signature with secretKey
	if($signaturexml == $signatureHash){
		echo "Response :<br/><textarea style='width:100%;height:80px'>". $payloadxml."</textarea>"; 
	}
	else{
		//If Signature does not match
		echo "Error :<br/><textarea style='width:100%;height:20px'>". "Wrong Signature"."</textarea>"; 
		echo "<br/>";
	}
?>

Next : Payment with javascript event