Install Java SDK
Integrating the PhonePe Java SDK(v 2.2.1) into your website is the first step toward enabling secure and reliable digital payments. The SDK provides all the necessary tools to seamlessly communicate with PhonePe’s APIs for transaction initiation, response handling, and more.
Prerequisites
Before you start the integration process, ensure you have:
- Access to PhonePe PG’s UAT (User Acceptance Testing) and Production environments.
- SDK credentials, including the Merchant ID, Client ID, Client Secret and Client Version.
- A testing environment to simulate the payment flow.
- Java 8 or above installed.
- Maven or Gradle configured as the project build tool.
To get started, add the SDK to your project using your preferred build tool: Maven or Gradle as shown below.
For Maven Users
- Open your project’s
pom.xmlfile. - Add the following dependency to include the SDK:
Code Reference
<dependency>
<groupId>com.phonepe</groupId>
<artifactId>pg-sdk-java</artifactId>
<version>2.2.1</version>
</dependency>For Gradle Users
- Open your project’s
build.gradlefile. - In the repositories section, add the URL for the PhonePe repository, and include the pg-sdk-java JAR in your dependencies.
Code Reference
dependencies {
implementation 'com.phonepe:pg-sdk-java:2.2.1'
}Onboarding
To get started with the keys, you will need three details. Reach out to the Integration team.
Credentials
String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = "<clientVersion>";