This section explains how a merchant app can integrate PhonePe Android SDK and initiate payment.
Demo App
Android PG SDK setup
- Add the below code to ‘repositories’ section of your project level build.gradle file
Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
repositories {
google()
maven {
url "https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android"
}
}
}
- Add the below line to the ‘dependencies’ section of your app level build.gradle file
implementation 'phonepe.intentsdk.android.release:IntentSDK:5.1.0'
For our SDK :
We have compileSdkVersion: 28, minSdkVersion: 21, targetSdkVersion: 28
- 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 Name | Type | Description |
---|---|---|
context | Object | Pass your activity context |
merchantId | String | The merchantId shared by PhonePe |
flowId | String | Pass the merchant user Id or a unique alphanumeric random string |
phonePeEnvironment | Enum | Values Allowed: – PhonePeEnvironment.SANDBOX (For PreProd) – PhonePeEnvironment.RELEASE (For Prod) |
enableLogging | Boolean | [Optional Parameter] – True (To enable the SDK logs) – False (To disable the SDK logs) Note: In Prod, make sure to set as False. |
appId | String | [Optional Parameter] – Can be passed as null or “” also. |