The SubscriptionClient class is designed for communicating with PhonePe APIs. An instance of this class can be initialized only once, and the necessary credentials must be provided during its initialization.
Disclaimer: For production builds don’t save credentials in code.
Parameters :
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
client_id | String | Yes | Client ID for secure communication with PhonePe. |
client_secret | String | Yes | Secret provided by PhonePe. To be kept secure on the merchant side. |
cient_version | Integer | Yes | Client version for secure communication with PhonePe. |
env | Env | Yes | Environment for the StandardCheckoutClient: Env.PRODUCTION (Production) Env.SANDBOX (Testing) |
Throws PhonePeException:
If a new SubscriptionClient is created with credentials different from the previous instance, a PhonePeException is thrown.
Example usage:
from phonepe.sdk.pg.env import Env
from phonepe.sdk.pg.subscription.v2.subscription_client import SubscriptionClient
client_id = "<YOUR_CLIENT_ID>"
client_secret = "<YOUR_CLIENT_SECRET>"
client_version = "<YOUR_CLIENT_VERSION>" # insert your client version here
env = Env.SANDBOX # change to Env.PRODUCTION when you go live
subscription_client = SubscriptionClient.get_instance(client_id=client_id,
client_secret=client_secret,
client_version=client_version,
env=env)