Errors
The error format, every error code, and which errors to retry.
Format
Every error is JSON with an HTTP status:
{
"error": {
"code": "invalid_amount",
"message": "QRIS amounts are whole rupiah from 1000 to 10000000."
}
}- Act on
code: it is stable. messageis for people (logs, your support team) and may change. Do not parse it.
Which errors to retry
| Answer | What to do |
|---|---|
| No answer (timeout, connection error) | Retry with the same Idempotency-Key. |
429 rate_limited | Wait for the seconds in Retry-After, then retry. |
409 idempotency_in_progress | Retry the same request after a moment. |
500 internal_error | Retry with the same Idempotency-Key. |
502 payment_unavailable | Do not retry. Create a new payment with a new Idempotency-Key, or offer another method. |
Any other 4xx | Do not retry as it is. Fix the request, the key or the setting the code names. |
See Idempotency.
const res = await fetch('https://pay.piti.id/v1/payments', { /* ... */ });
const body = await res.json();
if (!res.ok) {
switch (body.error.code) {
case 'method_disabled':
// switch the method on in the dashboard, or offer another one
break;
case 'payment_unavailable':
// create a new payment with a new Idempotency-Key
break;
default:
console.error(res.status, body.error.code, body.error.message);
}
}All codes
| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | invalid_request | A field is missing, the wrong type or out of range; message names it. | Fix the request. |
| 400 | invalid_amount | The amount is not whole rupiah, or outside the method's range (QRIS, virtual account; a virtual account total with a customer-paid fee over the limit). | Change the amount or the method. |
| 422 | invalid_amount | A refund is more than what is left to refund. | Refund less. |
| 400 | method_unknown | method or va_bank is not one we know. | Use qris, va (with mandiri, bri, bni, bsi, cimb, permata, maybank or danamon) or any. |
| 400 | idempotency_key_required | A POST that creates something was sent without Idempotency-Key. | Add the header. |
| 401 | unauthorized | No API key, or a key that is wrong or revoked. | Check the key and its mode (lbp_test_ / lbp_live_). |
| 403 | account_suspended | Your business is suspended. | Contact us. |
| 403 | live_not_enabled | A live key, but live payments are not on for your business (verification not approved yet). | Use a test key, or finish business verification. |
| 403 | app_disabled | This key's app is turned off in the dashboard (Developer). Its webhooks wait. | Turn the app on. |
| 404 | not_found | No such payment, refund, event, plan or subscription for this key. Another app's, another mode's and another business's are all "not found". | Check the id and the key. |
| 404 | no_webhook | GET /v1/webhooks: no webhook URL is set for this app and mode. | Set one in the dashboard. |
| 409 | no_webhook | A test event or a resend, but no webhook URL is set. | Set a webhook URL first. |
| 409 | compat_active | A test event while a Xendit or Duitku compatibility mode owns this app's callback (it has no test event). | Turn the compatibility mode off to use our own webhooks. |
| 409 | idempotency_in_progress | The first request with this Idempotency-Key is still running. | Retry the same request after a moment. |
| 409 | method_disabled | The method is switched off for this app, or (method: any) no switched-on method takes this amount. | Switch it on in the dashboard (Metode pembayaran), or pick another. |
| 409 | not_payable | The payment is no longer waiting for payment (paid, expired or failed). | Create a new payment. |
| 409 | not_qris | A new QR was asked for a payment that has none (a virtual account). | Use the virtual account number. |
| 409 | method_not_chosen | Simulating a method: any payment before the customer picked a method, where it cannot be picked for you. | Pick a method on the payment page first. |
| 409 | simulation_unavailable | Only test payments can be simulated, and this one cannot (a live payment, or a test payment your account sends to the provider's sandbox). | Simulate test payments only. If every test payment gets this, contact us. |
| 409 | not_refundable | Only paid payments can be refunded; or the payment is under review. | Check the status; contact us for one under review. |
| 409 | plan_inactive | Subscribing to a plan that is switched off. | Switch the plan on. |
| 409 | subscription_active, subscription_paused, subscription_cancelled, subscription_completed | The action does not fit the subscription's status (resume an active one, pause a cancelled one, ...). The code names the current status. | Read the subscription first. |
| 409 | app_disabled | Creating a payment, plan or subscription for an app that is turned off (from the dashboard). | Turn the app on. |
| 413 | body_too_large | The request body is too large. | Send less (payments: up to 64 KB). |
| 422 | idempotency_mismatch | The Idempotency-Key was used before with a different body. | Use a new key for a new request. |
| 422 | insufficient_balance | A refund needs your unsettled balance to cover it, and it does not. | Wait for new payments, or contact us. |
| 422 | method_unavailable | Virtual accounts are not available yet for your business. | Use QRIS. |
| 429 | rate_limited | Over 120 requests a minute for this key. | Back off; see Retry-After. |
| 500 | internal_error | Our error. The request may not have been applied. | Retry with the same Idempotency-Key. |
| 502 | payment_unavailable | The QR or virtual account could not be made. Nothing was charged; no customer saw it. | Create a new payment (new Idempotency-Key), or try another method. |