桜
403 words
2 minutes
ระบบตัดบัตร TrueMoney และ RazerGoldPin ด้วย TMPAY
ระบบตัดบัตร TrueMoney และ RazerGoldPin ด้วย TMPAY
อยากให้เว็บตัวเองมีระบบชำระเงินด้วยบัตรทรูมันนี่และ Razer Gold PIN กันใช่ไหมละ เดี๋ยว 0x01code จะพาไปทำระบบชำระเงินกัน
TMPAY คืออะไร
tmpay คือผู้ให้บริการบริการตัดยอดเงินจากบัตรเงินสดทรูมันนี่และ razer gold pin อัตโนมัติ เหมาะสำหรับเกมออนไลน์ และเว็บไซต์ทุกประเภท ก่อตั้งเมื่อปี 2551 ได้รับความไว้วางใจและการยอมรับเรื่องบริการด้านการเงินทรูมันนี่มากที่สุดในขณะนี้
โค้ดตัวอย่าง
index.php
<?php
require_once 'TMPAY.php';
$tmpay = new TMPAY('TEST', 'https://0x01code.me/TMPAY.Webhook.php', 'truemoney');if ($tmpay->tmn_refill('55555555555551')) { echo 'ทำรายการสำเร็จ';} else { echo 'เกิดข้อผิดพลาด';}TMPAY.php
<?php
class TMPAY{ private string $merchant_id = ''; private string $resp_url = ''; private string $channel = '';
/** * merchant_id => รหัสร้านค้า (A-Z,0-9 ความยาว 10 หลัก) เช่น TMPAY * resp_url => URL สำหรับการรับผลการตรวจสอบ เช่น https://0x01code.me/TMPAY.Webhook.php * channel => ประเภทบัตรเงินสด * truemoney = บัตรเงินสดทรูมันนี่ * razer_gold_pin = Razer Gold PIN * * การทดสอบระบบสามารถใช้ merchant_id เป็น TEST และใช้รหัสบัตรด้านล่างทดสอบ * รหัสบัตรเงินสด 55555555555551 มูลค่า 50 บาท * รหัสบัตรเงินสด 55555555555552 มูลค่า 90 บาท * รหัสบัตรเงินสด 55555555555553 มูลค่า 150 บาท * รหัสบัตรเงินสด 55555555555554 มูลค่า 300 บาท * รหัสบัตรเงินสด 55555555555555 มูลค่า 500 บาท * รหัสบัตรเงินสด 55555555555556 มูลค่า 1000 บาท */ public function __construct(string $merchant_id, string $resp_url, string $channel = 'truemoney') { $this->merchant_id = $merchant_id; $this->resp_url = $resp_url; $this->channel = $channel; }
public function tmn_refill($truemoney_password) { if (function_exists('curl_init')) { $curl = curl_init('https://www.tmpay.net/TPG/backend.php?merchant_id=' . $this->merchant_id . '&password=' . $truemoney_password . '&channel=' . $this->channel . '&resp_url=' . $this->resp_url); curl_setopt($curl, CURLOPT_TIMEOUT, 10); curl_setopt($curl, CURLOPT_HEADER, FALSE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); $curl_content = curl_exec($curl); curl_close($curl); } else { $curl_content = file_get_contents('http://www.tmpay.net/TPG/backend.php?merchant_id=' . $this->merchant_id . '&password=' . $truemoney_password . '&channel=' . $this->channel . '&resp_url=' . $this->resp_url); } if (strpos($curl_content, 'SUCCEED') !== FALSE) { return true; } else { return false; } }}TMPAY.Webhook.php
<?php
// ถ้าไม่ใช้ IP ของ TMPAY ไม่ให้เข้าหน้านี้if ($_SERVER['REMOTE_ADDR'] != '203.146.127.112') { die('Access Denied');}
/** * Callback ที่ TMPAY จะส่งมาให้ * transaction_id => Transaction ID ของผลการตรวจสอบ (A-Z,0-9 ความยาว 10 หลัก) เช่น XYZ1234567 * password => รหัสบัตรเงินสดทรูมันนี่ (0-9 ความยาว 14 หลัก) เช่น 01234567890123 * real_amount => จำนวนเงินที่ได้รับ เช่น 20.00, 50.00, 90.00, 150.00, 300.00, 500.00, 1000.00 * status => ผลการตรวจสอบ (1,3,4,5) * 1 = การเติมเงินสำเร็จ * 3 = บัตรเงินสดถูกใช้ไปแล้ว * 4 = รหัสบัตรเงินสดไม่ถูกต้อง * 5 = เป็นบัตรทรูมูฟ (ไม่ใช่บัตรทรูมันนี่) */
$transaction_id = $_GET['transaction_id'];$password = $_GET['password'];$amount = $_GET['real_amount'];$status = $_GET['status'];
if ($status == 1) { /* Code เพิ่มเงินที่นี่ */ /* เช่น $user_id_refill = $this->db->query( 'SELECT TOP 1 user_id FROM truemoney WHERE truemoney = ? ', password); $this->db->query( 'UPDATE point = pount + ? WHERE user_id = ? ', $amount, $user_id_refill); */ die('SUCCEED|TOPPED_UP_THB_' . $amount . '_TO_' . $user_id_refill);} else { /* ไม่สามารถเติมเงินได ้ */ die('ERROR|ANY_REASONS');}ดูโค้ดแล้วงงรึป่าว ถ้างงก็ดูคลิปใน Youtube โล้ดดดด
ระบบตัดบัตร TrueMoney และ RazerGoldPin ด้วย TMPAY
https://blog.0x01code.me/posts/make-payment-truemoney-and-razergoldpin/