How to integrate

'2C2P Payment Action API' allows merchant to Query, Manage, Capture transaction and also perform other Advance Management to RPP (Recurring Payment Plan) transaction, Tokenize credit card data and pull IPP (Installment Payment Plan) plan list.

For merchant who want to integrate with Payment Action API, there are 2 way of encrypt / decrypt method as below

  • Integrate with PKCS7 - For this method, merchant required user cert key (public & private key) to conduct encryption & decryption.

  • Integrate with Base64 - For this method, merchant only required Base64 to conduct encryption & decryption.

πŸ“˜

Environment

Please refer Demo & Live Endpoint.

Β 

Integrate With PKCS7


Prepare Payment Action Request

πŸ‘

Download Sample Code

PHP Code

🚧

Prerequisite

Required necessary certificate key for the Payment Action Request and Response. Please refer Certificate Generation Guide.

Β 
Set account credentials

//Merchant's account information
    $merchantID = "JT01";       //Get MerchantID when opening account with 2C2P
    $secretKey = "7jYcp4FxFdf0";    //Get SecretKey from 2C2P PGW Dashboard

Set Inquiry Parameter

//Request Information 
    $processType = "I";     
    $invoiceNo = "Invoice1401872337";
    $version = "3.4";

Set payment action request information

//Construct signature string
    $stringToHash = $version . $merchantID . $processType . $invoiceNo ; 
    $hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));    //Compute hash value

Construct payment action request message

//Construct request message
    $xml = "<PaymentProcessRequest>
            <version>$version</version> 
            <merchantID>$merchantID</merchantID>
            <invoiceNo>$invoiceNo</invoiceNo> 
            <processType>$processType</processType>
            <hashValue>$hash</hashValue>
            </PaymentProcessRequest>";  
            
    include_once('pkcs7.php');
    
    $pkcs7 = new pkcs7();
    $payload = $pkcs7->encrypt($xml,"./keys/demo2.crt"); //Encrypt payload

Submit payment action request message

include_once('HTTP.php');
    
    //Send request to 2C2P PGW and get back response
    $http = new HTTP();
    $response = $http->post("https://demo2.2c2p.com/2C2PFrontend/PaymentActionV2/PaymentAction.aspx","paymentRequest=".$payload);

Read payment response and Display

//Decrypt response message and display  
    $response = $pkcs7->decrypt($response,"./keys/demo2.crt","./keys/demo2.pem","2c2p");   
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>";
    
?>

Complete Code

<?php
  
    //Merchant's account information
    $merchantID = "JT01";       //Get MerchantID when opening account with 2C2P
    $secretKey = "7jYcp4FxFdf0";    //Get SecretKey from 2C2P PGW Dashboard

    //Request Information 
    $processType = "I";     
    $invoiceNo = "Invoice1401872337";
    $version = "3.4";
    
    //Construct signature string
    $stringToHash = $version . $merchantID . $processType . $invoiceNo ; 
    $hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));    //Compute hash value

    //Construct request message
    $xml = "<PaymentProcessRequest>
            <version>$version</version> 
            <merchantID>$merchantID</merchantID>
            <processType>$processType</processType>
            <invoiceNo>$invoiceNo</invoiceNo> 
            <hashValue>$hash</hashValue>
            </PaymentProcessRequest>";  

    include_once('pkcs7.php');
    
    $pkcs7 = new pkcs7();
    $payload = $pkcs7->encrypt($xml,"./keys/demo2.crt"); //Encrypt payload
                
    include_once('HTTP.php');
    
    //Send request to 2C2P PGW and get back response
    $http = new HTTP();
    $response = $http->post("https://demo2.2c2p.com/2C2PFrontend/PaymentActionV2/PaymentAction.aspx","paymentRequest=".$payload);
     
    //Decrypt response message and display  
    $response = $pkcs7->decrypt($response,"./keys/demo2.crt","./keys/demo2.pem","2c2p");   
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>"; 
?>

Β 

Integrate With Base64


πŸ‘

Download Sample Code

PHP Code

Prepare Payment Action Request

🚧

Prerequisite

Required necessary certificate key for the Payment Action Request and Response. Please refer Certificate Generation Guide.

Β 
Set account credentials

//Merchant's account information
    $merchantID = "JT01";       //Get MerchantID when opening account with 2C2P
    $secretKey = "7jYcp4FxFdf0";    //Get SecretKey from 2C2P PGW Dashboard

Set Inquiry Parameter

//Request Information 
    $processType = "I";     
    $invoiceNo = "Invoice1401872337";
    $version = "3.4";

Set payment action request information

//Construct signature string
    $stringToHash = $version . $merchantID . $processType . $invoiceNo ; 
    $hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));    //Compute hash value

Construct payment action request message

//Construct request message
    $xml = "<PaymentProcessRequest>
            <version>$version</version> 
            <merchantID>$merchantID</merchantID>
            <invoiceNo>$invoiceNo</invoiceNo> 
            <processType>$processType</processType>
            <hashValue>$hash</hashValue>
            </PaymentProcessRequest>";  
            
    $payload = base64_encode($xml); //Encrypt payload

Submit payment action request message

include_once('HTTP.php');
    
    //Send request to 2C2P PGW and get back response
    $http = new HTTP();
    $response = $http->post("https://demo2.2c2p.com/2C2PFrontend/PaymentActionV2/PaymentProcess.aspx","paymentRequest=".$payload);

Read payment response and Display

//Decrypt response message and display  
    $response = base64_decode($response);   
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>";
    
?>

Complete Code

<?php
  
    //Merchant's account information
    $merchantID = "JT01";       //Get MerchantID when opening account with 2C2P
    $secretKey = "7jYcp4FxFdf0";    //Get SecretKey from 2C2P PGW Dashboard

    //Request Information 
    $processType = "I";     
    $invoiceNo = "Invoice1401872337";
    $version = "3.4";
    
    //Construct signature string
    $stringToHash = $version . $merchantID . $processType . $invoiceNo ; 
    $hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));    //Compute hash value

    //Construct request message
    $xml = "<PaymentProcessRequest>
            <version>$version</version> 
            <merchantID>$merchantID</merchantID>
            <processType>$processType</processType>
            <invoiceNo>$invoiceNo</invoiceNo> 
            <hashValue>$hash</hashValue>
            </PaymentProcessRequest>";  

    $payload = base64_encode($xml); //Encrypt payload
                
    include_once('HTTP.php');
    
    //Send request to 2C2P PGW and get back response
    $http = new HTTP();
    $response = $http->post("https://demo2.2c2p.com/2C2PFrontend/PaymentActionV2/PaymentProcess.aspx","paymentRequest=".$payload);
     
    //Decrypt response message and display  
    $response = base64_decode($response);   
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>"; 
?>

Next : Basic Payment options