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

Submit payment request (S2S)

Server to Server (S2S) Integration support ONLY Non-3DS transactions

👍

Download Sample Code

PHP Code

Set account credentials

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

Set transaction information

//Transaction Information
	$desc = "2 days 1 night hotel room";
	$uniqueTransactionCode = time();
	$currencyCode = "702";
	$amt  = "000000000010";
	$panCountry = "SG";

	//Customer Information
	$cardholderName = "John Doe";

Set encrypted card data

//Encrypted card data
	$encCardData = $_POST['encryptedCardInfo'];

	//Retrieve card information for merchant use if needed
	$maskedCardNo = $_POST['maskedCardInfo'];
	$expMonth = $_POST['expMonthCardInfo'];
	$expYear = $_POST['expYearCardInfo'];

Merchant's backend code will receive credit card details encrypted.

"encryptedCardInfo" => "00acTPCs4oy2P52nolDsjc9FabG5/p6OqMzISvh8glP+qb5YgD7z7wCayBp9QW66CtAFENvqW/zZTgDBSKM8qz0W6sFx4TO6Uww58ar//VvDc5+OUz+JIAlQCPhewZN8IznxlyaBFvFLpvi+VugaUWo/Eow6kYalVuIj0MYg8OAccgU=U2FsdGVkX18jR/eUn9PmDT3MSuD3cmgWSovAztlaIPaE52l+fl3SJkU2+UhgJxZL"

Posted information to backend code

Variable nameDescription
encryptedCardInfoEncrypted card data to be sent to 2C2P PGW
maskedCardInfoMasked card number (first 6 and last 4 digit of the credit card)
expMonthCardInfoCard expiry month
expYearCardInfoCard expiry year

Set payment request information

//Request Information 
	$version = "9.9";

Construct payment request message

//Construct payment request message
	$xml = "<PaymentRequest>
		<merchantID>$merchantID</merchantID>
		<uniqueTransactionCode>$uniqueTransactionCode</uniqueTransactionCode>
		<desc>$desc</desc>
		<amt>$amt</amt>
		<currencyCode>$currencyCode</currencyCode>  
		<panCountry>$panCountry</panCountry> 
		<cardholderName>$cardholderName</cardholderName>
		<encCardData>$encCardData</encCardData>
		</PaymentRequest>"; 
	$paymentPayload = base64_encode($xml); //Convert payload to base64
	$signature = strtoupper(hash_hmac('sha256', $paymentPayload, $secretKey, false));
	$payloadXML = "<PaymentRequest>
           <version>$version</version>
           <payload>$paymentPayload</payload>
           <signature>$signature</signature>
           </PaymentRequest>"; 
	$data = base64_encode($payloadXML); //Convert payload to base64
  	$payload = urlencode($data);        //encode with base64

Submit payment request form

include_once('HTTP.php');
	
	//Send authorization request
	$http = new HTTP();
	$response = $http->post("https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/Payment.aspx","paymentRequest=".$payload);

Read payment response

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

	//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/>";
	}
 
?>

Complete Code
Copy & Paste below code to 'payment_3d.php' file, and put this file in your Web Server.

<?php 

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

	//Transaction Information
	$desc = "2 days 1 night hotel room";
	$uniqueTransactionCode = time();
	$currencyCode = "702";
	$amt  = "000000000010";
	$panCountry = "SG";

	//Customer Information
	$cardholderName = "John Doe";
 
	//Encrypted card data
	$encCardData = $_POST['encryptedCardInfo'];

	//Retrieve card information for merchant use if needed
	$maskedCardNo = $_POST['maskedCardInfo'];
	$expMonth = $_POST['expMonthCardInfo'];
	$expYear = $_POST['expYearCardInfo'];
	
    //Request Information
	$version = "9.9";  
	
	//Construct signature string
	$stringToHash = $version.$merchantID.$uniqueTransactionCode.$desc.$amt.$currencyCode.$panCountry.$cardholderName.$encCardData;
	
	//Construct payment request message
	$xml = "<PaymentRequest>
		<merchantID>$merchantID</merchantID>
		<uniqueTransactionCode>$uniqueTransactionCode</uniqueTransactionCode>
		<desc>$desc</desc>
		<amt>$amt</amt>
		<currencyCode>$currencyCode</currencyCode>  
		<panCountry>$panCountry</panCountry> 
		<cardholderName>$cardholderName</cardholderName>
		<encCardData>$encCardData</encCardData>
		</PaymentRequest>"; 
	$paymentPayload = base64_encode($xml); //Convert payload to base64
	$signature = strtoupper(hash_hmac('sha256', $paymentPayload, $secretKey, false));
	$payloadXML = "<PaymentRequest>
           <version>$version</version>
           <payload>$paymentPayload</payload>
		   <signature>$signature</signature>
           </PaymentRequest>"; 
	$data = base64_encode($payloadXML); //Convert payload to base64
  	$payload = urlencode($data);        //encode with base64
	
	include_once('HTTP.php');
	
	//Send authorization request
	$http = new HTTP();
	$response = $http->post("https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/Payment.aspx","paymentRequest=".$payload);
	
	//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;

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