Wallet balance နဲ့ product ဝယ်ယူခြင်း၊ order result စစ်ခြင်းအတွက် REST API
DigiZay Reseller API ကို ဘာအတွက် သုံးလဲ?
Wallet balance နဲ့ DigiZay ပစ္စည်းစာရင်းကို စက်အလိုအလျောက် ဝယ်ယူပြီး order result ပြန်ယူဖို့ သုံးပါတယ်။ အရင်ဆုံး GET /services ကိုခေါ်ပြီး response ထဲက လက်ရှိ product ID နဲ့ stock ကို သုံးပါ။ ဝယ်ယူမည့်အချိန်တွင် လက်ရှိဈေးနှုန်းနှင့် ရရှိနိုင်မှုကို ပြန်စစ်ပါ။
Base URL နဲ့ Authentication
Base URL က https://digizay.com/api/v1 ဖြစ်ပြီး request တိုင်းမှာ X-Api-Key: dz_your_key_here header ပို့ရပါတယ်။ API key ကို Telegram store သို့မဟုတ် Dashboard API tab မှာ တစ်ကြိမ်သာ ရယူနိုင်ပါတယ်။
Reseller REST also accepts Authorization: Bearer dz_.... Keep keys out of URLs.
AI assistants (MCP)
Manually connect to https://digizay.com/api/shop/mcp using Streamable HTTP. Guests need no key. Optional Authorization: Bearer dzm_... from Dashboard > API links orders to your account and cannot spend wallet balance. MCP purchases use MMQR after explicit confirmation. See the Shopping MCP setup guide.
အဓိက endpoints
GET /balance — လက်ရှိ Wallet balance
GET /services — ဝယ်နိုင်တဲ့ product ID၊ စျေးနှုန်းနဲ့ stock
Keep API keys out of URLs. Use the X-Api-Key header for GET and POST. Authorization: Bearer dz_... is also accepted by the reseller REST API.
Game ID and account-name checks use the v2 quote flow. See Game ID & account name check; this is not a v1 endpoint.
Endpoints
GET /balance
JSON
{
"balance": 25000,
"currency": "MMK"
}
GET /services
price includes the effective product/provider-capped discount. Use the returned id for /order; 123 below is only an example. Use requiredInputs for the destination fields; phone is required when telecom is true.
Debits balance and delivers. Telecom packs need phone (09… / Mytel 096… / ATOM 097…).
Send product, qty and the product’s requiredInputs in an inputs object (or phone) in a JSON request body. Each purchase needs a unique Idempotency-Key (8–128 letters/numbers, ., _, :, -). Retry the same purchase with the same key and identical parameters. Use a new key only for a new purchase.
Heartopia needs UID as gameId and a serverId: Global, SEA, America, Asia or TW,HK,MO. Use the package ID returned by /services, quantity 1. Do not combine inputs with phone/link.
Set up an HTTPS receiver in Dashboard → API → Order webhooks, or use these authenticated endpoints. One endpoint per account; only future REST API order events are queued while enabled.
HTTP
GET /api/v1/webhook
PUT /api/v1/webhook
DELETE /api/v1/webhook
POST /api/v1/webhook/rotate-secret
POST /api/v1/webhook/test
GET /api/v1/webhook/deliveries?before=123
POST /api/v1/webhook/deliveries/:id/retry
Use X-Api-Key as above. Create with the body below; on updates, disable or rotation include the current integer version from GET. The signingSecret is returned once on creation or rotation; store it securely. Updates cancel pending deliveries for the old configuration.
Your receiver gets POST JSON with these fields. No login credentials, delivered keys, phone numbers or API keys are included. Use the owned-order endpoint to fetch the current result when needed. Test events have type webhook.test and data: {"test":true}.
Refund events also include refundMmk. A paid event means wallet payment was accepted, not that delivery has finished. A refund and a cancellation can arrive separately. Return 2xx quickly after durably accepting an event; process it asynchronously.
Signatures use Standard Webhooks: webhook-id, webhook-timestamp (Unix seconds), and webhook-signature (v1,BASE64). Verify HMAC-SHA256 of id.timestamp.rawBody using the base64-decoded key after removing whsec_. Verify before parsing or acting on the body.
JavaScript
import crypto from 'node:crypto';
// rawBody must be the original request bytes, before JSON parsing.
const id = req.headers['webhook-id'];
const ts = req.headers['webhook-timestamp'];
const sig = req.headers['webhook-signature'];
if (!/^evt_[1-9]\d*$/.test(id || '') || !/^\d+$/.test(ts || '') ||
Math.abs(Date.now()/1000 - Number(ts)) > 300) throw Error('Stale event');
const key = Buffer.from(process.env.DIGIZAY_WEBHOOK_SECRET.slice(6), 'base64');
const expected = crypto.createHmac('sha256', key)
.update(id + '.' + ts + '.').update(rawBody).digest();
const actual = Buffer.from(String(sig).replace(/^v1,/, ''), 'base64');
if (!String(sig).startsWith('v1,') || actual.length !== expected.length ||
!crypto.timingSafeEqual(actual, expected)) throw Error('Invalid signature');
// Atomically record id as processed; acknowledge duplicates without reprocessing.
Delivery is at least once; deduplicate by event ID. Retries keep the event ID and body, with a fresh signature timestamp. Up to 8 automatic attempts, with backoff, expire after 48 hours; a failed delivery allows up to 3 manual retries within that window. Delivery history is retained for 30 days. Do not assume event order; read the current order status before applying an older update.
Only public HTTPS destinations on port 443 are allowed. Redirects are not followed. Requests time out after 5 seconds, with a 64 KiB response limit. A request already in flight may finish after you disable or rotate. Tests and retries only send events; they never create orders or debit/refund wallets.
Errors
400
Invalid product, qty, or phone
401
Missing or invalid API key
404
Order not found
409
Idempotency key reused with different parameters, or request still processing. Keep the original key; do not start another purchase. DUPLICATE_ORDER: a U9 pack for this number was ordered in the last 5 minutes (U9 rejects it as a duplicate); nothing was charged, retry after Retry-After seconds.
429
Rate limit (default 60 / min) or CHECKOUT_BUSY. Respect Retry-After and retry the same purchase with its original Idempotency-Key and body.