เอนด์พอยต์คำสั่งซื้อ

คำสั่งซื้อทุกรายการสร้างด้วย UUID ที่ฝั่งคุณสร้างขึ้นเอง UUID นี้คือ idempotency key หากส่งซ้ำ ระบบจะคืนคำสั่งซื้อเดิมให้แทนการเรียกเก็บเงินสองครั้ง จากนั้นอ่านสถานะได้ทีละคำสั่งซื้อ ครั้งละไม่เกิน 50 รายการ หรือดึงเป็นลิสต์แบบแบ่งหน้า

POST

/orders/create

สร้างคำสั่งซื้อ

สร้างคำสั่งซื้อใหม่ ต้องส่ง UUID ที่ไม่ซ้ำเป็น order_id เพื่อรองรับ idempotency ระบบจะตัดเงินจากกระเป๋าเงินทันที

ขีดจำกัดการเรียกใช้5000 คำขอ / 60 วินาที ต่อบัญชี

หมายเหตุ: order_id คือ idempotency key หากส่งคำขอซ้ำด้วย UUID เดิม ระบบจะส่งคำสั่งซื้อเดิมกลับมาแทนการสร้างคำสั่งซื้อซ้ำ

Body ของคำขอ

ชื่อชนิดจำเป็นคำอธิบายตัวอย่าง
order_idstring (UUID)ใช่UUID ที่ไม่ซ้ำสำหรับคำสั่งซื้อนี้ (รูปแบบใดก็ได้ เช่น v1, v4, v7) ใช้เป็น idempotency key01912345-6789-7abc-8def-0123456789ab
sub_category_idnumberใช่ID หมวดหมู่ย่อยของสินค้า999
quantitynumberใช่จำนวนที่สั่ง (จำนวนเต็มบวก)1
requirementsobjectใช่ข้อมูลผู้เล่นสำหรับการจัดส่ง ใส่ให้ครบทุกฟิลด์ที่ได้จาก endpoint “ดูฟิลด์ที่ต้องกรอกตามหมวดหมู่”{"player_id": "123456789", "server": "Asia"}
expected_unit_pricestringไม่กันราคาเปลี่ยน หากราคาปัจจุบันสูงกว่าค่านี้ ระบบจะปฏิเสธคำสั่งซื้อ0.950000
คำขอ
curl -s -X POST "https://shop2topup.com/api/endpoints/v1/orders/create" \
  -H "Authorization: Bearer YOUR_KEY_ID.YOUR_KEY_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
  "order_id": "01912345-6789-7abc-8def-0123456789ab",
  "sub_category_id": 999,
  "quantity": 1,
  "requirements": {
    "player_id": "123456789",
    "server": "Asia"
  },
  "expected_unit_price": 0.95
}'
ตัวอย่างการตอบกลับ
{
  "success": true,
  "order": {
    "order_id": "01912345-6789-7abc-8def-0123456789ab",
    "status": "pending",
    "player_id": "123456789",
    "player_name": "ProGamer99",
    "subcategory_name": "FF 100 Diamonds",
    "quantity": 1,
    "charged_amount": "0.950000",
    "currency": "USD",
    "created_at": "2024-06-15T12:00:00Z"
  }
}
GET

/orders/:orderId

ดูสถานะคำสั่งซื้อ

ดึงสถานะล่าสุดและรายละเอียดของคำสั่งซื้อที่ระบุ

ขีดจำกัดการเรียกใช้3 คำขอ / 60 วินาที ต่อบัญชี + order_id

หมายเหตุ: สถานะคำสั่งซื้อมีได้ 4 ค่า คือ pending, completed, refunded หรือ partial (partial หมายถึงจัดส่งแล้วบางหน่วย และคืนเงินหน่วยที่เหลือ) สำหรับ sub_transactions[].status แต่ละรายการจะเป็น pending, completed หรือ refunded หน่วยใดยังไม่ได้จัดส่งหรือคืนเงินจะยังอยู่ในสถานะ pending ค่า sub_transactions[].id คือลำดับของหน่วยในคำสั่งซื้อ (1…n) ไม่ใช่ ID ในฐานข้อมูล ส่วน retry_count และ max_retries หากปรากฏในผลลัพธ์ ถือว่าเลิกใช้แล้วและมีค่าเป็น 0 เสมอ

พารามิเตอร์ใน Path

ชื่อชนิดจำเป็นคำอธิบายตัวอย่าง
orderIdstring (UUID)ใช่ID คำสั่งซื้อที่ต้องการค้นหา01912345-6789-7abc-8def-0123456789ab
คำขอ
curl -s "https://shop2topup.com/api/endpoints/v1/orders/01912345-6789-7abc-8def-0123456789ab" \
  -H "Authorization: Bearer YOUR_KEY_ID.YOUR_KEY_SECRET"
