PG Refund

This method is used to initiate a transaction refund.


merchant_transaction_idstrYesThe merchant transaction ID for which the status is fetched
original_transaction_idstrYesMerchant transaction ID of the forward transaction to be reversed.
amountintYesReversal amount in paise, up to the maximum of the original payment transaction.
callback_urlstrNoURL for server-to-server callback. A POST request will be made.

For Python SDK Version <= 0.0.3, the imports should be:

For Python SDK Version > 0.0.3, the imports should be:

Example (Refund)

from import PhonePePaymentClient
from import Env

merchant_id = "<YOUR_MERCHANT_ID>"
salt_key = "<YOUR_SALT_KEY>"
salt_index = 1 # insert your salt index
env = Env.UAT
should_publish_events = True
phonepe_client = PhonePePaymentClient(merchant_id, salt_key, salt_index, env, should_publish_events)

unique_refund_transcation_id = str(uuid.uuid4())[:-2]
transaction_id_to_refund = "<TRANSACTION_ID_TO_REFUND>"
s2s_callback_url = ""
amount = 100
refund_response = phonepe_client.refund(merchant_transaction_id=unique_refund_transaction_id,


The function returns a PhonePeResponse object with the following properties:

successbooleanSuccess/failure of the request processing
codestrResponse code explaining the result
messagestrAdditional information about the response
dataPgRefundResponseInformation about the refund

PgRefundResponse properties

Here is the response property table for the given model:

merchant_idstrThe ID of the merchant associated with the transaction.
merchant_transaction_idstrThe unique identifier of the merchant transaction
transaction_idstrThe PhonePe unique identifier of the transaction.
amountintThe refunded amount
response_codestrThe response code indicating the status of the refund
statestrThe state of the refund transaction. Can be PENDING, COMPLETED, or FAILED.