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

Settle request

Allows merchant to capture / settle a pre-authorized 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
--


👍

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 = "S";		
	$invoiceNo = "Test051115184517799";
	$version = "3.4";
	$actionAmount = "10.00";

🚧

Action amount

Action amount is mandatory for Settlement request.
Merchant could request for partial Settlement amount.

🚧

Pre-authorized transaction

Pre-authorized transaction that is not settled after a period of time (commonly 7 days) will be automatically Voided by the Acquirer, the period vary from one to another acquirer.

PaymentTypeDescription
IInquiry transaction information
VVoid a transaction
SSettle a pre-authorized transaction
RRefund a transaction
RSGet Refund Status of an invoice number

Set payment action request information

//Construct signature string
	$stringToHash = $version . $merchantID . $processType . $invoiceNo . $actionAmount ; 
	$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> 
			<actionAmount>$actionAmount</actionAmount> 
			<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"; }
	
?>

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 = "S";		
	$invoiceNo = "Test051115184517799";
	$version = "3.4";
	$actionAmount = "10.00";
	
	//Construct signature string
	$stringToHash = $version . $merchantID . $processType . $invoiceNo . $actionAmount ; 
	$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> 
			<actionAmount>$actionAmount</actionAmount> 
			<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
--


👍

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 = "S";		
	$invoiceNo = "Test051115184517799";
	$version = "3.4";
	$actionAmount = "10.00";

🚧

Action amount

Action amount is mandatory for Settlement request.
Merchant could request for partial Settlement amount.

🚧

Pre-authorized transaction

Pre-authorized transaction that is not settled after a period of time (commonly 7 days) will be automatically Voided by the Acquirer, the period vary from one to another acquirer.

PaymentTypeDescription
IInquiry transaction information
VVoid a transaction
SSettle a pre-authorized transaction
RRefund a transaction
RSGet Refund Status of an invoice number

Set payment action request information

//Construct signature string
	$stringToHash = $version . $merchantID . $processType . $invoiceNo . $actionAmount ; 
	$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> 
			<actionAmount>$actionAmount</actionAmount> 
			<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"; }
	
?>

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 = "S";		
	$invoiceNo = "Test051115184517799";
	$version = "3.4";
	$actionAmount = "10.00";
	
	//Construct signature string
	$stringToHash = $version . $merchantID . $processType . $invoiceNo . $actionAmount ; 
	$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> 
			<actionAmount>$actionAmount</actionAmount> 
			<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>"; 
 
	//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 : Refund request