Cancel a Pre-Authorized Transaction

API Command: cancel_transaction

The Cancel Transaction (cancel_transaction) API is used to cancel a pre-authorized transaction.

Environment

Request parameters

ParameterReferenceExample
key mandatoryFor more information on how to generate the Key and Salt, refer to any of the following:

- Production: Generate Merchant Key and Salt

- Test: Generate Test Merchant Key and Salt
JP***g
command mandatoryThe API command name is cancel_transaction for this API.cancel_transaction
var1 mandatoryThis parameter must contain the payuId that was generated by PayU as part of pre-authorize operation.15246574846
var2 mandatoryThis parameter contain the token, that is, merchant unique reference number.Authorize123
hash mandatoryHash logic for this API is:
sha512(key|command|var1|salt)
sha512

Sample request

curl --location 'https://info.payu.in/merchant/postservice.php/?form=2' \
--header 'Authorization: Basic Og==' \
--header 'Cookie: PHPSESSID=60jf7q3aum9337hn1fjkgmr30p' \
--form 'key="smsplus"' \
--form 'hash="912b83345ad3ed35cece78cf7696f71aecf3b61189767e5a9267a23c953f0a4ad70e4b6b7552edbb3fd87f25c3b60f97c6532dcbde74c1df6d9170aa8ba09559"' \
--form 'var1="999000000008527"' \
--form 'var2="ad800ef0ccc2f4ad9aasd"' \
--form 'command="cancel_transaction"'

Response parameters

ParameterDescription
statusThis parameter returns the status of web service call. The status can be any of the following:

- 0 - If web service call failed
- 1 - If web service call succeeded
msgThis parameter returns the following message if the pre-auth transaction was successful: Capture Request Queued
txn_update_idThis parameter returns the transaction update ID for the transaction.
bank_ref_numThis parameter returns the bank reference number for the transaction.
error_codeThis parameter returns the error code for success or failure scenarios.

Sample response

Success scenario

{"status":1,"msg":"Cancelled Request Queued","txn_update_id":"4993824106405","bank_ref_num":null,"error_code":102}

Failure scenario

{"status":0,"msg":"Cancelled failed","error_code":105}