The refund() method is used to initiate the refund, by passing the below parameters in the builder: RefundRequest.builder()
Parameters:
Parameter name | Data Type | Mandatory | Description | Constraints |
---|---|---|---|---|
| String | Yes | Unique merchant refund id generated by merchant | Max Length = 63 characters |
originalMerchantOrderId | String | Yes | Original merchant order id against which refund is required | |
amount | Long | Yes | Amount in paisa to refund | Min value = 100 (in paise), Max value = order amount |
Example Usage:
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.common.models.request.RefundRequest;
import com.phonepe.sdk.pg.common.models.response.RefundResponse;
import com.phonepe.sdk.pg.subscription.v2.SubscriptionClient;
String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = 1; //insert your client version here
Env env = Env.SANDBOX; //change to Env.PRODUCTION when you go live
SubscriptionClient subscriptionClient = SubscriptionClient.getInstance(clientId, clientSecret,
clientVersion, env);
String merchantRefundId = UUID.randomUUID()
.toString();
String originalMerchantOrderId = "<merchantOrderId>";
long amount = 100;
RefundRequest refundRequest = RefundRequest.Builder()
.merchantRefundId(merchantRefundId)
.originalMerchantOrderId(merchantOrderId)
.amount(amount)
.build();
RefundResponse refundResponse = subscriptionClient.refund(refundRequest);
String state = refundResponse.getState();
Returns :
The function returns a RefundResponse
Object
Property | Data Type | Description |
---|---|---|
refundId | String | PhonePe generated internal refund id |
state | String | The state of the refund initiated. Initially it will be PENDING |
amount | Long | Amount in paisa that will be refunded |