# Interpret the Transaction Response
source: https://developer.mastercard.com/mastercard-gateway/documentation/integrations-types/hosted-session/integrate-hosted-session/interpret-transaction-response/index.md

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](https://developer.mastercard.com/mastercard-gateway/documentation/api-reference/v100/rest/index.md). 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.

Warning: It is good practice to validate whether the data you supplied for the transaction is the same as the data used to process the transaction. For example, check that the amount returned in the transaction response matches the value you sent in the request.

<br />

## Sample transaction response {#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.

Warning: This page includes sample code snippets. Choose an interface and language, then click *Update Code Snippets*.

<br />

## Decode the response {#decode-the-response}

When 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.

## Parse the response {#parse-the-response}

Once 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.

Warning: All API operations contain a result field in the response. This field indicates the overall result and status of your transaction. Use it to determine different processing options within your app. For example, if the transaction result value is a SUCCESS, you can record it as being processed successfully. If the result is a FAILURE, you can look further at the transaction response to determine whether the payer must retry the transaction or whether you must execute another process within your app. The following code snippet shows how to parse a field from the decoded transaction response.

<br />

```java
public static String getJsonFieldValue(String jsonFieldName, String resp) {
    jsonFieldName = "\"" + jsonFieldName + "\":";
    String jsonFieldValue = null;
    int index = resp.indexOf(jsonFieldName);

    if (index != -1) {
        int startIndex = index + jsonFieldName.length() + 1;
        int endIndex = resp.indexOf("\"", startIndex);
        jsonFieldValue = resp.substring(startIndex, endIndex);
    }

    return jsonFieldValue;
}
```

## Frequently asked questions {#frequently-asked-questions}

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. 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.
