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()
Required Parameters
| Attribute | Data Type | Mandatory | Description | Default Value |
| String | Yes | Unique order ID generated by the merchant. | |
| String | Yes | Unique subscription ID generated by the merchant. | |
| Int | Yes | Amount in Paisa (FULL auth – first debit amount, PENNY auth – 200). | |
| Int | No | Epoch timestamp; the order will automatically fail if not completed within the given time (default is 10 minutes). | 48hrs |
| RedemptionRetryStrategy | No | STANDARD or CUSTOM | STANDARD |
| Boolean | No | true or false | False |
meta_info | MetaInfo | No | User-defined fields for status checks and callbacks |
Example Code
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_PROGRESSReturn Values
The function returns a PgPaymentResponse object with the following properties:
| Parameter Name | Data Type | Description |
| String | Unique order ID generated by PhonePe. |
| String | State of the order. It will be NOTIFICATION_IN_PROGRESS. |
| expire_at | Long | Epoch time when the order will expire. |
What’s Next ?
Now that the subscription has been notified, let’s explore how to redeem it. Head to the next section to understand the redemption process.