The notify() method is used to send the subscription notification, by passing the below parameters in the builder: PgPaymentRequest.SubscriptionNotifyRequestBuilder()
Parameters
Attribute | Data Type | Mandatory | Description | Default Value |
---|---|---|---|---|
merchantOrderId | String | Yes | Unique order ID generated by merchant | |
| String | Yes | Unique subscription ID generated by merchant | |
amount | Long | Yes | Amount of order in Paisa 1. FULL auth – first debit amount 2 . PENNY auth – 200 | |
orderExpireAt | Long | No | Order expireAt epoch after which order will auto fail if not terminal | 48 hours |
| RedemptionRetryStrategy | No | Redemption retry strategy in case attempts fail 1. STANDARD – Internal Retries 2. CUSTOM – Merchant needs to retry | STANDARD |
autoDebit | Boolean | No | Auto debit redemption 24 hours after notify success Can’t be true for CUSTOM redemptionRetryStrategy | false |
metaInfo | MetaInfo | No | User 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:
Property | Type | Description |
---|---|---|
orderId | String | Unique order ID generated by PhonePe |
state | String | State of the order notified. It will be NOTIFICATION_IN_PROGRESS |
expireAt | Long | Order expire date in epoch |