Introduction

This document provides a guide for merchants to integrate the PhonePe Standard Checkout Backend PHP SDK. This SDK facilitates seamless integration with PhonePe’s payment gateway for processing payments, refunds, and handling callback verifications.

Note:

  • Supported and can be tested in Production only
  • Supported only for API based integration

Prerequisites

  • PHP 8.2 or higher.
  • Composer installed for dependency management.
  • A PhonePe merchant account with the necessary credentials (Client ID, Client Version, Client Secret).

Installation

Mandatory Step

Before proceeding with the installation steps below, add the following repository details to your project’s root directory within the composer.json file. This step is mandatory to fetch the PhonePe PHP SDK package.

{
 "repositories": [
      {
        "type": "package",
        "url": "./vendor/phonepe/pg-sdk-php/",
        "package": {
          "name": "phonepe/pg-php-sdk-v2",
          "version": "2.0.0",
          "dist": {
            "url": "https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-php-sdk/v2-sdk.zip",
            "type": "zip"
          },
          "autoload": {
            "classmap": ["/"]
          }
        }
      }
    ],

    "require": {
        "phonepe/pg-php-sdk-v2": "^2.0",
        "vlucas/phpdotenv": "^5.6",
        "netresearch/jsonmapper": "^4.4"
    }
}

1. Using Composer:
Add the PhonePe PHP SDK as a dependency to your project using Composer:

composer install

2. Manual Installation (Not Recommended):

Download the SDK source code and manually include the necessary files in your project. This method is not recommended as it requires manual dependency management. And if you do, make sure you also add vlucas/phpdotenv and netresearch/jsonmapper dependency as well.

Onboarding

To get your client ID and secret, refer to the PhonePe business dashboard in Production.

String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = "<clientVersion>";