SDK Setup


This section explains how your app integrates the PhonePe Android SDK(v5.3.0) to initiate a payment. It covers the flow from fetching the SDK token to retrieving saved instruments and processing the transaction.

You can also you use the Demo App: https://github.com/PhonePe/phonepe-pg-android-demo

Make sure your project uses the following SDK versions:

  • compileSdkVersion: 28
  • minSdkVersion: 21
  • targetSdkVersion: 28
  • Add the below code to ‘repositories’ section of your project level build.gradle file
configurations:
Top-level build file where you can add configuration options common to all sub-projects/modules.

allprojects {
   repositories {
       google()
       maven {
       	url = uri("https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android")
       }
   }
}
  • Add the below line to the ‘dependencies’ section of your app level build.gradle file
dependencies:
implementation 'phonepe.intentsdk.android.release:IntentSDK:5.3.0'
  • Initialize the SDK on launch of your application (Application class) or launch of your checkout activity. This needs to be done before calling any method of Phonepe SDK. This doesn’t block Main Thread
// kotlin

import com.phonepe.intent.sdk.api.PhonePeKt

val result = PhonePeKt.init(
  context = this,
  merchantId = "MID",
  flowId = "FLOW_ID",
  phonePeEnvironment = PhonePeEnvironment.SANDBOX,
  enableLogging = false,
  appId = null 
)

 if(result){
  // Good to go
 }
 else {
  // Some error occurred in SDK. Report it to PhonePe Integration team.
  // NOTE: SDK is not in the state to use. Hence, no other method should be called.
}
Parameter NameTypeDescription
contextObjectPass your activity context
merchantIdStringThe merchantId shared by PhonePe
flowIdStringPass the merchant user Id or a unique alphanumeric random string
phonePeEnvironmentEnumValues Allowed:
– PhonePeEnvironment.SANDBOX (For PreProd)
– PhonePeEnvironment.RELEASE (For Prod)
enableLoggingBoolean[Optional Parameter]
– True (To enable the SDK logs)
– False (To disable the SDK logs)
Note: In Prod, make sure to set as False.
appIdString[Optional Parameter]
– Can be passed as null or “” also.

In the next section, you will learn how to generate an auth token.

Head over to the next section to learn how to securely authenticate your API requests using our Authorization API.

Is this article helpful?