Billing API (User)#

Quản lý đơn hàng, thanh toán, và voucher cho người dùng.

Base URL: https://apitest.likepion.com/api/v1 Auth: JWT Token (Authorization: Bearer <token>)


POST /orders — Tạo đơn hàng #

Request:

{
  "package_id": "uuid",                         // required
  "payment_method": "qrcode",                   // required, oneof: qrcode, paypal, bank
  "coupon_code": "SALE50"                        // optional
}

Response (201):

{
  "success": true,
  "data": {
    "id": "uuid",
    "order_code": "ORD-20250601-ABC123",
    "package_name": "Basic",
    "credits": 500,
    "original_price": 100000,
    "discount": 50000,
    "final_amount": 50000,
    "payment_method": "qrcode",
    "status": "pending",
    "qr_url": "https://maxqr.scapbot.net/api/v1/qr/...",
    "created_at": "2025-06-01T00:00:00Z"
  }
}

GET /orders/pending — Đơn hàng đang chờ #

Trả về đơn pending của user hoặc null.


GET /orders/:id — Chi tiết đơn hàng #

Response: Full order object gồm id, order_code, user_id, package_name, package_credits, package_price, original_price, discount, final_amount, credits, coupon_code, payment_method, status, note, approved_at, approved_by, created_at, updated_at.


POST /orders/:id/confirm — Xác nhận đã thanh toán #

Response:

{"success": true, "data": {"message": "payment confirmed, waiting for admin approval"}}

POST /orders/:id/cancel — Hủy đơn #

Response:

{"success": true, "data": {"message": "order cancelled"}}

PayPal#

POST /orders/:id/paypal — Tạo PayPal Order #

Response:

{
  "success": true,
  "data": {
    "paypal_order_id": "PAYPAL-ORDER-ID",
    "approve_url": "https://www.paypal.com/checkoutnow?token=..."
  }
}

POST /orders/:id/paypal/capture — Capture Payment #

Request:

{
  "paypal_order_id": "PAYPAL-ORDER-ID"
}

Response:

{"success": true, "data": {"message": "payment completed", "credits_added": 500}}

GET /transactions — Lịch sử giao dịch #

Query: page (mặc định 1), limit (mặc định 20), type (credit/debit)

Response:

{
  "success": true,
  "data": [
    {
      "id": "uuid",
      "type": "credit",
      "credits": 500,
      "balance_after": 1500,
      "description": "Package purchase - Basic",
      "status": "completed",
      "reference_type": "order",
      "reference_id": "uuid",
      "created_at": "2025-06-01T00:00:00Z"
    }
  ],
  "total": 50,
  "page": 1,
  "limit": 20
}

POST /vouchers/validate — Kiểm tra voucher #

Request:

{
  "code": "SALE50"    // required
}

Response (200): Full voucher object gồm id, code, discount_type (percent/fixed), discount_value, max_uses, used_count, min_order_amount, status, expires_at.