ตัวอย่างการตอบกลับ
{
  "success": true,
  "order": {
    "order_id": "01912345-6789-7abc-8def-0123456789ab",
    "status": "completed",
    "player_id": "123456789",
    "player_name": "ProGamer99",
    "subcategory_name": "FF 100 Diamonds",
    "quantity": 1,
    "charged_amount": "0.950000",
    "currency": "USD",
    "created_at": "2024-06-15T12:00:00Z",
    "completed_at": "2024-06-15T12:00:05Z",
    "vouchers": [],
    "sub_transactions": [
      {
        "id": 1,
        "status": "completed",
        "player_id": "123456789",
        "player_name": "ProGamer99",
        "amount": "0.950000",
        "created_at": "2024-06-15T12:00:00Z",
        "completed_at": "2024-06-15T12:00:05Z"
      }
    ]
  }
}
POST

/orders/batch

ดึงคำสั่งซื้อแบบกลุ่ม

ดึงข้อมูลคำสั่งซื้อหลายรายการพร้อมกันด้วย ID ส่งได้สูงสุด 50 ID ต่อคำขอ

ขีดจำกัดการเรียกใช้2 คำขอ / 60 วินาที ต่อบัญชี

Body ของคำขอ

ชื่อชนิดจำเป็นคำอธิบายตัวอย่าง
order_idsstring[]ใช่อาร์เรย์ของ UUID คำสั่งซื้อ (สูงสุด 50 รายการ)["uuid-1", "uuid-2"]
คำขอ
curl -s -X POST "https://shop2topup.com/api/endpoints/v1/orders/batch" \
  -H "Authorization: Bearer YOUR_KEY_ID.YOUR_KEY_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
  "order_ids": [
    "uuid-1",
    "uuid-2"
  ]
}'
ตัวอย่างการตอบกลับ
{
  "success": true,
  "orders": [
    {
      "order_id": "01912345-6789-7abc-8def-0123456789ab",
      "status": "completed",
      "charged_amount": "0.950000"
    }
  ],
  "not_found": [
    "uuid-that-does-not-exist"
  ]
}
GET

/orders

รายการคำสั่งซื้อ

แสดงคำสั่งซื้อแบบแบ่งหน้า และกรองตามสถานะหรือช่วงวันที่ได้

ขีดจำกัดการเรียกใช้2 คำขอ / 60 วินาที ต่อบัญชี

พารามิเตอร์ใน Query

ชื่อชนิดจำเป็นคำอธิบายตัวอย่าง
pagenumberไม่หมายเลขหน้า (ค่าเริ่มต้น: 1)1
limitnumberไม่จำนวนผลลัพธ์ต่อหน้า 1-100 (ค่าเริ่มต้น: 50)50
statusstringไม่กรองคำสั่งซื้อตามสถานะ ค่าที่ใช้ได้คือ pending (รอดำเนินการ), completed (สำเร็จ), refunded (คืนเงินแล้ว) และ partial (บางส่วน)completed
created_afterstring (ISO 8601)ไม่กรองคำสั่งซื้อที่สร้างหลังวันที่นี้2024-01-01T00:00:00Z
created_beforestring (ISO 8601)ไม่กรองคำสั่งซื้อที่สร้างก่อนวันที่นี้2024-12-31T23:59:59Z
คำขอ
curl -s "https://shop2topup.com/api/endpoints/v1/orders?page=1&limit=50&status=completed&created_after=2024-01-01T00:00:00Z&created_before=2024-12-31T23:59:59Z" \
  -H "Authorization: Bearer YOUR_KEY_ID.YOUR_KEY_SECRET"
ตัวอย่างการตอบกลับ
{
  "success": true,
  "orders": [
    {
      "order_id": "01912345-6789-7abc-8def-0123456789ab",
      "status": "completed",
      "subcategory_name": "FF 100 Diamonds",
      "quantity": 1,
      "charged_amount": "0.950000",
      "created_at": "2024-06-15T12:00:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 1,
    "total_pages": 1
  }
}

ส่งคำขอจริงจากหน้านี้

วางคีย์ API เพื่อเรียก endpoint เหล่านี้จริง คีย์จะอยู่ในแท็บเบราว์เซอร์นี้ และส่งไปที่ตัว API เท่านั้น

Enter your API key to use the interactive playground. Get your API key

เลือกเอนด์พอยต์

1
2
Order Details

Enter your API key above to try this endpoint.

หากเพิ่งเริ่มใช้แพลตฟอร์ม เริ่มที่หน้าภาพรวม API เติมเกมสำหรับตัวแทนจำหน่าย หรืออ่านภาพรวมโปรแกรมตัวแทนจำหน่ายของ SHOP2TOPUP เพื่อดูว่าบัญชีพาร์ทเนอร์ใช้งานอย่างไร

API คำสั่งซื้อ: สร้าง ดึงข้อมูล ดึงแบบชุด และแสดงรายการคำสั่งซื้อ