Errors
A failed request returns an error object, and its type determines how to handle it. The HTTP status is 4xx when the request can’t be completed, such as a missing parameter or a declined card, and 5xx when the error is on Bias’s side.
Invalid request errors that an integration can handle have a code. Payment errors have a decline_code, listed in decline codes.
An error’s message is written for developers. customer_message is safe to show to the customer, such as for a card decline or an expired discount code, and is null when Bias has no customer wording for the error.
The request-id response header identifies the request. Include it when you contact support.
The Error object
The request can't be processed as sent, such as when a parameter is missing or invalid, or the object's current state doesn't allow the action. param names the parameter at fault.
- Name
object
- Type
- "error",
- Description
- The object's type.
- Name
error
- Type
- object,
- Description
- Details about the error.
- Properties
- Name
type
- Type
- "invalid_request_error",
- Name
live
- Type
- boolean or null,
- Description
truefor a live request,falsefor a sandbox request, ornullif the request wasn't authenticated as a merchant.- Name
code
- Type
- enum or null,
- Description
- A code for errors an integration can handle.
- Properties
- Name
message
- Type
- string,
- Description
- A message about the error, written for developers.
- Name
customer_message
- Type
- string or null,
- Description
- A message about the error that's safe to show to the customer.
- Name
param
- Type
- string or null,
- Description
- The request parameter the error relates to.
or
The payment method was declined or couldn't be charged. decline_code says why, and the decline codes table says what to do about each. When set, customer_message can be shown to the customer.
- Name
object
- Type
- "error",
- Description
- The object's type.
- Name
error
- Type
- object,
- Description
- Details about the error.
- Properties
- Name
type
- Type
- "payment_error",
- Name
live
- Type
- boolean or null,
- Description
truefor a live request,falsefor a sandbox request, ornullif the request wasn't authenticated as a merchant.- Name
code
- Type
- null,
- Name
decline_code
- Type
- enum or null,
- Description
- Why the payment was declined, as a decline code.
- Properties
- Name
network_decline_code
- Type
- string or null,
- Description
- The decline code from the payment network.
- Name
message
- Type
- string,
- Description
- A message about the error, written for developers.
- Name
customer_message
- Type
- string or null,
- Description
- A message about the error that's safe to show to the customer.
- Name
param
- Type
- string or null,
- Description
- The request parameter the error relates to.
- Name
payment
- Type
- Payment or null,
- Description
- The declined payment.
or
The idempotency key can't be used for this request: it belongs to a different request, the first request with it is still running, or that request's outcome is unknown. code says which.
- Name
object
- Type
- "error",
- Description
- The object's type.
- Name
error
- Type
- object,
- Description
- Details about the error.
- Properties
- Name
type
- Type
- "idempotency_error",
- Name
live
- Type
- boolean or null,
- Description
truefor a live request,falsefor a sandbox request, ornullif the request wasn't authenticated as a merchant.- Name
code
- Type
- enum or null,
- Properties
- Name
message
- Type
- string,
- Description
- A message about the error, written for developers.
- Name
customer_message
- Type
- string or null,
- Description
- A message about the error that's safe to show to the customer.
- Name
param
- Type
- null,
or
An IP address sent more than 1,000 requests in 10 seconds. The response has status 429 and a Retry-After header with the seconds until the next window. The rate limits page covers the headers.
- Name
object
- Type
- "error",
- Description
- The object's type.
- Name
error
- Type
- object,
- Description
- Details about the error.
- Properties
- Name
type
- Type
- "rate_limit_error",
- Name
live
- Type
- boolean or null,
- Description
truefor a live request,falsefor a sandbox request, ornullif the request wasn't authenticated as a merchant.- Name
code
- Type
- null,
- Name
message
- Type
- string,
- Description
- A message about the error, written for developers.
- Name
customer_message
- Type
- string or null,
- Description
- A message about the error that's safe to show to the customer.
- Name
param
- Type
- null,
or
Something went wrong on Bias's side. The request can be retried with backoff, but a retry with the same idempotency key returns the same error, so it needs a new key. Support can look up the request by its request-id header.
- Name
object
- Type
- "error",
- Description
- The object's type.
- Name
error
- Type
- object,
- Description
- Details about the error.
- Properties
- Name
type
- Type
- "server_error",
- Name
live
- Type
- boolean or null,
- Description
truefor a live request,falsefor a sandbox request, ornullif the request wasn't authenticated as a merchant.- Name
code
- Type
- null,
- Name
message
- Type
- string,
- Description
- A message about the error, written for developers.
- Name
customer_message
- Type
- string or null,
- Description
- A message about the error that's safe to show to the customer.
- Name
param
- Type
- null,
or
Handling errors
- Retry a
rate_limit_errorafter the number of seconds in itsRetry-Afterheader. - Retry a
server_errorwith exponential backoff. - For a
payment_error, the decline code says whether to retry or ask the customer for another payment method.
An idempotency key makes it safe to retry a request after a network failure.
Errors in the SDKs
The Python SDK raises a typed exception for each error type, and the Rust SDK returns Err(biaspay::Error::Api(_)).
The TypeScript SDK returns API errors as values, typed as a union with the successful response. Only network and other fetch errors are thrown.
Warning
res.object === "error") before using its properties.