Class Initialization

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 NameData TypeMandatoryDescription
clientIdStringYesClient ID for secure communication with PhonePe.
clientSecretStringYesSecret provided by PhonePe. To be kept secure on the merchant side.
clientVersionIntegerYesClient version for secure communication with PhonePe.
envEnvYesEnvironment 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);