Alipay+ DocsAlipay+ Docs

Idempotency

An API call is idempotent if the action is performed only once no matter how many times the API call is retried.

Idempotency helps to avoid unwanted duplication in case of failures and retries. For example, idempotency can guarantee that the payment is charged only once if the same API payment call is retried multiple times in the case of a timeout error.

In Alipay+, API idempotency is enabled by an idempotency field. Idempotency fields stay unique without a time limit.

Idempotency fields

The following tables list the APIs that need idempotency control, the idempotency parameters of APIs, and key parameters that are checked for consistency in idempotency control. For detailed information, see the specific API chapter.

Direction: ACQP > Alipay+

For APIs that are used by the ACQP to call Alipay+, Alipay+ decides the idempotency parameters and key parameters that are checked for consistency. The following table lists the APIs that need idempotency control, idempotency parameters of APIs, and key parameters that are checked for consistency in idempotency control:

Interface

Idempotency parameter

Key parameter to check consistency

pay (User-presented Mode Payment)

paymentRequestId

paymentAmount,

paymentMethod.paymentMethodType, and order.orderAmount

pay (Merchant-presented Mode Payment -Entry Code)

pay (Merchant-presented Mode Payment - Order Code)

pay (Cashier Payment)

pay (Auto Debit)

refund

refundRequestId

refundAmount and paymentRequestId, or refundAmount and paymentId

cancelPayment

paymentRequestId

N/A

prepare

authClientId and referenceAgreementId

Note:

authClientId and referenceAgreementId are jointly used for idempotency control.

ALL the other request parameters

cancelToken

accessToken

N/A

registration

registrationRequestId

N/A

declare

customsDeclarationRequestId

N/A

responseRetrieval

disputeRequestId

N/A

responseEscalation

disputeRequestId

refundType and refundAmount

Direction: Alipay+ > ACQP

For APIs that are used by Alipay+ to call the ACQP, the ACQP decides the idempotency parameters and key parameters that are checked for consistency. The following table lists the APIs that need idempotency control, the idempotency parameters of APIs, and recommended key parameters that are checked for consistency in idempotency control:

Interface

Idempotency parameter

Key parameter to check consistency

userInitiatedPay

codeValue

customerId

initiateRetrieval

disputeRequestId

paymentRequestId

initiateEscalation

disputeRequestId

paymentRequestId