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.build_subscription_notify_request()

AttributeData TypeMandatoryDescriptionDefault Value
merchant_order_idStringYesUnique order ID generated by the merchant.
merchant_subscription_idStringYesUnique subscription ID generated by the merchant.
amountIntYesAmount in Paisa (FULL auth – first debit amount, PENNY auth – 200).
order_expire_atIntNoEpoch timestamp; the order will automatically fail if not completed within the given time (default is 10 minutes).48hrs
redemption_retry_strategyRedemptionRetryStrategyNoSTANDARD or CUSTOMSTANDARD
auto_debitBooleanNotrue or falseFalse
meta_infoMetaInfoNoUser-defined fields for status checks and callbacks
Code Reference
import uuid
from phonepe.sdk.pg.common.models.request.pg_payment_request import PgPaymentRequest
from phonepe.sdk.pg.subscription.v2.subscription_client import SubscriptionClient
from phonepe.sdk.pg.subscription.v2.models.request.redemption_retry_strategy import RedemptionRetryStrategy
 
client_id = "<cliend_id>"
client_secret = "<client_secret>"
client_version = <clientVersion>
env = Env.SANDBOX
 
subscription_client = SubscriptionClient.get_instance(client_id, client_secret, client_version, env)
 
merchant_order_id = str(uuid.uuid4())
merchant_subscription_id = "<MERCHANT_SUBSCRIPTION_ID>"
redemption_retry_strategy = RedemptionRetryStrategy.STANDARD
auto_debit = False
amount = 100
 
notify_request = PgPaymentRequest.build_subscription_notify_request(
    merchant_order_id=merchant_order_id,
    merchant_subscription_id=merchant_subscription_id,
    auto_debit=auto_debit,
    redemption_retry_strategy=redemption_retry_strategy,
    amount=amount
)
 
notify_response = subscription_client.notify(notify_request)
state = notify_response.state            #state will be NOTIFICATION_IN_PROGRESS

The function returns a PgPaymentResponse object with the following properties:

Parameter NameData TypeDescription
order_idStringUnique order ID generated by PhonePe.
stateStringState of the order. It will be NOTIFICATION_IN_PROGRESS.
expire_atLongEpoch 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?