TÀI LIỆU

API đại lý CrizonShop

Bán hàng số CrizonShop trên web, bot hoặc shop Zalo của bạn. Tất cả là JSON; khoá thử bắt đầu bằng czs_test_, khoá thật bằng czs_live_.

1. Xác thực

Gửi khoá trong header Authorization. Không dùng cookie, không dùng CSRF. Mỗi khoá có quyền đọc và đặt hàng, giới hạn 60 lượt đọc/phút và 20 lượt đặt/phút.

Authorization: Bearer czs_live_...

2. Lệnh

MethodPathViệc
GET/api/partner/v1/meSố dư, bậc, hạn mức
GET/api/partner/v1/productsBảng giá và input schema
POST/api/partner/v1/ordersĐặt hàng, chờ tối đa 50s
GET/api/partner/v1/orders/{code}Trạng thái và hàng đã giao
GET/api/partner/v1/price-list?token=…&format=csv|jsonLink bảng giá chỉ đọc

3. Lấy bảng giá

curl https://crizonshop.com/api/partner/v1/products?limit=20 \
  -H "Authorization: Bearer czs_live_..."

# response
{
  "products": [{
    "plan_id": "cmw...",
    "name": "Adobe Express Premium",
    "plan": "12 Tháng",
    "retail_price": 89000,
    "price": 84600,
    "currency": "VND",
    "level": { "name": "Bậc 1", "discount_percent": 5 },
    "input_schema": [],
    "delivery": { "eta_seconds": 26, "eta_p95_seconds": 40, "success_rate": 0.9 }
  }]
}

Giá trả về đã là giá đại lý. Sàn lãi là vốn ÷ 0,9, làm tròn lên 100đ; gói có sàn trên giá lẻ sẽ không mở.

4. Đặt hàng

curl https://crizonshop.com/api/partner/v1/orders \
  -H "Authorization: Bearer czs_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "plan_id": "cmw...",
    "quantity": 1,
    "external_ref": "DH-1042",
    "inputs": { "email": "[email protected]" },
    "wait": 50,
    "max_price": 90000
  }'

# delivered in time
{ "order_code": "API-20261127-AAAAAA", "status": "delivered",
  "total": 84600, "currency": "VND", "balance_after": 915400,
  "items": [{ "plan_id": "cmw...", "quantity": 1, "price": 84600,
    "delivered": { "username": "...", "password": "...", "license_key": null, "note": null } }] }

# not in time
{ "order_code": "API-20261127-BBBBBB", "status": "processing",
  "total": 84600, "currency": "VND", "balance_after": 830800 }
  • external_ref là khoá chống trùng; gửi lại cùng mã trả lại đơn cũ.
  • max_price bảo vệ bạn nếu giá tăng giữa chừng; giá vượt mức bị từ chối, không trừ tiền.
  • Đơn không kịp trong wait trả processing; webhook báo khi giao xong.

5. Webhook

Đặt URL trong tài khoản API. Mỗi lần gửi có chữ ký HMAC-SHA256; kiểm chữ ký trước khi dùng.

X-Crizon-Event: order.delivered
X-Crizon-Event-Id: partner-webhook:<partner>:order.delivered:<order>
X-Crizon-Timestamp: 1795776000
X-Crizon-Signature: sha256=<HMAC-SHA256(secret, timestamp + "." + rawBody)>

payload: { "event":"order.delivered", "event_id":"...",
  "data": { "order_code":"API-...", "status":"delivered",
            "total":84600, "currency":"VND", "items":[...] } }

Payload không chứa mật khẩu/hàng; gọi GET /orders/{code} để lấy hàng. Gửi lại 5 lần trong 24 giờ; event_id để chống trùng.

6. Mã lỗi thường gặp

INSUFFICIENT_BALANCE (402)
Ví không đủ VND.
PARTNER_NOT_QUALIFIED (403)
Khoá LIVE cần đủ 1.000.000đ và điều khoản.
PLAN_NOT_AVAILABLE (422)
Gói đóng, chưa có vốn hoặc dưới sàn.
PRICE_ABOVE_MAX (409)
Giá vượt max_price.
DAILY_SPEND_LIMIT (429)
Chạm trần chi ngày.
PLAN_DAILY_LIMIT (429)
Chạm trần đơn của gói.

7. Mẫu PHP

<?php
$key = getenv('CRIZON_PARTNER_KEY');
$ch = curl_init('https://crizonshop.com/api/partner/v1/products');
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["Authorization: Bearer $key"],
]);
$json = json_decode(curl_exec($ch), true);
curl_close($ch);
foreach ($json['products'] as $p) {
  echo $p['name'], ' — ', $p['price'], "đ\n";
}