1. Home
  2. Docs
  3. Developers Guide
  4. Integration APIs
  5. Refund APIs

Refund APIs

There are 4 kinds of APIs under refund APIs that helps merchant to cancel refund, get refund status of a one or more request against a particular transaction ID

  1. check_action_status (1ST Usage)
  2. check_action_status (2nd Usage)
  3. getAllRefundsFromTxnIds
  4. cancel_refund_transaction

1. check_action_status (1ST Usage)

This API is used to check the status of refund/cancel requests. Whenever the cancel_refund_transaction API is executed successfully, a Request ID is returned in the output parameters for that particular request. In check_action_status API, you need to input this Request ID to get the current status of the request. The return parameters are MIHPayID, Amount, Discount, Mode, and Status of transaction.

ParameterDescriptionValue
keyMerchant key provided by PayU. Please refer to the first entry in the Post Parameters table for a detailed description of this parameter JPTXg
command This parameter must have the name of the web-service. check_action_status
var1 In this parameter, you can
request_id
131278422
hashThis parameter must contain the hash value to be calculated at your end. The string used for calculating the hash is mentioned below:
sha512(key|command|var1|salt)
sha512 is the encryption method used here
2a04a44ed058ca724a
17b4e4d4639aa15254a
343e0

Request body

curl -X POST "https://test.payu.in/merchant/postservice?form=2
-H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d

"key=JP***g&command=check_action_status&var1=131278422&hash=2a04a44ed058ca724a17b4e4d4639aa15254a343e047c9085687810d815845aed5183ae7792adbc8c9c4991f978ee2f15ea4284706dfa3fbcd42d36491369848"

Response

  • if mihpayid isn’t found
{
      "status": 0,
      "msg": "0 out of 1 Transactions Fetched Successfully",
      "transaction_details": {
            "13127842": "No action status found"
      }
}
  • if mihpayid is missing
{
      "status": 0,
      "msg": "Parameter missing"
}
  • if successfully fetched
{
      "status": 1,
      "msg": "1 out of 1 Transactions Fetched Successfully",
      "transaction_details": {
            "131278422": {
                  "131278422": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278422",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  }
            }
      }
}

2. check_action_status (2nd Usage)

This command has a second usage also. For a particular PayUID, it returns the status of all requests (capture/refund/cancel).

ParameterDescriptionValue
keyMerchant key provided by PayU. Please refer to the first entry in the Post Parameters table for a detailed description of this parameter JPTXg
command This parameter must have the name of the web-service. check_action_status
var1
Payu ID (mihpayid) of transaction

8000123

var2
String Payuid i.e. ‘payuid’ payuid
hashThis parameter must contain the hash value to be calculated at your end. The string used for calculating the hash is mentioned below:
sha512(key|command|var1|salt)
sha512 is the encryption method used here
c24ee06c7cf40314ede424
b1fcc2b97a12f97a7d3dd2
06876eef16660eb09fd374
fd82861f66d8152e

Request body

curl -X POST "https://test.payu.in/merchant/postservice?form=2
-H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d

"key=JP***g&command=check_action_status&var1=403993715521937565&var2=payuid&hash=81bdb5b8e625f254398d744269844fc6b9d87b3782670331c2a6b856f42f315b9898f397df7292cfd33a6153abf4acac58ce3ac671e41999ff81d98ce432f48e"

Response

  • If successfully fetched
{
      "status": 1,
      "msg": "1 out of 1 Transactions Fetched Successfully",
      "transaction_details": {
            "403993715521937565": {
                  "131278418": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "399900",
                        "request_id": "131278418",
                        "amt": "100.00",
                        "mode": "CC",
                        "action": "capture",
                        "token": "",
                        "status": "SUCCESS",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "-"
                  },
                  "131278422": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278422",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131278430": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278430",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131278458": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278458",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131278471": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278471",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131278484": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278484",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131278499": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278499",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131278515": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131278515",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131287648": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131287648",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131295795": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131295795",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  },
                  "131297379": {
                        "mihpayid": "403993715521937565",
                        "bank_ref_num": "527013524405",
                        "request_id": "131297379",
                        "amt": "10.00",
                        "mode": "CC",
                        "action": "refund",
                        "token": "20201105secrettokenatur",
                        "status": "success",
                        "bank_arn": null,
                        "settlement_id": null,
                        "amount_settled": null,
                        "UTR_no": null,
                        "value_date": null,
                        "refund_mode": "Back to Source"
                  }
            }
      }
}

3. getAllRefundsFromTxnIds

This command is used to retrieve status of all the refund requests fired for a particular Transaction ID. The output of this API provides the request ID, the PG used, the status of refund request and creation of refund date information.

ParameterDescriptionValue
keyMerchant key provided by PayU. Please refer to the first entry in the Post Parameters table for a detailed description of this parameter JPTXg
command This parameter must have the name of the web-service. getAllRefundsFromTxnIds
var1 In this parameter, you need to pass the Transaction ID (txnid) of the transaction.
8000123
hashThis parameter must contain the hash value to be calculated at your end. The string used for calculating the hash is mentioned below:
sha512(key|command|var1|salt)
sha512 is the encryption method used here
c24ee06c7cf40314ede424
b1fcc2b97a12f97a7d3dd2
06876eef16660eb09fd374
fd82861f66d8152e

