# Best practices

> Best practices for improving your product experience and payment efficiency.

This topic introduces the following best practice solutions to help you enhance product experience and payment efficiency:

-   [Client-side optimization](https://idocsmng.alipay.com/spaces/ac/repos/apo/page/editor#J4Qir)
-   [Payment result display](https://idocsmng.alipay.com/spaces/ac/repos/apo/page/editor#QecRh)
-   [Payment failure retry](https://idocsmng.alipay.com/spaces/ac/repos/apo/page/editor#efckT)
-   [API timeout settings](https://idocsmng.alipay.com/spaces/ac/repos/apo/page/editor#c9EB9)

## Client-side optimization App only

It mainly involves optimization of the following items:

-   Handling of a disambiguation box on Android.
-   Determine whether the buyer has installed the payment method app.
-   Completing payments on the merchant app.

Refer to [Payment continuation URL](https://docs.antom.com/ac/apo/configure_url.md#eK0wp) for more information on app terminals.

## Payment result display

### Redirection handling

If the buyer successfully completes the payment but faces issues being redirected to the URL you set in _paymentRedirectUrl_\-whether due to network issues or payment method limitations-consider the following points:

-   Do not use the client redirection as the basis for determining the success of the payment.
-   If _paymentRedirectUrl_ of the payment method page fails to redirect to the merchant page, the buyer may manually click to return to the original merchant page. To prevent buyers from mistakenly attempting to pay for the order again, it is recommended to implement a pop-up window on the original merchant page. This pop-up should allow for transaction result inquiries. When buyers click the pop-up window, it should display the transaction result, thereby preventing any duplicate payment attempts.

## Payment failure retry

If a payment attempt fails and the buyer can retry payment for the same order, follow the steps below to provide a seamless experience for the buyer:

1.  In the [**pay (Checkout Payment)**](https://docs.antom.com/ac/ams/payment_cashier.md) request, set _referenceOrderId_ to the order ID and _paymentRequestId_ to the payment order ID.
2.  Before retrying payment for the same order, check the order status:

-   If payment is successful, display "Payment completed" to the buyer.
-   If payment fails, call the [**pay (Checkout Payment)**](https://docs.antom.com/ac/ams/payment_cashier.md) API again to obtain a new _normalUrl_ for redirection. Though _referenceOrderId_ remains the same since it's the same order, you must update _paymentRequestId_ for the subsequent payment attempt

3.  Ensure only one successful payment is associated with each order. If multiple successful payments are detected for a single order, call the [**cancel**](https://docs.antom.com/ac/ams/paymentc_online.md) API to initiate a refund for the buyer.
4.  For payment methods that do not offer refunds, it is recommended to cancel the initial payment before initiating a new one.

The integration process varies depending on whether the payment method supports refunds.

#### Tab: Refund supported

A new payment can be initiated for the same order. If two successful payment orders exist, cancel one of them.

![APO-最佳实践-支持退款-英.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/yuque/idocs/2025/png/97d2b48e-b5b3-4c00-aca3-968961f11ded.png)

#### Tab: Refund not supported

Before initiating a new payment, the previous payment must be cancelled to avoid two successful payment orders where refunds are not supported.

![APO-最佳实践-不支持退款-英.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/yuque/idocs/2025/png/fbbf24fa-9aad-4595-ab3e-01f376c9cd02.png)

## API timeout settings

APO offers seamless integration with a variety of payment methods. However, in certain scenarios, processing delays in the [**pay**](https://docs.antom.com/docs/ac/apo/pay.md) API may result in slow responses, preventing buyers from being redirected to the payment continuation link. This can reduce the payment success rate and negatively impact the user experience. To address this, it is recommended to set the API timeout to 10 seconds to improve response success rates. If a [**pay**](https://docs.antom.com/docs/ac/apo/pay.md) API call times out, it is suggested to reinitiate the original request to retrieve the payment continuation link.