Status Inquiry

Allow merchant to query the current status of a transaction.

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";

PaymentType

Description

I

Inquiry transaction information

V

Void a transaction

S

Settle a pre-authorized transaction

R

Refund a transaction

RS

Get Refund Status of an invoice number

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>
            <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

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 Validate Hash

//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>"; 
 
    //Validate response Hash
    $resXml=simplexml_load_string($response); 
    $res_version = $resXml->version;
    $res_respCode = $resXml->respCode;
    $res_processType = $resXml->processType;
    $res_invoiceNo = $resXml->invoiceNo;
    $res_amount = $resXml->amount;
    $res_status = $resXml->status;
    $res_approvalCode = $resXml->approvalCode;
    $res_referenceNo = $resXml->referenceNo;
    $res_transactionDateTime = $resXml->transactionDateTime;
    $res_paidAgent = $resXml->paidAgent;
    $res_paidChannel = $resXml->paidChannel;
    $res_maskedPan = $resXml->maskedPan;
    $res_eci = $resXml->eci;
    $res_paymentScheme = $resXml->paymentScheme;
    $res_processBy = $resXml->processBy;
    $res_refundReferenceNo = $resXml->refundReferenceNo;
    $res_userDefined1 = $resXml->userDefined1;
    $res_userDefined2 = $resXml->userDefined2;
    $res_userDefined3 = $resXml->userDefined3;
    $res_userDefined4 = $resXml->userDefined4;
    $res_userDefined5 = $resXml->userDefined5;
    
    //Construct hash string
    $res_stringToHash = $res_version.$res_respCode.$res_processType.$res_invoiceNo.$res_amount.$res_status.$res_approvalCode.$res_referenceNo.$res_transactionDateTime.$res_paidAgent.$res_paidChannel.$res_maskedPan.$res_eci.$res_paymentScheme.$res_processBy.$res_refundReferenceNo.$res_userDefined1.$res_userDefined2.$res_userDefined3.$res_userDefined4.$res_userDefined5 ; 
  
    //Compute response hash
    $res_responseHash = strtoupper(hash_hmac('sha1',$res_stringToHash,$secretKey, false)); 
  
  //Validate hash value
    echo "<br/>hash: ".$res_responseHash."<br/>"; 
    if($resXml->hashValue == strtolower($res_responseHash)){ echo "valid response"; } 
    else{ echo "invalid response"; }
    
    
?>

The following XML string will return from the Decrypt Function.

<PaymentProcessResponse>
    <version>3.4</version>
    <timeStamp>030718145939</timeStamp>
    <respCode>00</respCode>
    <hashValue>f66ea0e140295cf538400ebc280547f7442b81a6</hashValue>
    <respDesc>Success</respDesc>
    <processType>I</processType>
    <invoiceNo>Invoice1401872337</invoiceNo>
    <amount>0.10</amount>
    <status>S</status>
    <approvalCode>125118</approvalCode>
    <referenceNo>33989</referenceNo>
    <transactionDateTime>20140604165807</transactionDateTime>
    <maskedPan>411111XXXXXX1111</maskedPan>
    <eci>07</eci>
    <paymentScheme>VI</paymentScheme>
    <processBy>VI</processBy>
    <userDefined1 />
    <userDefined2 />
    <userDefined3 />
    <userDefined4 />
    <userDefined5 />
</PaymentProcessResponse>

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>"; 
 
    //Validate response Hash
    $resXml=simplexml_load_string($response); 
    $res_version = $resXml->version;
    $res_respCode = $resXml->respCode;
    $res_processType = $resXml->processType;
    $res_invoiceNo = $resXml->invoiceNo;
    $res_amount = $resXml->amount;
    $res_status = $resXml->status;
    $res_approvalCode = $resXml->approvalCode;
    $res_referenceNo = $resXml->referenceNo;
    $res_transactionDateTime = $resXml->transactionDateTime;
    $res_paidAgent = $resXml->paidAgent;
    $res_paidChannel = $resXml->paidChannel;
    $res_maskedPan = $resXml->maskedPan;
    $res_eci = $resXml->eci;
    $res_paymentScheme = $resXml->paymentScheme;
    $res_processBy = $resXml->processBy;
    $res_refundReferenceNo = $resXml->refundReferenceNo;
    $res_userDefined1 = $resXml->userDefined1;
    $res_userDefined2 = $resXml->userDefined2;
    $res_userDefined3 = $resXml->userDefined3;
    $res_userDefined4 = $resXml->userDefined4;
    $res_userDefined5 = $resXml->userDefined5;
    
  //Construct hash string
    $res_stringToHash = $res_version.$res_respCode.$res_processType.$res_invoiceNo.$res_amount.$res_status.$res_approvalCode.$res_referenceNo.$res_transactionDateTime.$res_paidAgent.$res_paidChannel.$res_maskedPan.$res_eci.$res_paymentScheme.$res_processBy.$res_refundReferenceNo.$res_userDefined1.$res_userDefined2.$res_userDefined3.$res_userDefined4.$res_userDefined5 ; 
  
    //Compute response hash
    $res_responseHash = strtoupper(hash_hmac('sha1',$res_stringToHash,$secretKey, false)); 
  
  //Validate hash value
    echo "<br/>hash: ".$res_responseHash."<br/>"; 
    if($resXml->hashValue == strtolower($res_responseHash)){ echo "valid response"; } 
    else{ echo "invalid response"; }
    
    
?>

Β 

Integrate With Base64


Prepare Payment Action Request

πŸ‘

Download Sample Code

PHP Code

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";

PaymentType

Description

I

