API ตัวแทนจำหน่าย eSIMDual

ใช้ API สำหรับตัวแทนจำหน่าย eSIMDual ในเว็บไซต์หรือแอปของคุณเอง

เอกสารนี้ครอบคลุม API สำหรับระบบใช้งานจริงและระบบทดสอบ ได้แก่ การยืนยันตัวตน แพ็กเกจสาธารณะ การซื้อ การส่งมอบ eSIM การใช้งาน การเติมเงินที่รองรับ การยกเลิก eSIM ที่ยังไม่ใช้ การคืนเงิน ข้อมูลกระเป๋าเงิน และเว็บฮุกที่มีลายเซ็น

เริ่มต้นอย่างรวดเร็ว
  • 1เริ่มทดสอบอย่างปลอดภัยด้วย POST /sandbox/login
  • 2ส่งโทเค็น Bearer ไปยังปลายทางที่ได้รับการป้องกันทั้งหมด
  • 3ใช้ Idempotency-Key กับทุกการซื้อ การเติมเงิน และการยกเลิก
  • 4เปลี่ยนไปใช้ระบบจริงหลังจากตัวแทนจำหน่ายได้รับอนุมัติแล้วเท่านั้น
URL พื้นฐาน https://esimdual.com/api/reseller/v1
URL ระบบทดสอบ https://esimdual.com/api/reseller/v1/sandbox
การตรวจสอบสิทธิ์ Authorization: Bearer <token>
ภาวะเสื่อมสมรรถภาพทางเพศ Idempotency-Key: unique-order-key
ความปลอดภัยของระบบทดสอบ

คำสั่งซื้อในระบบทดสอบใช้ยอดคงเหลือสมมติและ eSIM จำลอง ระบบจะไม่เรียกผู้ให้บริการต้นทางและไม่หักเงินจากกระเป๋าเงินจริง ใช้ endpoint จำลองเพื่อทดสอบสถานะติดตั้งแล้ว ใช้งานอยู่ และใช้หมดแล้ว จากนั้นตรวจสอบขั้นตอนคืนเงินที่อนุมัติ ปฏิเสธ และรอตรวจสอบด้วยตนเอง

curl --request POST 'https://esimdual.com/api/reseller/v1/sandbox/login' \
  --header 'Content-Type: application/json' \
  --data '{"email":"partner@example.com","password":"YOUR_PASSWORD","device_name":"sandbox-ci"}'
ตัวอย่างคำขอเข้าสู่ระบบ
curl --request POST 'https://esimdual.com/api/reseller/v1/login' \
  --header 'Content-Type: application/json' \
  --data '{
    "email": "partner@example.com",
    "password": "StrongPassword123!",
    "device_name": "production-server",
    "expires_in_days": 90
  }'
ตัวอย่างใบสั่งซื้อ
curl --request POST 'https://esimdual.com/api/reseller/v1/orders' \
  --header 'Authorization: Bearer YOUR_TOKEN' \
  --header 'Idempotency-Key: ORDER-2026-0001' \
  --header 'Content-Type: application/json' \
  --data '{
    "package_id": 1120,
    "external_order_id": "NOANET-2026-0001",
    "device_imei": "356938035643809"
  }'
ขั้นตอนการเติมเงินที่รองรับ
GET /esims/{id}/topup-options

POST /topups
Idempotency-Key: TOPUP-2026-0001
{
  "esim_id": "{id}",
  "package_id": 456
}
การยกเลิก eSIM ที่ยังไม่ใช้
POST /esims/{id}/cancel
Idempotency-Key: CANCEL-2026-0001

Automatic refund only when the supplier confirms:
- zero usage
- never installed
- never activated
- no completed recharge exists
- original wallet debit is verified

เหตุการณ์ Webhook

eSIMDual ลงลายเซ็น timestamp.raw_payload ด้วย HMAC SHA-256 ข้อมูลลับสร้างโดย eSIMDual และจะแสดงเฉพาะหลังการสร้างหรือการหมุนเวียนเท่านั้น ให้ปฏิเสธการประทับเวลาที่เก่ากว่าห้านาทีและกำจัดรายการซ้ำด้วย X-eSIMDual-Delivery

ping order.completed order.processing order.failed topup.completed topup.processing topup.failed esim.cancelled refund.completed refund.failed
X-eSIMDual-Event
X-eSIMDual-Delivery
X-eSIMDual-Timestamp
X-eSIMDual-Signature: v1=…
การตรวจสอบลายเซ็น PHP
$rawBody = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_X_ESIMDUAL_TIMESTAMP'] ?? '';
$received = $_SERVER['HTTP_X_ESIMDUAL_SIGNATURE'] ?? '';
$fresh = ctype_digit($timestamp) && abs(time() - (int) $timestamp) <= 300;
$expected = 'v1=' . hash_hmac('sha256', $timestamp . '.' . $rawBody, $webhookSecret);

if (!$fresh || !hash_equals($expected, $received)) {
    http_response_code(401);
    exit('Invalid or stale signature');
}

จัดเก็บค่า X-eSIMDual-Delivery แต่ละค่าและปฏิเสธการส่งซ้ำ ส่งกลับการตอบกลับ HTTP 2xx หลังจากยอมรับเหตุการณ์แล้วเท่านั้น

Nous pouvons utiliser des cookies ou toute autre technologie de suivi lorsque vous visitez notre site web, ainsi que tout autre support, site web mobile ou application mobile lié ou connecté, afin de personnaliser le Site et d’améliorer votre expérience. เรียนรู้เพิ่มเติม

อนุญาต