Subscription Notify


The notify() method is used to send a subscription notification request. This initiates a debit request from a previously set up subscription by passing the required parameters using PgPaymentRequest.SubscriptionNotifyRequestBuilder().

AttributeData TypeMandatoryDescriptionDefault Value
merchantOrderIdStringYesUnique order ID generated by the merchant.
merchantSubscriptionIdStringYesUnique subscription ID generated by the merchant.
amountLongYesAmount in Paisa (FULL auth – first debit amount, PENNY auth – 200).
orderExpireAtLongNoEpoch timestamp; the order will automatically fail if not completed within the given time (default is 10 minutes).48hrs
redemptionRetryStrategyRedemptionRetryStrategyNoSTANDARD or CUSTOMSTANDARD
autoDebitBooleanNotrue or falseFalse
meta_infoMetaInfoNoUser-defined fields for status checks and callbacks
Code Reference
import com.phonepe.sdk.pg.common.models.request.PgPaymentRequest;
import com.phonepe.sdk.pg.common.models.response.PgPaymentResponse;
import com.phonepe.sdk.pg.subscription.v2.SubscriptionClient;
import com.phonepe.sdk.pg.subscription.v2.models.request.RedemptionRetryStrategy;
 
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 = UUID.randomUUID().toString();
String merchantSubscriptionId = "<MERCHANT_SUBSCRIPTION_ID>";       //Use same subscription ID created at the time of setup
RedemptionRetryStrategy redemptionRetryStrategy = RedemptionRetryStrategy.STANDARD;
boolean autoDebit = false;
long amount = 100;
 
PgPaymentRequest notifyRequest = PgPaymentRequest.SubscriptionNotifyRequestBuilder()
        .merchantOrderId(merchantOrderId)
        .merchantSubscriptionId(merchantSubscriptionId)
        .autoDebit(autoDebit)
        .redemptionRetryStrategy(redemptionRetryStrategy)
        .amount(amount)
        .build();
 
 
PgPaymentResponse notifyResponse = subscriptionClient.notify(notifyRequest);
String state = notifyResponse.getState();           //state will be NOTIFICATION_IN_PROGRESS

The function returns a PgPaymentResponse object with the following properties:

Parameter NameData TypeDescription
orderIdStringUnique order ID generated by PhonePe.
stateStringState of the order. It will be NOTIFICATION_IN_PROGRESS.
expireAtLongEpoch time when the order will expire.

Now that the subscription has been notified, let’s explore how to redeem it. Head to the next section to understand the redemption process.

Is this article helpful?