Refund

<html-block html=”

Request Headers

“>

Header NameHeader Value
Content-Typeapplication/json
X-VERIFYSHA256(base64 encoded payload + “/v3/credit/backToSource” + salt key) + ### + salt index
{
    "merchantId": "DemoMerchant",
    "transactionId": "TX123456789",
    "providerReferenceId": "PPXXXXX",
    "amount": 100,
    "merchantOrderId": "OD1234",
    "subMerchant": "DemoMerchant",
    "message": "refund for cancelled order"
}
{
  "request": "eyJtZXJjaGFudE9yZGVySWQiOiAiT0QxMjM0IiwgInN1Yk1lcmNoYW50IjogIkRlbW9NZXJjaGFudCIsICJhbW91bnQiOiAxMDAsICJtZXNzYWdlIjogInJlZnVuZCBmb3IgY2FuY2VsbGVkIG9yZGVyIiwgIm1vYmlsZU51bWJlciI6ICI5eHh4eHh4eHh4IiwgInNob3J0TmFtZSI6ICJBbWl0IiwgInRyYW5zYWN0aW9uSWQiOiAiVFgxMjM0NTY3ODkiLCAibWVyY2hhbnRVc2VySWQiOiAiVTEyMzQ1Njc4OSIsICJtZXJjaGFudElkIjogIkRlbW9NZXJjaGFudCIsICJlbWFpbCI6ICJhbWl0eHh4NzVAZ21haWwuY29tIn0"
}

<html-block html=”

Request Parameters

“>

Parameter NameTypeDescriptionMandatory
merchantIdSTRINGUnique Merchant ID assigned to the merchant by PhonePeYes
transactionIdSTRINGUnique Transaction ID generated by the merchant to track this request to PhonePe.
This should be different from transaction ID of debit transaction.
Yes
originalTransactionIdSTRINGMerchant transaction Id of forward transaction which needs to be reversed.Yes
providerReferenceIdSTRINGPhonePe transaction id of the original forward payment.
Note : use only one of originalTransactionId, providerReferenceId only
Yes
amountLONGReversal amount in paise. Upto a max of amount of original payment transaction.Yes
merchantOrderIdSTRINGOrder ID for the merchant transactionYes
subMerchantSTRINGTag to categorize merchant transactionNo
messageSTRINGShort messageYes

<html-block html=”

Response Parameters

“>

Parameter NameTypeDescription
successBOOLEANSuccess status of the request
codeENUMSee list of response codes below
messageSTRINGShort message about code
transactionIdSTRINGUnique Transaction ID generated by the merchant to track this request to PhonePe
merchantIdSTRINGUnique Merchant ID assigned to the merchant by PhonePe
amountLONGTransaction amount in paise
statusSTRINGStatus of the request
mobileNumberSTRINGMobile number of the user
providerReferenceIdSTRINGPhonePe payment transaction id against which the reversal is to be done
payResponseCodeSTRINGPhonePe internal status code

<html-block html=”

Refund API Response Codes

“>

CodeDescription
BAD_REQUESTInvalid request
AUTHORIZATION_FAILEDX-VERIFY header is incorrect
TRANSACTION_NOT_FOUNDOriginal transaction not found
INTERNAL_SERVER_ERRORSomething went wrong. Refund might get initiated (need to check status with check transaction status API before retrying the refund)
PAYMENT_SUCCESSPayment is successful
PAYMENT_ERRORPayment failed
PAYMENT_PENDINGPayment is pending. It does not indicate failed payment. Refund might get initiated (need to check status with check transaction status API before retrying the refund)
TIMED_OUTRefund timed out. Refund might get initiated (need to check status with check transaction status API before retrying the refund)
DUPLICATE_TXN_REQUESTIf the transaction id is used already for refund request.
EXCESS_REFUND_AMOUNTIf the amount requested for refund is more than forward payment or If refund is already done
WALLLET_NOT_ACTIVATEDIf the user has disabled the wallet. Contact user to know the source for refund.
API_RATE_LIMIT_REACHEDIf the API call limit is breached then HTTP status code 429 would be sent
{“method”:”post”,”url”:”/v3/credit/backToSource”,”auth”:”required”,”apiSetting”:”5da600be463ecf036287d7f3″,”examples”:{“codes”:[]},”results”:{“codes”:[{“status”:200,”language”:”json”,”code”:”{\n \”success\”: true,\n \”code\”: \”PAYMENT_SUCCESS\”,\n \”message\”: \”Your payment is successful.\”,\n \”data\”: {\n \”transactionId\”: \”TX123456789\”,\n \”merchantId\”: \”DemoMerchant\”,\n \”amount\”: 100,\n \”status\”: \”SUCCESS\”,\n \”mobileNumber\”: \”9xxxxxxxxxx\”,\n \”providerReferenceId\”: \”PPXXXXX\”,\n \”payResponseCode\”: \”SUCCESS\”\n }\n}”,”name”:””},{“status”:400,”language”:”json”,”code”:”{}”,”name”:””}]},”params”:[{“name”:”X-VERIFY”,”type”:”string”,”enumValues”:””,”default”:””,”desc”:”SHA256(base64 encoded payload + \”/v3/credit/backToSource\” + salt key) + ### + salt index”,”required”:false,”in”:”header”,”ref”:””,”_id”:”5da630538c9ac0005e221d34″},{“name”:”Content-type”,”type”:”string”,”enumValues”:””,”default”:”application/json”,”desc”:””,”required”:false,”in”:”header”,”ref”:””,”_id”:”5da630662131d800188e6a5f”},{“name”:”request”,”type”:”string”,”enumValues”:””,”default”:””,”desc”:”base64 encoded payload”,”required”:false,”in”:”body”,”ref”:””,”_id”:”5da6307fdc0eb90065a3875d”},{“name”:”X-CLIENT-ID”,”type”:”string”,”enumValues”:””,”default”:””,”desc”:”This will vary corresponding to the merchants. The default value will be merchant ID”,”required”:false,”in”:”header”,”ref”:””,”_id”:”5da6b5bce8fd8600337aefba”}]}
https://apps-uat.phonepe.com