The refund() method is used to initiate the refund, by passing the below parameters in the builder: RefundRequest.build_refund_request()
Parameters:
Parameter name | Data Type | Mandatory | Description | Constraints |
---|---|---|---|---|
| Str | Yes | Unique merchant refund id generated by merchant | Max Length = 63 characters |
original_merchant_order_id | Str | Yes | Original merchant order id against which refund is required | |
amount | Int | Yes | Amount in paisa to refund | Min value = 100 (in paise), Max value = order amount |
Example Usage:
import uuid
from phonepe.sdk.pg.common.models.request.refund_request import RefundRequest
from phonepe.sdk.pg.subscription.v2.subscription_client import SubscriptionClient
client_id = "<client_id>"
client_secret = "<client_secret>"
client_version = 1 # insert your client version here
env = Env.SANDBOX # change to Env.PRODUCTION when you go live
subscription_client = SubscriptionClient.get_instance(client_id, client_secret, client_version, env)
merchant_refund_id = str(uuid.uuid4())
original_merchant_id = "<merchant_order_id>"
amount = 100
refund_request = RefundRequest.build_refund_request(merchant_refund_id, amount, original_merchant_id)
refund_response = subscription_client.refund(refund_request)
state = refund_response.state
Returns :
The function returns a RefundResponse
Object
Property | Data Type | Description |
---|---|---|
refund_id | Str | PhonePe generated internal refund id |
state | Str | The state of the refund initiated. Initially it will be PENDING |
amount | Int | Amount in paisa that will be refunded |