Skip to main content

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 NameTypeLengthRequiredDescription
mallIdString8ByteMerchant ID assigned by KICC
shopTransactionIdString60ByteMerchant Transaction ID (API Idempotency Key)
pgCnoString60ByteOriginal Payment Transaction ID
reviseTypeCodeString2ByteCancellation Type
Full Cancel: “40”, Partial Cancel: “32”
cancelReqDateString8ByteCancellation Request Date (yyyyMMdd)
Note: Use the INITIAL date when retrying.
msgAuthValueString200ByteMessage Integrity Verification Value (See Message Authentication)
Contact sales for the Secret Key.
memoString400ByteReason for Cancellation
regIdString40ByteRequestor ID
amountInfoObjectCancellation Amount Info (Required for Partial Cancel)
See amountInfo below

amountInfo (Cancellation Amount Info)

Field NameTypeLengthRequiredDescription
currencyString2ByteCurrency Code (KRW: "KRW", USD: "USD")
totAmountNumberCancellation 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 NameTypeLengthRequiredDescription
resCdString4ByteResponse Code
resMsgString1000ByteResponse Message
shopTransactionIdString60ByteReturns the value sent in the request
mallIdString8ByteMerchant ID assigned by KICC
pgCnoString60ByteOriginal Payment Transaction ID
cancelPgCnoString60ByteCancellation Transaction ID
transactionDateString14ByteTransaction Date/Time (yyyyMMddHHmmss)
amountInfoObjectCancellation Amount Info
See amountInfo below

amountInfo (Cancellation Amount Info)

Field NameTypeLengthRequiredDescription
currencyString2ByteCurrency Code (KRW: "KRW", USD: "USD")
totAmountNumberCancellation 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)