This method is used to initiate a transaction refund.
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
merchantId | mixed | Yes | The ID of the merchant associated with the transaction. |
merchantTransactionId | mixed | Yes | Unique Refund Transaction ID generated by the merchant. This should be different from the transaction ID of the debit transaction. |
originalTransactionId | mixed | Yes | Merchant transaction ID of the forward transaction which needs to be reversed. |
amount | integer | Yes | Reversal amount in paise. Up to a maximum of the amount of the original payment transaction. |
callbackUrl | mixed | No | The 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:
Property | Type | Description |
---|---|---|
merchantId | mixed | The ID of the merchant associated with the transaction. |
merchantTransactionId | mixed | The unique identifier of the merchant transaction. |
transactionId | mixed | The unique identifier of the refund transaction. |
amount | integer | The refunded amount in paise [100 paise = 1 rupee]. |
state | mixed | The state of the refund transaction. |
responseCode | mixed | The response code indicates the status of the refund. |