# Get Transaction Details

After the payment is initiated, you can use this API to get the transaction
details of an order.

> [!NOTE]
> **Important:**
>
> We strongly recommend that you
> check the payment transaction status with your payment service provider (PSP).
> This is to ensure that the transaction is successful before you deliver the
> goods or services. This also helps you to follow up on the payment status
> and perform reconciliation if the payment fails.
>
> We also recommend you to check the amount paid in the response received from
> the PSP and \`GetTransactionDetails\` API response from Google.

## Request

To get the transaction details, make a POST request to the following endpoint:

**Prod**

    POST https://nbupayments.googleapis.com/v1/merchantTransactions:get

> [!NOTE]
> **Note:** If you want to test against test endpoints, reach out to your Google point of contact for the details.

### Request Body

    {
      // Merchant identifier, googleMerchantId should be set. This ID is globally
      // unique across all Google Pay merchants.
      "merchantInfo": {
        "googleMerchantId": "ABCDE12345"
      },
      // Merchant transaction ID for which payment details need to be fetched.
      "transactionIdentifier": {
        "merchantTransactionId": "someTransactionId"
      }
    }

#### Request Body parameters

##### Merchant Info

The following data parameter for the `merchantInfo` object must be passed in the
API request:

| Parameters | Type of value | Description | Required/Optional |
|---|---|---|---|
| `googleMerchantId` | String | Google assigned merchant ID. Generated during onboarding. | Required |

##### Transaction Id

You must pass the unique transaction ID that you generated while creating the
payment/order in the `merchantTransactionId` key. It is a **required** field.

## Response

The response contains "UPI" as the value for `paymentMode` object and one of the
following possible values for the `transactionStatus` object.

- SUCCESS
- FAILURE: Transaction has failed
- IN_PROGRESS: Transaction is in progress
- PAYMENT_NOT_INITIATED: Payment hasn't been initiated by the user
- DECLINED: Payment has been declined by the user
- EXPIRED: Payment request expired

### Successful response

If successful, the GET request returns a `200 OK` HTTP status code, including
the following response:

    {
      // Merchant transaction ID for which payment details are fetched.
      "transactionId": "someTransactionId",
      // Google's transaction ID.
      "googleTransactionId": "someGoogleTransactionId",
      // Mode of payment that the user used.
      "paymentMode": "UPI",
      // Status of the transaction.
      "transactionStatus": {
        "status": "SUCCESS"
      },
      // Transaction details for UPI transaction.
      "upiTransactionDetails": {
        "upiRrn": "abcdef"
      },
      // Amount paid by the user (only present if the transactionStatus is SUCCESS)
      "amountPaid": {
        "currencyCode": "INR",
        "units": "100",
        "nanos": 750000000
      },
      // Time at which transaction was last updated in RFC 3339 format
      "lastUpdatedTime": "2022-01-31T11:00:44.735Z",

      // Payer account type: UPI_CREDIT, UPI_DEBIT (only populated for allowlisted merchants)
      "payerAccountType": "UPI_DEBIT",
      // Payee VPA of the transaction (only populated for allowlisted merchants)
      "payeeVpa": "your-merchant-vpa@acquiringbank"

    }

### Failure response

The API returns the following response in case of a failure:

    {
      // Merchant transaction ID for which payment details are fetched.
      "transactionId": "someTransactionId",
      // Google's transaction ID.
      "googleTransactionId": "someGoogleTransactionId",
      // Mode of payment that the user used.
      "paymentMode": "UPI",
      // Status of the transaction.
      "transactionStatus": {
        "status": "FAILURE",
        // (String) failure error code describing the reason behind the failure
        "failureErrorCode": "BENEFICIARY_VPA_RESTRICTED"
      },
      // Transaction details for UPI transactions.
      "upiTransactionDetails": {
        "upiRrn": "abcdef"
      },
      // Time at which transaction was last updated in RFC 3339 format
      "lastUpdatedTime": "2022-01-31T11:00:44.735Z",

      // Payer account type: UPI_CREDIT, UPI_DEBIT (only populated for allowlisted merchants)
      "payerAccountType": "UPI_DEBIT",
      // Payee VPA of the transaction (only populated for allowlisted merchants)
      "payeeVpa": "your-merchant-vpa@acquiringbank"
    }

In case of a malformed request, you will receive the following response with
an appropriate error message and error code:

    {
      "error": {
        "code": 400,
        "status": "INVALID_ARGUMENT",
        "message": "MerchantInfo not present"
      }
    }

#### Malformed request error codes

| Code | Title | Description |
|---|---|---|
| 403 | PERMISSION_DENIED | The merchant is not authorized. |
| 400 | INVALID_ARGUMENT | Request contains an invalid argument. |
| 404 | NOT_FOUND | Request contains invalid transaction ID. |