POST /v1/payments/void is used to void a paid order before the payment is captured, and then return money to the payer. There are the following two types of voiding a paid order:
The timeout setting is available when the remaining payment amount is voided or confirmed automatically if the session timeout is set.
All monetary amounts in requests and responses must be expressed in the smallest currency unit (IQD fils). For example, 100 IQD equals 100000.
51051000101000100008) can use this API.cancel instead.
my.getAuthCode JSAPI with specific scopes(USER_ID) to request an authorization code.authCode and returns.authCode to the Mini Program.authCode to the merchant backend.authCode to apply the accessToken.accessToken information to the merchant backend, such as customerId, accessToken, refreshToken, etc.customerId.customerId as referenceBuyerId, paymentNotifyUrl(optional), etc.redirectionUrl.my.tradePay JSAPI with redirectionUrl to conduct the payment.void API to return the money to the customer (Step 23)./v1/payments/void.Alternative flow:
When the E-Wallet backend returns the resultCode as VOID_IN_PROCESS, the merchant can call inquiryPayment API to query void result (Step 27).
| Method | Path |
|---|---|
POST | /v1/payments/void |
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see: OpenAPIs Overview.
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
voidRequestId | string | Yes | The unique ID of a void request generated by a merchant. Max. length: 64 characters. | "2023010123456789013" |
paymentId | string | Yes | The payment ID of the original authorization to be voided. Max. length: 64 characters. | "202312061112128001016xx" |
voidAmount | object | No | The void payment amount. The voidAmount is mandatory in partial void scenario. The voidAmount is optional in full void scenario. | { "value":"40000", "currency":"IQD" } |
extendInfo | string | No | The extension information that wallets and merchants want to describe. The format should be JSON format. Max. length: 2048 characters. | "extendInfo: This is additional information" |
{
"voidRequestId": "2023010123456789013",
"paymentId": "202312061112128001016xx",
"voidAmount": {
"value": "40000",
"currency": "IQD"
}
}
The
voidRequestIdis used for idempotence—repeat submissions with the same ID will yield the same final result.
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
result | object | Yes | The request result, which contains information such as result status and error codes. | { "resultCode": "SUCCESS", "resultStatus": "S", "resultMessage": "Success." } |
voidRequestId | string | No | The unique ID of a void request generated by a merchant. Max. length: 64 characters. | "2023010123456789013" |
voidId | string | No | The unique ID of a void request generated by the wallet. Max. length: 64 characters. | "202312061112128017xxx" |
{
"result": {
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "Success."
},
"voidRequestId": "2023010123456789013",
"voidId": "202312061112128017xxx"
}
In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:
| resultStatus | Description |
|---|---|
S | It means that the void is successful. The corresponding result.resultCode is "SUCCESS", and the result.resultMessage is "Success.". |
U | It means that the status of the void is unknown. The corresponding result.resultCode is UNKNOWN_EXCEPTION, and result.resultMessage is "An API calling is failed, which is caused by unknown reasons". For details, see the Common error codes section.What needs to note is as follow: • U status (inquiry/retry still gets U) can not set to fail or success on merchant/partner system. If other response (almost never occur), the merchant/partner should process like U. |
F | It means that the void fails. The corresponding result.resultCode and result.resultMessage may vary based on different situations. For details, see the Error codes section. |
Error codes are usually classified into the following categories:
| resultStatus | resultCode | resultMessage |
|---|---|---|
F | ORDER_NOT_EXISTS | The order does not exist. |
F | ORDER_STATUS_INVALID | The order status is invalid. |
U | VOID_IN_PROCESS | The void is still under process. |
F | CURRENCY_NOT_SAME | The currency of a user's payment is not the same as the original payment currency. |
F | VOID_AMOUNT_EXCEEDS_AUTH_LIMIT | The total void amount exceeds the limit of the authorized payment amount. |
F | MUTEX_OPERATION_IN_PROCESSING | There is another payment void, confirm, or capture in processing. |
F | ORDER_UNSUPPORTED_OPERATION | The order is not support void. |
F | REPEAT_REQ_INCONSISTENT | Repeated submit, and requests are inconsistent. |
F | PARTNER_NOT_EXIST | The partner does not exist. |
F | USER_NOT_EXISTS | The user does not exist. |
F | USER_STATUS_ABNORMAL | The user status is abnormal. |
F | PARTNER_STATUS_ABNORMAL | The partner status is abnormal. |
51051000101000100008 for escrow)