Interpret the Transaction Response
When you send a transaction request to the Mastercard Gateway, you receive a response within a short interval. To determine the success of your transaction, as well as obtain other important data from the transaction response, you need to decode and parse the transaction response. When you know the result for the transaction, it is good practice to display that and a receipt of some kind to your payer on your payment page.
Spend some time examining the transaction response fields for each relevant operation in the API Reference. All the fields provide valuable information, and you probably want to store some of them locally for accounting, reconciliation, and traceability reasons. The more complex your integration is, the more useful it can be to study specific response codes to identify all aspects of the transaction status.
Sample transaction response
This topic includes various sample code snippets. Select the protocol and language that you want to use and select Update Code Snippets to change all the snippets in this topic.
Decode the response
(, ) ChangeWhen you receive the response to your transaction, it is encoded or formatted in the same format as the transaction request. To make this data more accessible, decode it and store it in an array or similar.
The following code snippet shows how to decode the response received from the gateway.
Select Protocol and Language to view Code Snippet.
From: Sample Code Download
Parse the response
(, ) ChangeOnce you decode the transaction response and store it in an easily accessible object, you can parse the data to retrieve any fields that you need.
The following code snippet shows how to parse a field from the decoded transaction response.
Select Protocol and Language to view Code Snippet.
From: Sample Code Download
Frequently asked questions
What should I do if I do not receive a response?
When you do not receive a response, wait for 60 seconds and attempt to resubmit an identical request. If the gateway has received the original request and the new one is a duplicate, the bank transaction is not repeated, and no duplicate funds are transferred. You receive the same response as you would have received for the first request.
How do I know if a transaction has been approved?
All approved transactions are represented with a Transaction Response Code value of APPROVED
from the gateway (see the response.gatewayCode
field in your transaction response). Any other code represents a declined or failed transaction.