Error handling

SDK errors

Exactly what happens in each scenario when using the SDK solution is described in more detail in the "Making a payment" section of the SDK documentation.

Invalid card information errors: The onInvalidCard callback is called.

Errors occurring before 3DS step: The onFailurecallback is called.

Errors occurring during 3DS step: End user is redirected to the redirectOnFailUrl set in the payment creation request. A query parameter called errorCode will be appended to the redirect URL, for example: https://stage-b2b.payer.se/fail?errorCode=DECLINED .

Redirect widget errors

When things go wrong when using the widget in redirect mode, the user will be redirected to the redirectOnFailUrl set in the payment creation request, once they click the 'Cancel' button. A query parameter called errorCode will be appended to the redirect URL, for example: https://stage-b2b.payer.se/fail?errorCode=DECLINED .

Embedded widget errors

When things go wrong when using the widget in embedded mode, messages will be posted to the parent page once the user clicks the 'Cancel' button. See message types and examples for more details.

API errors

For cards, the errors can be a little different from other Payer endpoints. Below is described the general errors as well as the special cases for cards.

Details on the card endpoints are found in API documentation.

General

Payer uses HTTP response status codes to indicate the success or failure of your API requests. If your request fails, Payer returns an error using the appropriate status code.

In general, there are three status code ranges you can expect:

  • 2xx success status codes confirm that your request worked as expected
  • 4xx error status codes indicate an error because of the information provided, including information from you or your end user.
  • 5xx error status codes are rare and indicate an error with Payer’s platform. Try again in the event of a 500 error and contact Payer if the issue persist.

Some 4xx errors

Some 4xx errors that could be handled programmatically (e.g., a card is declined) include an error code—a short string with a brief explanation—as a value for code. See tables below for possible error codes that can be returned and information about how to resolve them.

When such an error is received from the API, it’s returned in the response body code parameter.

JSON
Copy

Error codes

Error CodeDescriptionPossible Solution(s)Who should take action?
CANCELLEDTransaction cancelled by end-userThe end-user should re-try the payment, if they still would like to complete it.End-user
DECLINED

The requested operation was not successful.

This is the default error when the payment is not accepted by the acquirer or the issuer

The end-user should check if their card is enabled for internet purchase, try another card, or contact their bank.End-user
DECLINED_INVALID_CSCInvalid card security codeThe end-user should input a valid card security codeEnd-user
DECLINED_EXPIREDTransaction declined due to expired cardThe end-user should try again with another card, that is not expiredEnd-user
DECLINED_INSUFFICIENT_FUNDS

Transaction declined due to insufficient funds.

Note:

Not all issuers will provide this information. If not enough information is provided from the card issuers, these errors will fallback to DECLINED.

The end-user needs to make sure that enough funds are available through his/her bankEnd-user
NOT_AUTHENTICATEDTransaction declined due to failed 3D secure authentication.The end-user should try with another card or try again later.End-user
TIMEOUTThe request timed outThe end-user should retry after a short periodEnd-user
SYSTEM_ERRORTransaction failed due to a system error reported by acquirer or card infrastructure.Contact Payer for more information.Integrator / Payer
ALREADY_PROCESSEDThe payment link has been processed, for instance it has been cancelled by Integrator or paid.Integrator should provide End-user a new payment link if it is cancelled.Integrator/End-user
UNKNOWN_ERRORTransaction failed due to an unknown or miscellaneous error.Contact Payer for more information.Integrator / Payer
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard