# Obtain payment results

After calling the **pay** API, the Acquiring Service Provider (ACQP) can get the payment result in the following three ways:

-   Get the payment result from the synchronous response of the **pay** API.
-   Get the payment result from the asynchronous payment notification sent by Alipay+ through the **notifyPayment** API.
-   Call the **inquiryPayment** API to inquire about the payment result.

The following diagram illustrates all the possible combinations of the results that you (the ACQP) might encounter in the three ways.

![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1756175940487-6915e501-0c41-4874-b111-ac983efa9473.png)

Figure 1. Possible combinations of the results

Payment results obtained by the three methods might be inconsistent. This is because the payment result returned by the response of the **pay** API and the **inquiryPayment** API might be in the intermediate status (unknown). To get the final status of the payment result, you need to keep retrying the **inquiryPayment** API call while waiting forAlipay+ to send the **notifyPayment** request. For how to handle the payment results that are returned by these two APIs, refer to the following section _Collaboration between inquiryPayment and notifyPayment_.

## Collaboration between inquiryPayment and notifyPayment

![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1756175940574-fb653314-9a8c-49f9-9ff2-926821c09fae.png)

Figure 2. Collaboration between the inquiryPayment API and notifyPayment API

It is recommended that the you take the following steps to ensure efficient collaboration between these two APIs:

1.  Create at least a table that includes the order number and order status in your local database.
2.  Set the initial order status to `INIT`.
3.  Depending on via which API the payment result is obtained, different actions are taken:

-   If you receive the payment result (which is specified in the _paymentResult_ parameter) from Alipay+ via the **notifyPayment** API, check if the order status is `INIT`. If so, update the order status in your database; otherwise, you don't need to update the order status.
-   If you obtain the payment result (which is specified in the _paymentResult_ parameter) by calling the **inquiryPayment** API, depending on the value of the _paymentResult.resultValue_ parameter, different actions are taken:

-   If the value is `S` or `F`, update the order status in your database.
-   If the value is `U`, retry to call the **inquiryPayment API** until the value becomes `S` or `F`. Then update the order status in your database.

## Integration requirements

It is required that you support both **notifyPayment** API and **inquiryPayment** API so that you are guaranteed to obtain the final payment result. For example, when you cannot receive the payment result notification due to network or system problems, the **inquiryPayment** API can work as a complement to ensure you get the final (success or failure) payment result.

Learn more about how to [receive payment notifications](receive_payment_notification) through the **notifyPayment** API.

Learn more about how to [inquire about payment results](inquire_payment_result) through the **inquiryPayment** API.