Prepare payment request
'2C2P Redirect API' allows merchant to integrate to 2C2P Payment Gateway with minimum effort and enjoy the full benefits of enhanced security and full suite of payment options. Accepting payment from Credit card, Cash, ATM, KIOSK, Over the counter, Internet banking, and all other bank channels cannot be easier with '2C2P Redirect API'.
Download Sample Code
Environment
Please refer Demo & Live Endpoint.
Set account credentials
<?php
//Merchant's account information
$merchant_id = "JT01"; //Get MerchantID when opening account with 2C2P
$secret_key = "7jYcp4FxFdf0"; //Get SecretKey from 2C2P PGW Dashboard
Set transaction information
//Transaction information
$payment_description = "2 days 1 night hotel room";
$order_id = time();
$currency = "702";
$amount = '000000002500';
Set payment request information
//Request information
$version = "8.5";
$payment_url = "https://demo2.2c2p.com/2C2PFrontEnd/RedirectV3/payment";
$result_url_1 = "http://localhost/devPortal/V3_UI_PHP_JT01_devPortal/result.php";
//Construct signature string
$params = $version.$merchant_id.$payment_description.$order_id.$currency.$amount.$result_url_1;
$hash_value = hash_hmac('sha256',$params, $secret_key,false); //Compute hash value
Construct payment request form
echo 'Payment information:';
echo '<html>
<body>
<form id="myform" method="post" action="'.$payment_url.'">
<input type="hidden" name="version" value="'.$version.'"/>
<input type="hidden" name="merchant_id" value="'.$merchant_id.'"/>
<input type="hidden" name="currency" value="'.$currency.'"/>
<input type="hidden" name="result_url_1" value="'.$result_url_1.'"/>
<input type="hidden" name="hash_value" value="'.$hash_value.'"/>
PRODUCT INFO : <input type="text" name="payment_description" value="'.$payment_description.'" readonly/><br/>
ORDER NO : <input type="text" name="order_id" value="'.$order_id.'" readonly/><br/>
AMOUNT: <input type="text" name="amount" value="'.$amount.'" readonly/><br/>
<input type="submit" name="submit" value="Confirm" />
</form>
Submit payment request form
<script type="text/javascript">
document.forms.myform.submit();
</script>
</body>
</html>';
?>
Complete Code
Copy & Paste below code to your working file, and put this file in your Web Server.
<?php
//Merchant's account information
$merchant_id = "JT01"; //Get MerchantID when opening account with 2C2P
$secret_key = "7jYcp4FxFdf0"; //Get SecretKey from 2C2P PGW Dashboard
//Transaction information
$payment_description = '2 days 1 night hotel room';
$order_id = time();
$currency = "702";
$amount = '000000002500';
//Request information
$version = "8.5";
$payment_url = "https://demo2.2c2p.com/2C2PFrontEnd/RedirectV3/payment";
$result_url_1 = "http://localhost/devPortal/V3_UI_PHP_JT01_devPortal/result.php";
//Construct signature string
$params = $version.$merchant_id.$payment_description.$order_id.$currency.$amount.$result_url_1;
$hash_value = hash_hmac('sha256',$params, $secret_key,false); //Compute hash value
echo 'Payment information:';
echo '<html>
<body>
<form id="myform" method="post" action="'.$payment_url.'">
<input type="hidden" name="version" value="'.$version.'"/>
<input type="hidden" name="merchant_id" value="'.$merchant_id.'"/>
<input type="hidden" name="currency" value="'.$currency.'"/>
<input type="hidden" name="result_url_1" value="'.$result_url_1.'"/>
<input type="hidden" name="hash_value" value="'.$hash_value.'"/>
PRODUCT INFO : <input type="text" name="payment_description" value="'.$payment_description.'" readonly/><br/>
ORDER NO : <input type="text" name="order_id" value="'.$order_id.'" readonly/><br/>
AMOUNT: <input type="text" name="amount" value="'.$amount.'" readonly/><br/>
<input type="submit" name="submit" value="Confirm" />
</form>
<script type="text/javascript">
document.forms.myform.submit();
</script>
</body>
</html>';
?>
Updated almost 3 years ago