Skip to main content

POST - Create Invoice

Create a crypto payment invoice. Merchant sends the amount (USD), order information, and callback URL; the system returns trans_id and url_payment to redirect the customer to the checkout page.

Endpoint

POST https://api.payerscan.com/payment/crypto

Headers

HeaderRequiredDescription
Content-TypeYesapplication/json
x-api-keyYesStore's API Key

Request Body (JSON)

FieldTypeRequiredConstraintsDescription
merchant_idstringYesNon-emptyStore's merchant code (must match the API Key).
amountnumber | stringYes> 0 and ≤ 1,000,000Payment amount (USD). Example: 100, "100".
callback_urlstringRecommendedMax 500 chars, valid URLURL to receive webhook on completed or expired status.
completed_urlstringNoMax 500 chars, valid URLRedirect URL after successful payment.
expired_urlstringNoMax 500 chars, valid URLRedirect URL when the invoice expires.
namestringNoMax 255 charsInvoice name/title.
descriptionstringNoMax 1000 charsInvoice description.
request_idstringNoMax 255 charsMerchant's order ID for cross-reference (returned in response and webhook). Also used for idempotency — see notes below.

Example Request

{
"merchant_id": "MID-XXXXXXXXXX",
"amount": 100,
"name": "Top-up balance",
"description": "Top-up the balance for username: [USERNAME]",
"callback_url": "https://your-server.com/webhook/payment",
"completed_url": "https://your-website.com/thank-you",
"expired_url": "https://your-website.com/",
"request_id": "ORDER_123456"
}

Response

Success (HTTP 200)

{
"status": "success",
"data": {
"request_id": "ORDER_123456",
"trans_id": "TID-ABC123DEF4567890",
"status": "waiting",
"amount": "100",
"url_payment": "https://app.payerscan.com/bill/TID-ABC123DEF4567890",
"expires_in_minutes": 15
}
}
FieldDescription
request_idThe value you sent in the request.
trans_idUnique invoice code, used for lookup and webhook cross-reference.
statusAlways "waiting" when newly created.
amountUSD amount (string).
url_paymentCheckout page URL — redirect the customer here.
expires_in_minutesInvoice expiration time (minutes).

Errors (4xx / 5xx)

All errors follow this format:

{
"status": "error",
"message": "Error description",
"error_code": "ERROR_CODE",
"request_id": "ORDER_123456",
"details": { }
}
HTTPerror_codeDescription
400VALIDATION_ERRORInvalid body (missing required fields, wrong type, exceeding constraints). details.errors has specifics.
400INVALID_MERCHANT_IDmerchant_id doesn't match the Store's API Key.
400NO_PAYMENT_METHODStore has no configured payment method. Add at least one wallet address or configure an exchange platform before creating invoices.
401MISSING_API_KEYNo x-api-key header provided.
401INVALID_API_KEYThe API key is invalid or does not exist.
403ACCOUNT_INACTIVEThe account associated with this API key is disabled.
403STORE_INACTIVEThe store associated with this API key is disabled.
402INSUFFICIENT_BALANCEStore balance insufficient for fees. details has current_balance, required_fee, shortage, fee_rate_percent, discount_percent, invoice_amount.
429RATE_LIMIT_EXCEEDEDExceeded request limit (burst or sustained). Has limit_type, retry_after_seconds.
500INTERNAL_ERRORServer error.

Error code details: API Error Codes.

Rate Limit

  • Burst: 5 requests/second (per API Key or IP).
  • Sustained: 60 requests/minute (per API Key or IP).

Exceeding limit → HTTP 429, body has error_code: "RATE_LIMIT_EXCEEDED", retry_after_seconds.

Notes

  • Payment method: Store must configure at least one wallet address or exchange platform (Binance Pay, OKX, Bybit, MEXC, Gate.io, Bitget, etc.) before creating invoices. If none configured, API returns NO_PAYMENT_METHOD error.
  • Idempotency: If you send a request_id that already exists for the same store, API returns the existing invoice instead of creating a new one. The response will include idempotent: true to indicate this. This prevents duplicate invoices when retrying failed requests.
  • Fees: Fees are calculated on amount (USD) and deducted from the Store's balance. Ensure sufficient balance before creating invoices. During the free trial period, fees are waived.
  • Callback: Always send callback_url to receive completed/expired webhooks; without it, you can only check via GET https://api.payerscan.com/invoice/:trans_id.
  • request_id: Recommended to send for easy webhook-to-order matching and idempotency support.