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 |
---|---|---|---|
clientId | String | Yes | Client ID for secure communication with PhonePe. |
clientSecret | String | Yes | Secret provided by PhonePe. To be kept secure on the merchant side. |
clientVersion | 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:
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.subscription.v2.SubscriptionClient;
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);