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
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.
notifyUrlString1000ByteWebhook 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
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}",
"notifyUrl": "{Webhook URL for Cancellation Result}",
"memo": "Customer Request"
}

Response

Parameters

Field NameTypeLengthRequiredDescription
resCdString4ByteResponse Code
resMsgString1000ByteResponse 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
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)