Python 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 NameData TypeMandatoryDescription
client_idintyesClient ID for secure communication with PhonePe.
client_versionstryesClient version for secure communication with PhonePe.
client_secretstryesSecret provided by PhonePe. To be kept secure on the merchant side.
envstryesEnvironment for the StandardCheckoutClient: 
‘PRODDUCTION’ (production), 
‘SANDBOX’ (testing).


Throws PhonePeException

If another  CustomCheckoutClient  object is initialized, PhonePeException is thrown.

Example Usage :

from phonepe.sdk.pg.payments.v2.custom_checkout_client 
import CustomCheckoutClient

from phonepe.sdk.pg.env 
import Env
 
client_secret = "<YOUR_CLIENT_SECRET>"
client_id = "<YOUR_CLIENT_ID>"
client_version = 1  # insert your client version
env = Env.SANDBOX
should_publish_events = False

phonepe_client = CustomCheckoutClient.get_instance(client_id=client_id,
                                                   client_secret=client_secret,
                                                   client_version=client_version,
                                                   env=env,
                                                    should_publish_events=should_publish_events)
Is this article helpful?