Introduction to Autopay Java SDK


The PhonePe Java SDK (v 2.1.8) for Autopay simplifies server-side integration with the PhonePe Payment Gateway for recurring payments. It offers a simple, secure, and efficient way to manage autopay transactions, allowing you to focus on delivering seamless and engaging user experiences.

The following user journey illustrates the complete payment lifecycle to help you understand the integration flow clearly.

Before you start the integration process, ensure you have:

  • Access to PhonePe PG’s UAT (User Acceptance Testing) and production environments.
  • A testing environment to simulate the payment flow.
  • Java 8 or higher installed on your system.

This section guides you through setting up the PhonePe Java SDK for Autopay in projects using Maven and Gradle. It includes the necessary dependencies and repository configuration to get started. Additionally, test credentials are provided to help you simulate and validate integration flows before going live.

Setting Up the SDK with Maven

Add the dependency to your project’s POM file:

Add the dependency to your project
<dependency>
    <groupId>com.phonepe</groupId>
    <artifactId>pg-sdk-java</artifactId>
    <version>2.1.8</version>
</dependency>

Add the following to your project’s build.gradle file.

include the PhonePe repository URL under the repositories section, and add the pg-sdk-java JAR under dependencies.

Add the following to you project
dependencies {
    implementation 'com.phonepe:pg-sdk-java:2.1.8'
}

To get started with the integration, you’ll need three essential details: the API key, merchant ID, and secret key. Reach out to the Integration team to obtain these credentials for testing.

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

The introduction has provided you with a broad overview of setting up the Java SDK. Now, let’s move forward with Class Initialisation to begin integrating the SDK into your application.

Head over to Class Initialisation, the first step to begin the integration process.

Is this article helpful?