Inquiry transaction information

V

Void a transaction

S

Settle a pre-authorized transaction

R

Refund a transaction

RS

Get Refund Status of an invoice number

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>
            <processType>$processType</processType>
            <invoiceNo>$invoiceNo</invoiceNo> 
            <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 Validate Hash

//Decrypt response message and display  
    $response = base64_decode($response);    
    echo "Response:<br/><textarea style='width:100%;height:80px'>". $response."</textarea>"; 
 
    //Validate response Hash
    $resXml=simplexml_load_string($response); 
    $res_version = $resXml->version;
    $res_respCode = $resXml->respCode;
    $res_processType = $resXml->processType;
    $res_invoiceNo = $resXml->invoiceNo;
    $res_amount = $resXml->amount;
    $res_status = $resXml->status;
    $res_approvalCode = $resXml->approvalCode;
    $res_referenceNo = $resXml->referenceNo;
    $res_transactionDateTime = $resXml->transactionDateTime;
    $res_paidAgent = $resXml->paidAgent;
    $res_paidChannel = $resXml->paidChannel;
    $res_maskedPan = $resXml->maskedPan;
    $res_eci = $resXml->eci;
    $res_paymentScheme = $resXml->paymentScheme;
    $res_processBy = $resXml->processBy;
    $res_refundReferenceNo = $resXml->refundReferenceNo;
    $res_userDefined1 = $resXml->userDefined1;
    $res_userDefined2 = $resXml->userDefined2;
    $res_userDefined3 = $resXml->userDefined3;
    $res_userDefined4 = $resXml->userDefined4;
    $res_userDefined5 = $resXml->userDefined5;
    
    //Construct hash string
    $res_stringToHash = $res_version.$res_respCode.$res_processType.$res_invoiceNo.$res_amount.$res_status.$res_approvalCode.$res_referenceNo.$res_transactionDateTime.$res_paidAgent.$res_paidChannel.$res_maskedPan.$res_eci.$res_paymentScheme.$res_processBy.$res_refundReferenceNo.$res_userDefined1.$res_userDefined2.$res_userDefined3.$res_userDefined4.$res_userDefined5 ; 
  
    //Compute response hash
    $res_responseHash = strtoupper(hash_hmac('sha1',$res_stringToHash,$secretKey, false)); 
  
  //Validate hash value
    echo "<br/>hash: ".$res_responseHash."<br/>"; 
    if($resXml->hashValue == strtolower($res_responseHash)){ echo "valid response"; } 
    else{ echo "invalid response"; }
    
    
?>

The following XML string will return from the Decrypt Function.

<PaymentProcessResponse>
    <version>3.4</version>
    <timeStamp>030718145939</timeStamp>
    <respCode>00</respCode>
    <hashValue>f66ea0e140295cf538400ebc280547f7442b81a6</hashValue>
    <respDesc>Success</respDesc>
    <processType>I</processType>
    <invoiceNo>Invoice1401872337</invoiceNo>
    <amount>0.10</amount>
    <status>S</status>
    <approvalCode>125118</approvalCode>
    <referenceNo>33989</referenceNo>
    <transactionDateTime>20140604165807</transactionDateTime>
    <maskedPan>411111XXXXXX1111</maskedPan>
    <eci>07</eci>
    <paymentScheme>VI</paymentScheme>
    <processBy>VI</processBy>
    <userDefined1 />
    <userDefined2 />
    <userDefined3 />
    <userDefined4 />
    <userDefined5 />
</PaymentProcessResponse>

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 //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>"; 
 
    //Validate response Hash
    $resXml=simplexml_load_string($response); 
    $res_version = $resXml->version;
    $res_respCode = $resXml->respCode;
    $res_processType = $resXml->processType;
    $res_invoiceNo = $resXml->invoiceNo;
    $res_amount = $resXml->amount;
    $res_status = $resXml->status;
    $res_approvalCode = $resXml->approvalCode;
    $res_referenceNo = $resXml->referenceNo;
    $res_transactionDateTime = $resXml->transactionDateTime;
    $res_paidAgent = $resXml->paidAgent;
    $res_paidChannel = $resXml->paidChannel;
    $res_maskedPan = $resXml->maskedPan;
    $res_eci = $resXml->eci;
    $res_paymentScheme = $resXml->paymentScheme;
    $res_processBy = $resXml->processBy;
    $res_refundReferenceNo = $resXml->refundReferenceNo;
    $res_userDefined1 = $resXml->userDefined1;
    $res_userDefined2 = $resXml->userDefined2;
    $res_userDefined3 = $resXml->userDefined3;
    $res_userDefined4 = $resXml->userDefined4;
    $res_userDefined5 = $resXml->userDefined5;
    
  //Construct hash string
    $res_stringToHash = $res_version.$res_respCode.$res_processType.$res_invoiceNo.$res_amount.$res_status.$res_approvalCode.$res_referenceNo.$res_transactionDateTime.$res_paidAgent.$res_paidChannel.$res_maskedPan.$res_eci.$res_paymentScheme.$res_processBy.$res_refundReferenceNo.$res_userDefined1.$res_userDefined2.$res_userDefined3.$res_userDefined4.$res_userDefined5 ; 
  
    //Compute response hash
    $res_responseHash = strtoupper(hash_hmac('sha1',$res_stringToHash,$secretKey, false)); 
  
  //Validate hash value
    echo "<br/>hash: ".$res_responseHash."<br/>"; 
    if($resXml->hashValue == strtolower($res_responseHash)){ echo "valid response"; } 
    else{ echo "invalid response"; }
    
    
?>

Next : Void transaction