# inquiryPayment

> The inquiryPayment API is called by the POS to query the payment status, typically when the POS does not receive a transaction response from the payment terminal.

The **inquiryPayment** API is called by the POS to query the payment status, typically when the POS does not receive a transaction response from the payment terminal.

## Method signature

When calling this method, please use the following standard method signature format.

```kotlin
fun inquiryPayment(
    queryPaymentRequest: QueryPaymentRequest,
    options: RequestOptions? = null,
    callBack: QueryPayResultListener? = null
)
```

## Parameters

| **Parameter name** | **Type** | **Required** | **Description** |
| --- | --- | --- | --- |
| _queryPaymentRequest_ | [QueryPaymentRequest](https://docs.antom.com/ac/omnichannel/usb_structures.md#MhIhI) | Yes | Indicates the object that contains the parameters for querying the payment result. |
| _options_ | [RequestOptions](https://docs.antom.com/ac/omnichannel/usb_structures.md#A6GQM) | No | Indicates the object that contains optional parameters in the API requests. |
| _callback_ | [QueryPayResultListener](#zisnH) | No | The callback that is used to return the query result. See [_callback_](#zisnH) for details. |

#### _callback_

| **Parameter name** | **Type** | **Required** | **Description** |
| --- | --- | --- | --- |
| _result_ | [QueryPayResultData](#qY7H1) | No | Indicates the result of querying the payment result. |

## Return values

| **Parameter name** | **Type** | **Required** | **Description** |
| --- | --- | --- | --- |
| _result_ | [Result](https://docs.antom.com/ac/omnichannel/usb_structures.md#qrMZE) | Yes | The result of the API call. |
| _paymentRequestId_ | String | Yes | The unique ID that is defined by the POS provider to identify a payment request. - Maximum length: 64 characters. - Only letters (a-z, A-Z), numbers (0-9), and underscores (\_) are allowed. > **Note**: This parameter is unique for each store. Call the **inquiryPayment** API with the _paymentRequestId_ to query the payment status. Each call returns the latest payment result. |
| _paymentId_ | String | Yes | The unique ID that is defined by the POS provider to identify a payment and consistent with the _paymentId_ in transaction reports. |
| _paymentCreateTime_ | String | Yes | The date and time when the payment is created. The value follows the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) standard format. For example, "2019-11-27T12:01:01+08:00". |
| _paymentTime_ | String | Yes | The date and time when the payment reaches a final state of success. The value follows the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) standard format. For example, "2019-11-27T12:01:01+08:00". |
| _paymentStatus_ | String | Yes | Indicates the final status of payment. Valid values are: - `SUCCESS`: The payment is successful. - `FAIL`: The payment failed. - `PROCESSING`: The payment is under processing. - `CANCELLED`: The payment is canceled. - `PENDING`: The payment completed, waiting for final payment result. |
| _paymentAmount_ | [Amount](https://docs.antom.com/ac/omnichannel/usb_structures.md#eb4xu) | Yes | The payment amount that the merchant requests to receive in the order currency. |
| _paymentMethod_ | String | Yes | The payment method that is used to collect the payment by the merchant or acquirer. For the supported payment methods, see [Supported payment methods](https://docs.antom.com/ac/omnichannel/n950.md#fXQ3O). |

## Result codes

| **_resultCode_** | **_resultStatus_** | **_resultMessage_** | **Further action** |
| --- | --- | --- | --- |
| `SUCCESS` | `S` | Success. | No action is required. |
| `PROCESS_FAIL` | `F` | A general business failure occurred. Do not retry. | Contact Antom Technical Support to troubleshoot the issue. |
| `PROCESS_FAIL` | `F` | The data format is invalid. | Contact Antom Technical Support to troubleshoot the issue. |
| `PROCESS_FAIL` | `F` | The public key pairing failed. | Contact Antom Technical Support to troubleshoot the issue. |
| `PARAM_ILLEGAL` | `F` | Parameter names or values do not meet the specified requirements. The result message can vary according to the specific error encountered. | Check whether the request parameters, including the header parameters and body parameters, are correct and valid. |
| `TERMINAL_NOT_LOGIN` | `F` | The payment terminal is not logged in. | Log in to the payment terminal. |
| `TERMINAL_BUSY` | `F` | The payment terminal is busy. | Try again later. |
| `PAYMENT_NOT_EXIST` | `F` | The payment does not exist. | Contact Antom Technical Support to troubleshoot the issue. |
| `DEVICE_NOT_CONNECT` | `F` | The USB connection failed. | - Check whether the initialization connection has been completed in your code. If not, perform initialization connection. - Check whether both ends of the USB connection are securely connected in your code. If not, connect the two devices again. |
| `TIMEOUT_EXCEPTION` | `U` | Response timeout. | Check whether the payment terminal app is active. If not, activate it again. |
| `UNKNOWN_EXCEPTION` | `U` | The API call failed, which is caused by unknown reasons. | Call the **inquryPayment** API with the _paymentRequestId_ to query the final payment status. |
| `UNKNOWN_EXCEPTION` | `U` | Failed to decrypt the data returned by the payment terminal. | Contact Antom Technical Support to troubleshoot the issue. |
| `UNKNOWN_EXCEPTION` | `U` | The message format is invalid. | Contact Antom Technical Support to troubleshoot the issue. |

## Samples

The following sample code shows how to call the **inquiryPayment** API:

```kotlin
PaymentManager.inquiryPayment(
    request,
    null,
    object : QueryPayResultListener {
        override fun result(result: QueryPayResultData) {
            runOnUiThread {
                findViewById<TextView>(R.id.tv_response).text = result.toString()
            }
        }
    }
)
```

The following code shows a sample of the response:

```json
{
  "result":{
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "Success."
  },
  "paymentRequestId": "pay_1089760038715669_1027757450XXXXX",
  "paymentId": "202502081140108001001888202003XXXXX",
  "paymentCreateTime": "2025-02-08T12:01:01+08:00",
  "paymentTime": "2025-02-08T12:01:01+08:00",
  "paymentStatus": "Success",
  "paymentAmount":{
    "currency": "SGD",
    "value": "50000"
  },
  "paymentMethod":"CARD"
}
```