Skip to main content

Cancel Payment

This API is used to submit a request for WeChat Pay cancellation (including partial cancellation).

Important: Asynchronous Processing
  • This API submits a cancellation request; it does NOT imply immediate completion of the cancellation.
  • The final cancellation result will be sent via the Webhook (Notification) Service.

Request​

Request URL
POST https://{API Domain}/api/trades/wechatpay/revise
Content-type: application/json; charset=utf-8
Note

Supports API Idempotency (See API Idempotency)

Caution

Since the request involves communicating with the global network, you must set the timeout to 30 seconds.

Parameters​

Field NameTypeLengthRequiredDescription
mallIdString8Byte✅Merchant ID assigned by KICC
shopTransactionIdString60Byte✅Merchant Transaction ID (API Idempotency Key)
pgCnoString60Byte✅Original Payment Transaction ID
reviseTypeCodeString2Byte✅Cancellation Type
Full Cancel: “40”, Partial Cancel: “32”
cancelReqDateString8Byte✅Cancellation Request Date (yyyyMMdd)
Note: Use the INITIAL date when retrying.
msgAuthValueString200Byte✅Message Integrity Verification Value (See Message Authentication)
Contact sales for the Secret Key.
notifyUrlString1000Byte✅Webhook URL to receive the cancellation result
memoString400ByteReason for Cancellation
regIdString40ByteRequestor ID
amountInfoObjectCancellation Amount Info (Required for Partial Cancel)
See amountInfo below

amountInfo (Cancellation Amount Info)​

Field NameTypeLengthRequiredDescription
currencyString2Byte✅Currency Code (KRW: "KRW", USD: "USD")
totAmountNumber✅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}",
"notifyUrl": "{Webhook URL for Cancellation Result}",
"memo": "Customer Request"
}

Response​

Parameters​

Field NameTypeLengthRequiredDescription
resCdString4Byte✅Response Code
resMsgString1000Byte✅Response Message
shopTransactionIdString60ByteReturns the value sent in the request
mallIdString8ByteMerchant ID assigned by KICC
resDetailMsgString1024ByteDetailed error message from WeChat (URL encoded)
pgCnoString60ByteOriginal Payment Transaction ID
cancelPgCnoString60ByteCancellation Transaction ID
transactionDateString14ByteTransaction Date/Time (yyyyMMddHHmmss)
amountInfoObjectCancellation Amount Info
See amountInfo below

amountInfo (Cancellation Amount Info)​

Field NameTypeLengthRequiredDescription
currencyString2Byte✅Currency 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)