Developer

Alternative Payment Methods

Follow

Prepare Payment Request

This option only applicable for Server-to-Browser mode

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

Set to APM payment mode

Set payment option

All APM information must be included in hash compute value

	//Payment Options
	$paymentChannel = "123";		//Set transaction as Alternative Payment Method
	$agentCode = "SAM";			//APM agent code
	$channelCode = "KIOSK";			//APM channel code
	$paymentExpiry = (new DateTime('today'))->format("Y-m-d 23:59:59");	//pay slip expiry date (optional). format yyyy-MM-dd HH:mm:ss
	$mobileNo = "812348888";		//customer mobile number
	$cardholderEmail = "demo@2c2p.com";	//customer email address
Variable Name Description
paymentChannel   Payment channels option code
agentCode APM Agent Codes
channelCode

APM Channel Codes

If channel Code is left blank, system will use default value "OVERTHECOUNTER".

paymentExpiry Payment Slip Expiry, Allows merchant to specify payment expiry date/time for APM service,
Format: yyyy-MM-dd HH:mm:ss,
Default for expiry will be merchant configuration in APM system.
mobileNo Customer's mobile number, mandatory for APM payment.
cardHolderEmail Customer's email address, mandatory for APM payment.

 

Set payment request information

	//Request Information 
	$version = "9.3";
	
	//Construct signature string
	$stringToHash = $version.$merchantID.$uniqueTransactionCode.$desc.$amt.$currencyCode.$paymentChannel.$panCountry.$cardholderName.$cardholderEmail.$agentCode.$channelCode.$paymentExpiry.$mobileNo.$encCardData;
	$hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));	//Compute hash value

Construct payment request message

	//Construct payment request message
	$xml = "<PaymentRequest>
		<version>$version</version> 
		<merchantID>$merchantID</merchantID>
		<uniqueTransactionCode>$uniqueTransactionCode</uniqueTransactionCode>
		<desc>$desc</desc>
		<amt>$amt</amt>
		<currencyCode>$currencyCode</currencyCode>  
		<panCountry>$panCountry</panCountry> 
		<cardholderName>$cardholderName</cardholderName>
		<paymentChannel>$paymentChannel</paymentChannel>
		<agentCode>$agentCode</agentCode>
		<channelCode>$channelCode</channelCode>
		<paymentExpiry>$paymentExpiry</paymentExpiry>
		<mobileNo>$mobileNo</mobileNo>
		<cardholderEmail>$cardholderEmail</cardholderEmail>
		<encCardData>$encCardData</encCardData>
		<secureHash>$hash</secureHash>
		</PaymentRequest>"; 
	$payload = base64_encode($xml);	//Convert payload to 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 file code 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";

	//Payment Options
	$paymentChannel = "123";		//Set transaction as Alternative Payment Method
	$agentCode = "SAM";			//APM agent code
	$channelCode = "KIOSK";			//APM channel code
	$paymentExpiry = (new DateTime('today'))->format("Y-m-d 23:59:59");	//pay slip expiry date (optional). format yyyy-MM-dd HH:mm:ss
	$mobileNo = "81238888";		//customer mobile number
	$cardholderEmail = "demo@2c2p.com";	//customer email address
	
 
	//Request Information 
	$version = "9.3";
	
	//Construct signature string
	$stringToHash = $version.$merchantID.$uniqueTransactionCode.$desc.$amt.$currencyCode.$paymentChannel.$panCountry.$cardholderName.$cardholderEmail.$agentCode.$channelCode.$paymentExpiry.$mobileNo.$encCardData;
	$hash = strtoupper(hash_hmac('sha1', $stringToHash ,$secretKey, false));	//Compute hash value
   
	//Construct payment request message
	$xml = "<PaymentRequest>
		<version>$version</version> 
		<merchantID>$merchantID</merchantID>
		<uniqueTransactionCode>$uniqueTransactionCode</uniqueTransactionCode>
		<desc>$desc</desc>
		<amt>$amt</amt>
		<currencyCode>$currencyCode</currencyCode>  
		<panCountry>$panCountry</panCountry> 
		<cardholderName>$cardholderName</cardholderName>
		<paymentChannel>$paymentChannel</paymentChannel>
		<agentCode>$agentCode</agentCode>
		<channelCode>$channelCode</channelCode>
		<paymentExpiry>$paymentExpiry</paymentExpiry>
		<mobileNo>$mobileNo</mobileNo>
		<cardholderEmail>$cardholderEmail</cardholderEmail>
		<encCardData>$encCardData</encCardData>
		<secureHash>$hash</secureHash>
		</PaymentRequest>"; 
	$payload = base64_encode($xml);	//Convert payload to base64  
?>

<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>
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.