# Respond to payment inquiry

After a payment is initiated, Alipay+ repeatedly calls the [inquiryPayment](../api_mpp/inquiry_payment) API to obtain the payment status from the Mobile Payment Provider (MPP). Polling stops once Alipay+ receives the final payment result, either in an **inquiryPayment** response or from a **pay** response.

# Processing logic

When responding to the **inquiryPayment** request from Alipay+, you need to pay attention to the rules below.

-   You need to return two kinds of results. The parameter _result_ is the result of the API call and the parameter _paymentResult_ is the result of the payment.
-   If the payment order does not exist, return a _result.resultStatus_ of `F` and _result.resultCode_ of `ORDER_NOT_EXIST`.
-   If the payment order exists, return a _result.resultStatus_ of `S` , a _result.resultCode_ of `SUCCESS`, and a _paymentResult_ according to your payment processing result.

-   If the payment succeeds, return a _paymentResult.resultStatus_ of `S` , a _paymentResult.resultCode_ of `SUCCESS`.
-   If the payment is being processed, return a _paymentResult.resultStatus_ of `U` , a _paymentResult.resultCode_ of `PAYMENT_IN_PROCESS`.
-   If the payment fails, return a _paymentResult.resultStatus_ of `F` and an error code that is corresponding to a specific reason.

-   Required: If the user's balance is not enough, return a _paymentResult.resultCode_ of `USER_BALANCE_NOT_ENOUGH`.
-   Recommended: If the payment is declined for risk reasons, return a _paymentResult.resultCode_ of `RISK_REJECT`.
-   Recommended: If the user does not exist, or the user's status is abnormal, return a _paymentResult.resultCode_ of `USER_NOT_EXIST` or `USER_STATUS_ABNORMAL`.
-   Recommended: If the user's payment methods that are linked to the MPP are unavailable, return a _paymentResult.resultCode_ of `UNAVAILABLE_PAYMENT_METHOD`.
-   Recommended: If the user verification fails, return a _paymentResult.resultCode_ of `USER_PAYMENT_VERIFICATION_FAILED`.
-   Recommended: If the user's KYC fails, return a _paymentResult.resultCode_ of `USER_KYC_NOT_QUALIFIED`.
-   Recommended: If the merchant verification fails, return a _paymentResult.resultCode_ of `MERCHANT_NOT_REGISTERED`.

-   If the payment is cancelled, return a _paymentResult.resultStatus_ of `F` and a _paymentResult.resultCode_ of `ORDER_IS_CLOSED`.

-   When no response from the MPP is received, Alipay+ retries the inquiry request at incremental time intervals until receiving the final payment result status of `S` or `F` , or until the payment expires. Currently, the intervals are 4s, 4s, 30s, 60s, 60s, 60s, 5min, and 5min. The intervals are subject to change in the future by Alipay+.

# Sample

The following sample shows the request and response of the **inquiryPayment** API.

**Request from Alipay+ to the MPP**

Alipay+ sends the payment inquiry request.

```json
{
  "acquirerId": "1022188000000000001",
  "pspId": "1022172000000000001",
  "paymentRequestId": "20200101234567890132"
}
```

**Response from the MPP to Alipay+**

The MPP returns a response that indicates a successful payment result.

```json
{
 "result": {
    "resultCode":"SUCCESS",
    "resultStatus":"S",
    "resultMessage":"Success"
  },
 "paymentResult": {
    "resultCode":"SUCCESS",
    "resultStatus":"S",
    "resultMessage":"Success"
 },
 "paymentId":"2020010123456789013****",
 "paymentTime": "2020-01-01T12:01:01+08:30",
 "paymentAmount":{
    "value":"100",
    "currency":"JPY"
 },
 "payToAmount":{
    "value":"1000",
    "currency":"KRW"
 },
 "customerId":"1234567"
}
```

# Related links

For more information about how to use the **inquiryPayment** API (such as the field description), see [inquiryPayment](../api_mpp/inquiry_payment).