2C2Pv1.8.0

Read Payment Response

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

Register Public key

2C2P Payment gateway encrypt transaction result data before sending it back to merchant's server.
Merchant's Public Key is required by the PGW to encrypt the transaction data, so that only the account owner could view the transaction result.
To register Merchant's Public Key, Login to 2C2P PGW Dashboard, under Account / Options / Payment Result URL
and SET 'Server-to-server API - Public key'.
If you do not have certificate yet, Download certificate generator here.

Screen Shot: 

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.
Screen Shot: 

Read POST message

<?php
      $response = $_REQUEST["paymentResponse"]; 

Decrypt response message

    include_once('pkcs7.php');
    $pkcs7 = new pkcs7();
    $response = $pkcs7->decrypt($response,"./publicKey.crt","./privateKey.pem","password");   
    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'.

/result.php
<?php 
    include_once('pkcs7.php');
    
    $response = $_REQUEST["paymentResponse"]; 
    $pkcs7 = new pkcs7();
    $response = $pkcs7->decrypt($response,"./publicKey.crt","./privateKey.pem","password");   
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>"; 
?>

Copy & Paste below code to 'pkcs7.php' file, and put this file in your Web Server in the same folder as 'result.php'.

/pkcs7.php show

Full Request elements and data type check here.
Full Response elements and data type check here.

Download full demo: PHP code / .Net code