Implementing error handling
Idempotence
Idempotence means that in response to the same requests sent multiple times, AlipayHK should send back only one unique result.
AlipayHK checks the idempotence for signing, payment and refund. See details as below:
- ApplyToken with the same authMerchantID: AlipayHK checks the idempotence of authMerchantID. Signing with the same valid authcode are considered as the same token signing process and will return the same accessToken.
- Payments with the same mechantID: AlipayHK checks the idempotence of merchantTransId. Transactions with the same merchantTransId are considered as the same transactions. AlipayHK then checks information such as the currency and amount of the transaction. If the information does not match with that in the AlipayHK system, errors will be returned. Otherwise, AlipayHK returns the real status of the transaction.
- Refunds with the same merchantID: AlipayHK checks the idempotence of merchantRefundId and refunds with the same merchantID AND merchantRefundId are considered as the same transactions. AlipayHK then checks information such as the amount of the refund. If this information does not match with that in the AlipayHK system, errors will be returned. Otherwise, AlipayHK returns the real status of the refund.
We support synchronous refund which means AlipayHK HK will make the refund in real-time, and returns the result immediately. Merchant can retry the refund API until it returns success.
Timeout or system error (SYSTEM_ERROR)
Because HTTPS requests depend on network stabilities, timeout might occur on interface requests. At the same time, AlipayHK might return SYSTEM_ERROR for internal system problems. In both cases, partners can retry or query to get aligned with the final authorization status, final payment status and final refund status.