Refund

The refund() method is used to initiate the refund, by passing the below parameters in the builder: RefundRequest.builder()

Parameters:

Parameter nameData TypeMandatoryDescriptionConstraints
merchantRefundIdStringYesUnique merchant refund id generated by merchantMax Length = 63 characters
originalMerchantOrderIdStringYes
Original merchant order id against which refund is required
amountLongYesAmount in paisa to refundMin 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

PropertyData TypeDescription
refundIdStringPhonePe generated internal refund id
stateStringThe state of the refund initiated. Initially it will be PENDING
amountLongAmount in paisa that will be refunded