SDK Integration

Android Configurations

  1. Add the below code to ‘repositories’ section of your project level build.gradle file
repositories {
  jcenter()
  maven {
    url "http://phonepe.bintray.com/PhonePeThinAndroidSDK-SNAPSHOT"
    credentials {
      username '[email protected]'
      password 'cf5f50936599c5dbbde28aa59c8a471c131e4736'
    }
  }
}
Sample build.gradle fileSample build.gradle file

Sample build.gradle file

  1. Add below line to ‘dependencies’ section of your app build.gradle.
compile 'phonepe.thinsdk.android.snapshot:merchantsdk:x.x.x'
Sample build.gradle fileSample build.gradle file

Sample build.gradle file

  1. It's possible that SDK and the Host app specify common dependencies, which might result in compile failure on the grounds of class duplication. In such cases specify resolutionStrategy on your App's build.gradle as follows:
//noinspection GroovyAssignabilityCheck
configurations.all {
    resolutionStrategy {
        force <path to your version of conflicting library - 1>
        force <path to your version of conflicting library - 2>
        ...
    }
}

🚧

Ignore this step if you don't see any compilation error.

  1. Add below line inside application tag of your AndroidManifest.xml file. Refer this link for more details.
<meta-data
  android:name="com.phonepe.android.sdk.MerchantId"
  android:value="<your merchant id given by PhonePe>"/>
 
<meta-data
   android:name="com.phonepe.android.sdk.AppId"
   android:value="<your app id given by PhonePe>" />

<!-- Keep it false in production environment-->
<meta-data
   android:name="com.phonepe.android.sdk.Debuggable"
   android:value="true"/>

<!-- Keep it false in production environment-->
<meta-data
   android:name="com.phonepe.android.sdk.isUAT"
   android:value="true"/>
  1. Create a custom Application class if you don’t have one already. Register the Application class you created in the AndroidManifest.xml as follows:
<application
   android:name="<name of application class>"
  1. Add internet permission to AndroidManifest.xml if you have not already added it. It must be added as a direct child of the manifest tag.
<uses-permission android:name="android.permission.INTERNET" />
  1. You should call this function in an Activity which get's launched before a user selects the PhonePe option on your checkout page. (ideally before 4-5 seconds of PhonePe pay option selection).
    Don't initialize in the Application class of your project.
PhonePe.init(this)
  1. PhonePe Onboarding involves OTP verification. If you would like Auto-OTP verification to be enabled add below permissions to AndroidManifest.xml. It must be added as direct child of manifest tag.
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>