Java Class Initialization
Overview
Class Initialization sets up the PhonePe Java SDK client using your credentials. This step creates a single client instance that handles all API communications securely throughout the application runtime.
Request
- The
CustomCheckoutClientclass is used to interact with PhonePe APIs. Only one instance of this client should be created per runtime. Make sure to use the correct credentials when initializing to avoid exceptions.
| Parameter Name | Data Type | Mandatory (Yes/No) | Description |
clientId | Integer | Yes | Your unique Client ID for secure communication with PhonePe Payment Gateway. |
clientVersion | String | Yes | Your unique Client Version for secure communication with PhonePe Payment Gateway. |
clientSecret | String | Yes | Secret provided by PhonePe. |
env | Env | Yes | Environment for the client: • PRODUCTION • SANDBOX |
Exceptions
- Throws
PhonePeExceptionif an attempt is made to initialize more than oneCustomCheckoutClientinstance.
Code Reference
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.payments.v2.CustomCheckoutClient;
String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = <clientVersion>; //insert your client version here
Env env = Env.SANDBOX; //change to Env.PRODUCTION when you go live
CustomCheckoutClient customCheckoutClient = CustomCheckoutClient.getInstance(clientId, clientSecret,clientVersion, env);