PG Refund

This method is used to initiate a transaction refund.

Parameters

ParameterTypeMandatoryDescription
merchantIdmixedYesThe ID of the merchant associated with the transaction.
merchantTransactionIdmixedYesUnique Refund Transaction ID generated by the merchant. This should be different from the transaction ID of the debit transaction.
originalTransactionIdmixedYesMerchant transaction ID of the forward transaction which needs to be reversed.
amountintegerYesReversal amount in paise. Up to a maximum of the amount of the original payment transaction.
callbackUrlmixedNoThe URL where PhonePe will send callback notifications after the refund is completed.

Example (Refund)

const $MERCHANTID="<merchantId>"; const $SALTKEY="<saltKey>"; const $SALTINDEX="<saltIndex>"; const $env=Env::UAT; const $SHOULDPUBLISHEVENTS=true; $phonePePaymentsClient = new PhonePePaymentClient(MERCHANTID, SALTKEY, SALTINDEX, Env::UAT, SHOLDPUBLISHEVENTS); $pgRefundRequest = PgRefundRequestBuilder::builder() ->originalTransactionId("<originalTransactionId>") ->merchantId(MERCHANTID) ->merchantTransactionId("<merchantTransactionId>") ->callbackUrl("https://webhook.in/test/status") ->amount(<amountInPaise>) ->build(); $response = $phonePePaymentsClient->refund($pgRefundRequest); $responseCode = $response->getResponseCode();

Returns

The function returns a PgRefundResponse object with the following properties:

PgRefundResponse properties

Here is the response property table for the given model:

PropertyTypeDescription
merchantIdmixedThe ID of the merchant associated with the transaction.
merchantTransactionIdmixedThe unique identifier of the merchant transaction.
transactionIdmixedThe unique identifier of the refund transaction.
amountintegerThe refunded amount in paise [100 paise = 1 rupee].
statemixedThe state of the refund transaction.
responseCodemixedThe response code indicates the status of the refund.