Python SDK Installation


Integrating the PhonePe Python SDK(v 2.1.5) into your website is the first step toward enabling secure and reliable digital payments. The SDK supports creation of separate client instances for each set of credentials including client ID and client secret. The SDK maintains a list of initialized instances, and if the same credentials are used again, it returns the existing instance instead of creating a new one or throwing an exception.

To integrate the PhonePe Payment Gateway into your Python project, start by installing the phonepe_sdk package:

  • Open a terminal or command prompt.
  • Run the following command to install the phonepe_sdk package:
install phonepe_sdk package
pip install --index-url https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-sdk-python  --extra-index-url https://pypi.org/simple phonepe_sdk

What does this command mean?

  • –index-url : Specifies the primary package index URL for phonepe_sdk. It tells pip to download the package from Phone Payment Gateway’s official repository
  • –extra-index-url : Adds an additional index URL (PyPI) to search as a backup source for dependencies
  • phonepe_sdk : The name of the package being installed

This command will install the SDK from the specified repository. If everything is set up correctly, you can import and use the phonepe_sdk library in your Python projects.

Now that you’ve added the Python SDK to your project, the next step is to initialize the required classes.

Head over to the Class Initialization section to learn how to set it up properly.

Is this article helpful?