NodeJs SDK – Class Initialization
Class Initialization
CustomCheckoutClient class will be used to communicate with the PhonePe APIs. You can initiate the instance of this class only once.
Use required credentials while initializing the object.
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. |
cientVersion | Integer | yes | Client version for secure communication with PhonePe. |
env | Env | yes | Environment for the CustomCheckoutClient: ‘PRODUCTION’ (production), ‘SANDBOX’ (testing). |
Throws PhonePeException
If another CustomCheckoutClient object is initialized, PhonePeException is thrown.
Example
import {CustomCheckoutClient, Env}
from 'pg-sdk-node';
const clientId:string = "<clientId>";
const clientSecret:string = "<clientSecret>";
const clientVersion:string = "<clientVersion>"; //insert your client version here
const env:Env = Env.SANDBOX; //change to Env.PRODUCTION when you go live
const client = CustomCheckoutClient.getInstance(clientId, clientSecret, clientVersion, env);