Subscription Redeem


The redeem() method is used to initiate a redemption against an active subscription. This action can only be performed after 24 hours have passed since the notify() method was called.

AttributeData TypeMandatoryDescription
merchantOrderIdStringYesUnique order ID generated by the merchant.
Code Reference
import com.phonepe.sdk.pg.subscription.v2.SubscriptionClient;
import com.phonepe.sdk.pg.subscription.v2.models.response.SubscriptionRedeemResponseV2;
 
String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = <clientVersion>;                      //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 merchantOrderId = "<MERCHANT_ORDER_ID>";     //Used at the time of notify()
 
SubscriptionRedeemResponseV2 subscriptionRedeemResponseV2 = subscriptionClient.redeem(merchantOrderId);

The function returns a SubscriptionRedeemResponseV2 object with the following properties:

Parameter NameData TypeDescription
stateStringState of the order.
transactionIdLongUnique transaction ID generated by PhonePe.

After initiating a redemption against an active subscription, let’s move on to understand how a subscription can be cancelled.

Is this article helpful?