Request body

curl -X POST "https://test.payu.in/merchant/postservice?form=2
-H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d

"key=JP***g&command=getAllRefundsFromTxnIds&var1=db97dd56eff7296e5061&hash=69543c08018121cc882d2f8b1761567367c1806becde3db7f54ab552362677cc08d8dfa4b9411e234e4876e6aba80c05a32e75ed499aff458c7f6027bf4ef2a8"

Response

  • If successfully fetched
{
      "status": 1,
      "msg": "Refunds fetched successfully.",
      "Refund Details": {
            "403993715521937565": [
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131278422",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-05 01:23:19",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2020-11-05 01:24:04"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131278430",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-05 01:29:13",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2020-11-05 01:30:08"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131278458",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-05 01:47:36",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2020-11-05 01:49:04"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131278471",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-05 01:53:28",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2020-11-05 01:55:05"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131278484",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-05 01:58:32",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2020-11-05 02:00:09"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131278499",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-05 02:05:42",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2020-11-05 02:07:04"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131278515",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-05 02:15:11",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2020-11-05 02:16:03"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131287648",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-06 19:21:32",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2021-01-28 10:25:17"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131295795",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-09 18:59:45",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2021-02-10 01:01:14"
                  },
                  {
                        "PayuID": "403993715521937565",
                        "RequestID": "131297379",
                        "RefundToken": "20201105secrettokenatur",
                        "PaymentGateway": "AXISPG",
                        "Amount": "10.00",
                        "Status": "success",
                        "RefundCreationDate": "2020-11-10 09:39:33",
                        "bank_ref_no": "527013524405",
                        "bank_arn": null,
                        "success_at": "2021-02-01 15:50:25"
                  }
            ]
      }
}
  • If no refunds found
{
      "status": 1,
      "msg": "No Refunds Found for the transaction."
}

4. cancel_refund_transaction

This API can be used for 2 different purposes:

  • To cancel a transaction that is in ‘auth’ state at the moment
  • To refund a transaction that is in a ‘captured’ state at the moment.
  • In this API var1 is Payu ID (mihpayid) of the transaction, var2 should contain the Token ID (unique token from the merchant) and var3 parameter should contain the amount which needs to be refunded.
ParameterDescriptionValue
keyMerchant key provided by PayU. Please refer to the first entry in the Post Parameters table for a detailed description of this parameter JPTXg
command This parameter must have the name of the web-service. cancel_refund_transaction
var1 Payu ID (mihpayid) of transaction 8000123
var2 This parameter should contain the Token ID (unique token from merchant) for the refund request. Token ID has to be generated at your end for each new refund request. It is an identifier for each new refund request which can be used for tracking it. It must be unique for every new refund request generated – otherwise the refund request would not be generated successfully.
Token ID length should not be greater than 23 characters

7800456
var3 For captured transaction:
This parameter should contain the amount which needs to be refunded. Please note that both partial and full refunds are allowed.
Hence, for partial refund, this var3 value would be less than the amount with which the transaction was made. For full refund, var3 value would be equal to the amount with which the transaction was made.
For pre-auth transaction:
If the transaction is in pre-auth state currently, then only a full cancellation is allowed. The amount must be same as the auth amount. Partial amount would not be allowed.

500
hashThis parameter must contain the hash value to be calculated at your end. The string used for calculating the hash is mentioned below:
sha512(key|command|var1|salt)
sha512 is the encryption method used here
2a04a44ed058ca724a
17b4e4d4639aa15254a
343e0

Request body

curl -X POST "https://test.payu.in/merchant/postservice?form=2
-H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d

"key=JP***g&command=cancel_refund_transaction&var1=403993715521937565&var2=20201105secrettokenaturend&hash=10"

Response

  • if token is missing
{
      "status": 0,
      "msg": "token is empty",
      "mihpayid": "403993715521937565"
}
  • if the amount is missing
Array 
(
[status] => 0
[msg] => amount is empty 
)
  • if the transaction isn’t found
Array 
(
[status] => 0
[msg] => transaction not exists 
)

  • on successful processing at our end
Array 
(
      [status] => 1
      [msg] => Cancel Request Queued 
      [txn_update_id] => Request ID 
      [bank_ref_num] => Bank Reference Number 
      [mihpayid] => PayU Transaction id
)
  • on successful processing on our end for captured transactions
Array 
(
     [status] => 1
     [msg] => Refund Request Queued 
     [request_id] => Request ID 
     [bank_ref_num] => Bank Reference Number 
     [mihpayid] => PayU Transaction id

)
  • if failed to refund
Array 
(
       [status] => 0
       [msg] => Refund request failed
)
  • if capture is done on the same day
Array 
(
    [status] => 1
    [msg]=> Capture is done today, please check for refund status tomorrow 
    [request_id] => Request ID
    [bank_ref_num] => Bank Reference Number
    [mihpayid] => PayU ID
)
  • if invalid token
Array 
(
    [status] => 0
    [msg] => token already used or request pending 
)
  • on successful processing at PayU end for auth transactions
Array 
(
    [status] => 1
    [msg] => Cancel Request Queued 
    [txn_update_id] => Request ID 
    [bank_ref_num] => Bank Reference Number
)
  • if failed to cancel a transaction
Array 
(
     [status] => 0
     [msg] => Cancel request failed
)