Subscription Notify

The notify() method is used to send the subscription notification, by passing the below parameters in the builder: PgPaymentRequest.SubscriptionNotifyRequestBuilder()

Parameters

AttributeData TypeMandatoryDescriptionDefault Value
merchantOrderIdStringYes
Unique order ID generated by merchant
merchantSubscriptionIdStringYes
Unique subscription ID generated by merchant
amountLongYes
Amount of order in Paisa
1. FULL auth – first debit amount
2 . PENNY auth – 200
orderExpireAtLongNoOrder expireAt epoch after which order will auto fail if not terminal48 hours
redemptionRetryStrategyRedemptionRetryStrategyNoRedemption retry strategy in case attempts fail
1. STANDARD – Internal Retries
2. CUSTOM – Merchant needs to retry

STANDARD
autoDebitBooleanNoAuto debit redemption 24 hours after notify success
Can’t be true for CUSTOM redemptionRetryStrategy
false
metaInfoMetaInfoNoUser defines fields propagated in status check & callbacks

Example:

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 = 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 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

Returns:

The function returns a PgPaymentResponse object with the following properties:

PgPaymentResponse Properties:

Here is the response property table for the given model:

PropertyTypeDescription
orderIdStringUnique order ID generated by PhonePe
stateStringState of the order notified. It will be NOTIFICATION_IN_PROGRESS
expireAtLongOrder expire date in epoch