Documentation / Payment Flow

Payment API ทำงานอย่างไร

ดู payment flow ครบตั้งแต่สร้าง deposit และยืนยัน payment ไปจนถึง credit, withdrawal, refund และ financial reconciliation

เปิด payment integration
Deposit
creation และ credit
Payout
verification และ sending
Statuses
operation confirmation
Reconciliation
financial control
Payment flow

จาก request ไป final result

01
สร้าง operation

บันทึก player, amount, currency, payment method และ unique operation ID

02
ยืนยัน payment

ส่ง player ไป payment page, ขอ bank confirmation หรือ process payment โดยตรง

03
รับ final status

ตรวจ payment provider response และยืนยัน final operation result

04
อัปเดต balance และ accounting

Credit หรือ debit funds เพียงครั้งเดียว บันทึก fee และเก็บ operation สำหรับ reconciliation

ภาพรวม

ทุก payment ผ่านขั้นตอนที่ควบคุมได้

Platform กำหนด internal ID ให้ operation เชื่อมกับ payment provider response และเปลี่ยน financial state หลังยืนยันผลแล้วเท่านั้น Repeated request ต้องไม่สร้าง debit หรือ credit ซ้ำ

Unified operation ID

ID นี้เชื่อม player, amount, currency, payment method, payment provider และ processing history ทั้งหมด

Statuses ที่เข้าใจง่าย

Operation ผ่านเฉพาะ stages ที่อนุญาตและไม่เปลี่ยน completed result โดยไม่มี correction แยก

Financial accounting แยกต่างหาก

Payment status, balance change, fee และ accounting entry เชื่อมโยงกัน แต่ตรวจสอบแยกกัน

Deposit flow

Typical deposit flow

Deposit เริ่มจากการสร้าง internal operation และจบด้วยการ credit เพียงครั้งเดียวหลัง payment provider ยืนยัน

01

ตรวจ request และสร้าง operation

Platform ตรวจ player, KYC, limits, currency, amount และ payment method แล้วกำหนด internal ID ให้ operation

02

ส่ง payment ไป provider

Provider รับ amount, currency, player data, return URL, notification URL และข้อมูลที่จำเป็น

03

ยืนยัน payment

Player ยืนยัน payment บน external page ผ่าน 3-D Secure หรือ banking app

04

รับ confirmation และ credit funds

หลังตรวจ signature และ final status แล้ว platform เพิ่ม player balance เพียงครั้งเดียวและปิด operation

Withdrawal และ refund

Withdrawal, cancellation และ refund

Outgoing operations ต้องตรวจ player, available balance, risk, payment details และ final response จาก payment provider

Player verification

KYC, อายุ, account status, limits, self-exclusion และ withdrawal methods ที่อนุญาต

Risk check

AML, fraud indicators, wagering requirements, source of funds และ operator approval

Reserve amount

Amount ถูกล็อกใน balance จนได้ final payout result

ส่งไป payment provider

สร้าง payout request แยกพร้อม unique ID และ beneficiary details ที่ยืนยันแล้ว

รอผลลัพธ์

Platform รับ intermediate statuses และไม่ debit amount ซ้ำ

Refund

Refund ถูกสร้างเป็น operation แยก เชื่อมกับ original payment และมี amount ของตัวเอง

Rollback

Cancellation ทำได้เฉพาะก่อน irreversible stage และไม่แทน refund ของ completed operation

Final reconciliation

Provider report, payout data, fees และ balance changes ต้องแสดงผลตรงกัน

Operation statuses

Recommended status model

Internal statuses รวม responses จาก payment providers ต่าง ๆ ให้เป็น model เดียวที่ platform เข้าใจง่าย

Created

Operation ถูกสร้างใน platform แล้ว แต่ยังไม่ส่งหรือยังไม่ถูก provider รับ

Action required

Player ต้องยืนยัน payment, กรอกข้อมูล หรือทำ action ในธนาคาร

Processing

Provider รับ operation แล้ว แต่ final result ยังไม่ยืนยัน

Completed

Operation สำเร็จ แล้วจึงเปลี่ยน balance เพียงครั้งเดียว

Declined

Operation จบด้วยการปฏิเสธ พร้อมเก็บ reason และไม่มี debit/credit ซ้ำ

Unconfirmed

Final result ไม่ทราบเนื่องจาก connection drop, delayed response หรือข้อมูลขัดแย้ง

Unknown result ไม่ควรถูกนับเป็น failure

Payment อาจถูก provider รับแล้วแม้ไม่มี response ทันเวลา ให้ขอ current status หรือรอ confirmation ก่อน แล้วค่อยตัดสินใจว่าจะทำ operation ซ้ำหรือไม่

Reliability และ reconciliation

Duplicate protection และ financial reconciliation

ความน่าเชื่อถือของ Payment API ขึ้นอยู่กับพฤติกรรมที่ปลอดภัยเมื่อมี repeated requests, delayed confirmations และ partial failures

การป้องกัน operation ซ้ำ

Deposit, withdrawal และ refund แต่ละรายการมี unique ID
Repeated request คืน existing result และไม่สร้าง financial operation ใหม่
Repeated notification ตรวจด้วย event ID และ current payment state
Balance change เชื่อมกับ payment ID และใช้เพียงครั้งเดียว

Financial accounting และ reconciliation

เก็บ amount, fee, net credit, currency และ provider ID แยกกัน
ไม่แก้ completed record ย้อนหลัง แต่สร้าง correction แยก
Reconcile API operations, provider reports, balance changes และ payouts
บันทึก discrepancy, reason, owner และ correction result
Testing

สิ่งที่ต้องตรวจสอบก่อน launch

ทดสอบ successful payment, decline, connection loss, repeated confirmation, unknown result, refund และ financial reconciliation

Successful deposit และ withdrawal

Intermediate statuses ทั้งหมด, confirmation, balance change และ final reporting

Operation declined

Insufficient funds, invalid details, limit exceeded, bank decline, risk check และ unavailable payment method

Connection loss

Connection หลุดหลังส่ง request แล้ว confirmation มาทีหลังหรือถูกขอแยก

Repeated requests

Operation หรือ confirmation เดิมเข้ามาซ้ำหลัง processing เสร็จ

Refund และ cancellation

Full/partial refund, cancellation ก่อน processing และห้าม cancel completed operation

Reconciliation

Amount, fee, final status, balance และ provider report ต้องตรงกันหลังทุก scenario

Checklist ก่อน launch

Production payments เปิดหลังตรวจ statuses, confirmations, duplicate protection, balance และ financial reporting

Test และ production ใช้ access, notification URLs และ accounts แยกกัน
การกลับมาที่เว็บไซต์ของ user ไม่ใช้เป็นหลักฐานว่า payment สำเร็จ
ตรวจ signature และ event ID ก่อนเปลี่ยน balance
Deposit, withdrawal และ refund ป้องกันการทำซ้ำ
Unknown status ตรวจสอบกับ provider และเช็กอีกครั้งตอน reconciliation
ตั้ง error alerts, PSP reports และกระบวนการวิเคราะห์ discrepancies แล้ว

ต้องการออกแบบ payment flow ไหม

ส่งรายชื่อ PSP, payment methods, currencies, markets, balance rules และ statuses มาให้ APIACE จะช่วยวาง deposit, withdrawal, refund, confirmation และ financial reconciliation