Response object of the API response. The sections below explain the structure of the response and detail the steps you can take to handle common error scenarios, such as:
- The request failed because it was invalid.
- You made a payment request but didn’t receive a result.
- The result of your payment request indicates the transaction failed.
Response object format
To be able to resolve issues with your requests, you need to know how Terminal API informs you of the processing status of your request. This is communicated in theResponse object of the API response, which has:
-
Result: one of the following values:- Success: The request succeeded / the transaction was approved on the terminal.
- Partial: The transaction amount has been partially approved.
- Failure: The request or transaction didn’t succeed. The remaining
Responsefields provide more information about the error, to enable you to determine how to handle it.
-
ErrorCondition: This field is included when the request or transaction fails, and indicates the cause of the failure. -
AdditionalResponse: More information about the error condition. You’ll receive either a string of form-encoded key-value pairs or a Base64 string that you need to decode to get a JSON object.
Response object help you to identify if and why a request has failed.
Invalid message format
AResponse object with Result Failure and ErrorCondition MessageFormat indicates there was a mistake in the request you sent. Proceed as follows:
-
Determine what caused the error, based on the
message,warnings, orerrorsin theAdditionalResponse. For example, a missing required field or an unexpected field. The following example is for a response indicating that theCurrencyfield is missing from the payment request: Currency missing - Refer to the Terminal API reference if necessary, then manually fix your request and try again.
Invalid JSON format
If your API request does not contain a valid JSON object, you receive a Bad JSON HTTP reply that specifies the line number and a description of the issue: Bad JSON- Manually fix the JSON error on the line mentioned in the HTTP reply and try again.
Unavailable service
AResponse object with Result Failure and ErrorCondition UnavailableService indicates we were unable to implement your request. Proceed as follows:
-
Determine what caused the error, based on the
message,warnings, orerrorsin theAdditionalResponse. For example:- You tried to use functionality that the payment terminal doesn’t support.
- You tried to use a ProtocolVersion that the terminal cannot manage.
- You tried to use functionality that we do not support.
- Depending on the cause of the error, manually fix your request and send it again. For example, after receiving the above failure response you’d specify the same protocol version that the terminal supports.
No result received
We recommend that your integration automatically checks the status of a transaction any time it fails to receive a transaction response. Payment requests time out after a while. If you do not receive a payment response (or you receive a response indicating a time-out) after 120 seconds (local integration) or 150 seconds (cloud integration), and the internet connection hasn’t dropped, your integration should automatically check the transaction status. If you do not receive a transaction result, neither synchronously nor asynchronously, proceed as follows:- Make a transaction status request.
-
Determine your next action based on the TransactionStatusResponse.Response:
Terminal unavailable (cloud integration)
When you send a payment request to a payment terminal that is unavailable, the payment cannot be processed. In a cloud integration, the Terminal API generates a Reject event notification. Note that event notifications are always presented as aSaleToPOIRequest.
The EventNotification body contains:
RejectedMessage: a Base64 string containing the payment request that couldn’t be processed. Decode this to get the original payment request as a JSON object.EventToNotify: RejectEventDetails: a message indicating why the payment terminal is unavailable.
EventDetails message you receive:
Did not receive a response
- Make a transaction status request to verify whether the WebSocket connection has been restored and the payment is now processed.
Failed to send message
-
Check the WebSocket connection:
- The terminal display should have a cloud icon in the top row.
- Check the cloud connection from your Customer Area, using an API request, or on the terminal itself.
Unknown POIID
- On the payment terminal, go to the Device info menu option and verify that the terminal ID in the format [device model]-[serial number] matches the POIID that you specified in the payment request. For example, P400Plus-123456789.
If the POIID matches, go to the next step. - Verify that the payment terminal is assigned to a merchant account or store. You can do this using a GET /terminals request, or using your Customer Area.
Declined payment
When the PaymentResponse.Response includesResult Failure and one of the error conditions listed below, the transaction was declined.The
AdditionalResponse has more information about why the transaction was declined in the refusalReason and message fields. These fields are our mapping of the response we receive from acquirers and issuers.
Here’s an example failure response for a declined payment:
Additional response
-
Check the ErrorCondition in the
PaymentResponse.Response, because in many cases this already indicates whether you can retry the transaction. -
For the error conditions Cancel, InvalidCard, and Refusal, check the
AdditionalResponsefor therefusalReasonandmessage. For the error condition Busy, check the response for aserviceId. You can use this if you want to cancel the transaction. You can use theErrorConditionto code your POS app. TherefusalReasonandMessagefields are included for additional insight, and should not be coded against.
TheserviceIdcan be used by the POS app to cancel a transaction. Select the tabs for details.
- Cancel
- Busy
- InvalidCard
- Refusal
The
ErrorCondition Cancel can be caused by a device time-out.
