Cancel Payment
This API is used to fully or partially cancel an Alipay transaction.
Important: Retry Policy
If you receive a timeout or a specific response code indicating a retry is needed (A210 ~ A219), you MUST retry the cancellation request using the SAME shopTransactionId and SAME cancelReqDate used in the initial request.
Request
Request URL
POST https://{API Domain}/api/trades/alipay/revise
Content-type: application/json; charset=utf-8
Note
Supports API Idempotency (See API Idempotency)
Caution
Since final cancellation takes time, you must set the timeout to 30 seconds.
Parameters
| Field Name | Type | Length | Required | Description |
|---|---|---|---|---|
| mallId | String | 8Byte | ✅ | Merchant ID assigned by KICC |
| shopTransactionId | String | 60Byte | ✅ | Merchant Transaction ID (API Idempotency Key) |
| pgCno | String | 60Byte | ✅ | Original Payment Transaction ID |
| reviseTypeCode | String | 2Byte | ✅ | Cancellation Type Full Cancel: “40”, Partial Cancel: “32” |
| cancelReqDate | String | 8Byte | ✅ | Cancellation Request Date (yyyyMMdd) Note: Use the INITIAL date when retrying. |
| msgAuthValue | String | 200Byte | ✅ | Message Integrity Verification Value (See Message Authentication) Contact sales for the Secret Key. |
| memo | String | 400Byte | Reason for Cancellation | |
| regId | String | 40Byte | Requestor ID | |
| amountInfo | Object | Cancellation Amount Info (Required for Partial Cancel) See amountInfo below |
amountInfo (Cancellation Amount Info)
| Field Name | Type | Length | Required | Description |
|---|---|---|---|---|
| currency | String | 2Byte | ✅ | Currency Code (KRW: "KRW", USD: "USD") |
| totAmount | Number | Cancellation Amount (Required for Partial Cancel) For USD: Amount * 100 (e.g., $12.03 -> 1203) |
Request Example
{
"mallId": "{Merchant ID}",
"shopTransactionId": "{API Idempotency Key}",
"pgCno": "{Original Payment Transaction ID}",
"reviseTypeCode": "40",
"cancelReqDate": "{Request Date}",
"msgAuthValue": "{Message Auth Value}",
"memo": "Customer Request"
}
Response
Parameters
| Field Name | Type | Length | Required | Description |
|---|---|---|---|---|
| resCd | String | 4Byte | ✅ | Response Code |
| resMsg | String | 1000Byte | ✅ | Response Message |
| shopTransactionId | String | 60Byte | ✅ | Returns the value sent in the request |
| mallId | String | 8Byte | Merchant ID assigned by KICC | |
| pgCno | String | 60Byte | Original Payment Transaction ID | |
| cancelPgCno | String | 60Byte | Cancellation Transaction ID | |
| transactionDate | String | 14Byte | Transaction Date/Time (yyyyMMddHHmmss) | |
| amountInfo | Object | Cancellation Amount Info See amountInfo below |
amountInfo (Cancellation Amount Info)
| Field Name | Type | Length | Required | Description |
|---|---|---|---|---|
| currency | String | 2Byte | ✅ | Currency Code (KRW: "KRW", USD: "USD") |
| totAmount | Number | Cancellation Amount For USD: Amount * 100 (e.g., $12.03 -> 1203) |
Response Example
{
"resCd": "0000",
"resMsg": "Success",
"mallId": "{Merchant ID}",
"shopTransactionId": "{API Idempotency Key}",
"pgCno": "{Original Payment Transaction ID}",
"cancelPgCno": "{Cancellation Transaction ID}",
"transactionDate": "20230312000512",
"amountInfo": {
"currency": "USD",
"totAmount": 5022 // Represents $50.22
}
}
Message Authentication Value
The Message Authentication Value is constructed by combining the fields below and hashing the result using HmacSHA256. (See Message Authentication)
pgCno(Original Payment Transaction ID) + “|” + shopTransactionId(Merchant Transaction ID)