Introduction to Android SDK

An SDK (Software Development Kit) is a collection of tools and libraries that makes it easier for developers to add specific features or functionalities to their apps without starting from scratch.

The PhonePe Payment Gateway Android SDK helps you quickly integrate secure and reliable payment processing into your Android app. It handles all the complex parts of the payment flow, so you can focus on delivering a smooth experience to your users. With just a few lines of code, you can start accepting payments through various modes supported by PhonePe.

The PhonePe Android SDK supports multiple payment methods, including:

  • UPI
  • Cards
  • Net Banking
  • Wallets

With the Android SDK, you can deliver a seamless, app-native payment experience to your users.

This guide will walk you through everything, from setting up the SDK to initiating transactions and handling refunds.

Before you begin integrating the PhonePe Android SDK, ensure you have the following:

  • Android Studio installed (latest stable version recommended)
  • Basic knowledge of Java or Kotlin for Android development.
  • Android SDK version 5.2.1 
  • Project Requirements:
    • compileSdkVersion: 28 or higher
    • minSdkVersion: 21 or higher
    • targetSdkVersion: 28 or higher

Below is a step-by-step overview of how the integration process works:

  1. Customer initiates a payment from Android app.
  2. Your backend fetches an Auth Token using the Authorization API.
  3. Your backend creates a payment order using the Create Order API.
  4. The SDK is initialized from Android app.
  5. The app launches PhonePe checkout screen using the SDK.
  6. User completes the payment and is redirected back to your app.
  7. Your backend verifies the final payment status using Webhook or the Order Status API.

Use the environment URLs below to integrate and test your API calls. The Sandbox environment is intended for testing and validation, while the Production environment should be used once your integration is live. Make sure to switch the base URL based on the environment you’re working in.

EnvironmentAPI
Sandboxhttps://api-preprod.phonepe.com/apis/pg-sandbox
Productionhttps://api.phonepe.com/apis/identity-manager

Note: To ensure a smooth integration, please integrate with the Test environment first and then move to production.

Here’s a quick reference to the key APIs involved in the Android SDK integration flow. Each API plays a specific role, from initiating a transaction to handling refunds and fetching statuses. Use this table to understand which endpoint to call for each step in the payment lifecycle.

Endpoint Details:
APIMethodEndpoint
AuthorizationPOST/v1/oauth/token
Initiate PaymentPOST/payments/v2/sdk/order
Order Status APIGET/payments/v2/order/{merchantOrderId}/status
RefundPOST/payments/v2/refund
Refund Status APIPOST/payments/v2/refund/{merchantRefundId}/status
Is this article helpful?