Developer ZoneRecipesAPI ReferenceChangelog
Developer Zone
These docs are for v3.2.6. Click to read the latest docs for v4.3.0.

Submit payment request (S2B)

Server to Browser (S2B) Integration support 3DS and 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>"; 
	$payload = base64_encode($payloadXML); //encode with base64
?>

Submit payment request form

<form action='https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/PaymentAuth.aspx' method='POST' name='paymentRequestForm'>
	Processing payment request, Do not close the browser, press back or refresh the page. 
	<?php echo "<input type='hidden' name='paymentRequest' value='".$payload."'>"; ?>
</form>
<script language="JavaScript">
	document.paymentRequestForm.submit();	//submit form to 2c2p PGW
</script>

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  = "000000000080";
	$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 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>"; 
	$payload = base64_encode($payloadXML); //encode with base64
?>  

<form action='https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/PaymentAuth.aspx' method='POST' name='paymentRequestForm'> 
	<!--display wait message to user when page is loading-->
	Processing payment request, Do not close the browser, press back or refresh the page. 
	<?php echo "<input type='hidden' name='paymentRequest' value='".$payload."'>"; ?>
</form>
<script language="JavaScript">
	document.paymentRequestForm.submit();	//submit form to 2c2p PGW
</script>

Next : Read payment response