Skip to content
SDK preview. Packages are not publicly published yet — use REST / cURL, or the local development artifacts.

Errors

The error format, every error code, and what to send support.

Errors use standard HTTP status codes and one JSON shape:

JSON
{
  "error": {
    "code": "external_id_conflict",
    "message": "A payment with this external_id already exists for this business.",
    "param": "external_id",
    "request_id": "req_1df6dd76-0350-479c-a234-e16d63b0f78b"
  }
}
  • code is stable and machine-readable — switch on it. New codes can be added, so keep a default branch.
  • message is for humans and may change.
  • param names the offending field when there is one.
  • request_id — include it when you contact support. It lets us find the exact request.

The SDK raises typed errors (PayTakaValidationError, PayTakaAuthenticationError, PayTakaRateLimitError, PayTakaIdempotencyError, PayTakaAPIError, PayTakaNetworkError), each with code, message, param, requestId and httpStatus.

Handling an error#

JavaScript
import { PayTakaAPIError } from "@paytaka/sdk"

try {
  await paytaka.payments.create({ amount: 500 })
} catch (error) {
  if (error instanceof PayTakaAPIError) {
    console.error(error.code, error.requestId)
  }
}

Not sure what a code means? See Troubleshooting.

Error codes#

CodeHTTPMeaning
invalid_api_key401The API key is missing, malformed, unknown, or revoked.
insufficient_scope403The key lacks the scope (payments:read or payments:write) this endpoint needs.
rate_limit_exceeded429Too many requests for this key. Honor the Retry-After header.
invalid_request400The request body or a parameter is malformed.
invalid_amount400amount must be a positive decimal string with at most two decimals, e.g. "500.00".
invalid_external_id400external_id is invalid or too long.
invalid_metadata400metadata exceeds its limits (20 keys, 64-char keys, 500-char values).
invalid_return_url400return_url must be an absolute https URL or a native app deep link.
invalid_allowed_method400allowed_methods must only name BKASH or NAGAD.
invalid_allowed_channel400allowed_channels must only name SEND_MONEY, PAYMENT, CASH_IN or BANK_TRANSFER.
description_too_long400description is too long.
reference_too_long400merchant_reference is too long.
invalid_customer400customer_id does not belong to your business.
order_not_found400order_id does not exist for your business.
order_customer_mismatch400The payment's customer does not match the order's customer.
exceeds_order_due400amount exceeds the order's remaining due.
context_items_not_accepted400context_items are not accepted by the Developer API.
payment_not_found404No hosted payment with this id exists for this key's business and environment.
not_found404No such API route.
method_not_allowed405The HTTP method is not allowed for this route.
external_id_conflict409A payment with this external_id already exists (per business and environment).
idempotency_conflict409This Idempotency-Key was already used with a different request.
idempotency_in_progress409A request with this Idempotency-Key is still being processed; retry shortly.
invalid_transition409The payment is not in a state that allows this action (for example, cancelling a paid payment).
order_cancelled409The referenced order is cancelled.
payment_method_unavailable409None of the allowed payment methods are currently usable (live mode).
payment_channel_unavailable409No ready receiving number accepts the requested payment type (live mode).
payment_detection_not_ready409The business has no enabled, ready receiving method yet (live mode).
insufficient_credit409The business does not have enough Service Credit for the next fee (live mode).
internal_error500Something went wrong on PayTaka's side. Retry; quote request_id to support if it persists.

Retrying#

Retry only what is safe. 429 (rate limit — wait for Retry-After) and 5xx are retryable; other 4xx errors are not — fix the request. Always retry a create with the same Idempotency-Key (the SDK does this for you). See Idempotency.