<?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 // ข้อมูลเชื่อมต่อ 2C2P $merchantId = '2206'; $apiSecretKey = '7068c343afa741ea978abe75a1b22d51'; $pacoEncryptionPublicKey = file_get_contents('key/PACOEncryptionPublic.txt'); $pacoSigningPublicKey = file_get_contents('key/PACOSigningPublic.txt'); //Request information $version = "8.5"; // version demo or implement $payment_url = "https://core.demo-paco.2c2p.com/api/1.0/Payment/prePaymentUi"; // version สำหรับทำสอบชำระเงิน โดยปรกติต้องทดสอบถึงจะแจ้งทาง 2C2P เพื่อเปิดใช้จริง //$payment_url = "https://t.2c2p.com/RedirectV3/payment"; // version ใช้จริง //Construct signature string hash ข้อมูลทั้งหมด $params = $version.$merchantid.$payment_description.$order_id.$currency.$amount.$result_url_1; $hash_value = hash_hmac('sha256',$params, $pacoEncryptionPublicKey,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; ?>