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 expected4xx
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.
{
.
"code": "DECLINED"
"message": "Failed to authorize payment.",
}
Error codes
Error Code | Description | Possible Solution(s) | Who should take action? |
---|---|---|---|
CANCELLED | Transaction cancelled by end-user | The 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_CSC | Invalid card security code | The end-user should input a valid card security code | End-user |
DECLINED_EXPIRED | Transaction declined due to expired card | The end-user should try again with another card, that is not expired | End-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 bank | End-user |
NOT_AUTHENTICATED | Transaction declined due to failed 3D secure authentication. | The end-user should try with another card or try again later. | End-user |
TIMEOUT | The request timed out | The end-user should retry after a short period | End-user |
SYSTEM_ERROR | Transaction failed due to a system error reported by acquirer or card infrastructure. | Contact Payer for more information. | Integrator / Payer |
ALREADY_PROCESSED | The 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_ERROR | Transaction failed due to an unknown or miscellaneous error. | Contact Payer for more information. | Integrator / Payer |