<?php require_once("config/config.php"); //ข้อมูลทั่วไปของ Transaction $order_id = "00000001"; $payment_description = " Product Itme 0001 x 10 "; // รายละเอียดของสินค้า $amount = str_pad(5000, 10, '0', STR_PAD_LEFT)."00"; // จำนวนเงิน ต้องททำเป็นเลข 10 หลัก $currency = "764"; // สกุลเงิน ไทย ถ้าอยากเปลี่ยนสกุลเงินดูได้ใน Doc ของ 2C2P $result_url_1 = "result.php"; // url สำหรับ redirect กลับมาที่เว็บเราเพื่อเช็คการชำระเงิน //Merchant's account information $merchant_id = "2206"; // Get MerchantID when $secret_key = $apikey; //Get SecretKey from 2C2P PGW Dashboard //Request information $version = "8.5"; // version demo or implement $payment_url = "https://demo2.2c2p.com/2C2PFrontEnd/RedirectV3/payment"; // version สำหรับทำสอบชำระเงิน โดยปรกติต้องทดสอบถึงจะแจ้งทาง 2C2P เพื่อเปิดใช้จริง //$payment_url = "https://t.2c2p.com/RedirectV3/payment"; // version ใช้จริง //Construct signature string hash ข้อมูลทั้งหมด $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 // สร้างแบบฟอร์มที่จะส่งค่า $formdata = ' <form id="payform" 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" id="submitx" name="submit" value="Confirm" /> </form> '; echo $formdata; ?>