การชำระเงินและการถอน/Payment API
Payment API
สร้างและจัดการเซสชันการชำระเงินด้วยคริปโตเคอร์เรนซีผ่าน Payment API ของ 2328.io
Payment API ให้คุณสร้างเซสชันการชำระเงิน นำลูกค้าไปยังหน้า checkout ที่โฮสต์ไว้ และติดตามสถานะการชำระเงินได้
สร้างการชำระเงิน
สร้างเซสชันการชำระเงินและคืน URL สำหรับให้ลูกค้าชำระเงิน
พารามิเตอร์ของคำขอ
| Field | Type | Required | Description | Values |
|---|---|---|---|---|
amount | decimal | yes | จำนวนเงินที่ชำระในสกุลเงินนั้น เช่น 100.00 | |
currency | string | yes | สกุลเงิน fiat (USD, EUR, RUB, …) หรือคริปโตเคอร์เรนซี (USDT, TRX, BTC, …) | |
order_id | string | yes | order ID ของคุณ เช่น ORDER-12345 (สูงสุด 128 ตัวอักษร) | |
to_currency | string | no | คริปโตเคอร์เรนซีที่เลือกไว้ล่วงหน้า | |
network | string | no* | รหัสเครือข่าย (ต้องระบุเมื่อตั้งค่า to_currency หรือ currency เป็นคริปโตเคอร์เรนซี) | |
url_return | string | no | URL redirect หลังการชำระเงิน เช่น https://your-site.com/return | |
url_success | string | no | ทางเลือกแทน url_return | |
url_callback | string | no | URL สำหรับการแจ้งเตือน Webhook เช่น https://your-site.com/webhook | |
invite_code | string | no | โค้ดผู้แนะนำ | |
fee_split | decimal | no | สัดส่วนค่าธรรมเนียมผู้ค้าที่ส่งต่อให้ผู้ชำระ 0–100 (%) 0 = ผู้ค้าจ่ายเต็ม, 100 = ผู้ชำระจ่ายเต็ม ค่านี้จะลบล้างการตั้งค่าระดับโปรเจกต์ ตัวอย่าง: 30 (ผู้ชำระรับภาระ 30% ของค่าธรรมเนียม) | |
price_markup | decimal | no | บวกเพิ่มหรือส่วนลดบนยอดใบแจ้งหนี้ −99 ถึง 100 (%) ค่านี้จะลบล้างการตั้งค่าระดับโปรเจกต์ ตัวอย่าง: 5 (+5%) หรือ -10 (ส่วนลด 10%) | |
description | string | no | คำอธิบายใบแจ้งหนี้ (สูงสุด 200 ตัวอักษร) แสดงให้ผู้ชำระเห็นบนหน้าชำระเงิน ตัวอย่าง: Premium plan — Order #12345 | |
ttl_seconds | int | no | อายุของใบแจ้งหนี้เป็นวินาที ตั้งแต่ 300 (5 นาที) ถึง 86400 (24 ชั่วโมง) เมื่อพ้นเวลานี้ใบแจ้งหนี้จะหมดอายุและชำระไม่ได้อีก ค่าเริ่มต้น: 3600 (1 ชั่วโมง) ตัวอย่าง: 3600 |
การตอบกลับ
JSON
{
"state": 0,
"result": {
"uuid": "abc123-def456-...",
"order_id": "ORDER-12345",
"amount": "100.00",
"currency": "USD",
"amount_usd": "100.00",
"exchange_rate": null,
"url": "https://2328.io/pay/abc123-def456-...",
"tg_deeplink": "https://t.me/my2328bot?start=pay_abc123-def456-...",
"expires_at": "2026-01-11T21:00:00Z",
"created_at": "2026-01-11T20:00:00Z",
"payer_currency": "USDT",
"payer_amount": "100.50",
"network": "TRX-TRC20",
"address": "TXYZabc123...",
"payment_status": "check",
"txid": null,
"payment_amount": null,
"qr": "data:image/png;base64,iVBORw0..."
}
}- นำลูกค้าไปยัง
result.urlเพื่อดำเนินการชำระเงินให้เสร็จสมบูรณ์ tg_deeplink— ดีพลิงก์บอท Telegram สำหรับชำระเงินผ่าน Telegram MiniAppqr— QR code ที่เข้ารหัส base64 (data URI) ของที่อยู่ฝากเงิน จะปรากฏเมื่อมีการกำหนดที่อยู่แล้ว (เมื่อตั้งค่าnetworkร่วมกับto_currencyหรือเมื่อcurrencyเป็นคริปโตเคอร์เรนซี); ในกรณีอื่นจะเป็นnulltxid,payment_amount— เป็นnullจนกว่าลูกค้าจะชำระเงิน จะถูกเติมค่าเมื่อระบบตรวจพบธุรกรรมบนเชน รับฟัง Webhookpayment_status: paidเพื่อรู้เวลาexchange_rate— เป็นnullหากยังใช้การแปลงสกุลไม่ได้ (เช่น ยังไม่ล็อกอัตรา fiat → crypto) จะถูกเติมค่าเมื่อเลือกสกุลเงินผู้ชำระแล้ว
Credentials
curl -X POST https://api.2328.io/api/v1/payment \
-H "Content-Type: application/json" \
-H "User-Agent: MyShop/1.0 (+https://myshop.example)" \
-H "project: YOUR_PROJECT_UUID" \
-H "sign: YOUR_HMAC_SIGNATURE"Click Try it to see the response here.
ข้อมูลการชำระเงิน
ดูสถานะการชำระเงินปัจจุบันด้วย uuid หรือ order_id
พารามิเตอร์ของคำขอ
| Field | Type | Required | Description | Values |
|---|---|---|---|---|
uuid | string | yes* | UUID ของการชำระเงิน (จาก result.uuid ตอนสร้าง) | |
order_id | string | yes* | order ID ของคุณ |
ต้องระบุ uuid หรือ order_id อย่างน้อยหนึ่งค่า
curl -X POST https://api.2328.io/api/v1/payment/info \
-H "Content-Type: application/json" \
-H "User-Agent: MyShop/1.0 (+https://myshop.example)" \
-H "project: YOUR_PROJECT_UUID" \
-H "sign: YOUR_HMAC_SIGNATURE"Click Try it to see the response here.
รายการการชำระเงิน
ดูรายการการชำระเงินทั้งหมดพร้อมการกรองและแบ่งหน้า
พารามิเตอร์ของคำขอ
| Field | Type | Required | Description | Values |
|---|---|---|---|---|
status | string | no | กรองตามสถานะการชำระเงิน (ดู References) | |
date_from | date | no | วันที่เริ่มต้น (YYYY-MM-DD) เช่น 2026-01-01 | |
date_to | date | no | วันที่สิ้นสุด (YYYY-MM-DD) เช่น 2026-01-31 | |
page | int | no | หมายเลขหน้า ค่าเริ่มต้น 1 | |
per_page | int | no | จำนวนรายการต่อหน้า ค่าเริ่มต้น 15 สูงสุด 5000 |
curl -X POST https://api.2328.io/api/v1/payment/list \
-H "Content-Type: application/json" \
-H "User-Agent: MyShop/1.0 (+https://myshop.example)" \
-H "project: YOUR_PROJECT_UUID" \
-H "sign: YOUR_HMAC_SIGNATURE"Click Try it to see the response here.