To merchants who have built their app on a Cordova platform, PhonePe provides a bridge to conveniently integrate PhonePe SDK for both Android. On this page, we will highlight the steps required to integrate PhonePe SDK with Cordova plugin for your app. This bridge will help you to build a seamless and responsive checkout experience for your Android application.
This integration will support the following flows:
**UPI Intent Flow**: In case the PhonePe app is installed, PhonePe intent flow will be launched to complete the transaction and send the response back to your app
**Redirection Flow**: In case the PhonePe app is not installed, PhonePe SDK will open a web-view to process transactions and give a response back to your app
## Android Project of Cordova Plug-In
Add the below code to 'repositories' section of your project level build.gradle file
Add the below line to the 'dependencies' section of your app build.gradle.
<!-- SNAPSHOT implementation 'phonepe.intentsdk.android.snapshot:IntentSDK:1.6.6-SNAPSHOT2’ RELEASE implementation 'phonepe.intentsdk.android.release:IntentSDK:1.6.6’ For, SDK version 1.6.5, We have compileSdkVersion: 28, minSdkVersion: 14, targetSdkVersion: 28 For, SDK version 1.6.6, We have compileSdkVersion: 29, minSdkVersion: 24, targetSdkVersion: 29 For, SDK version 1.6.7, We have compileSdkVersion: 28, minSdkVersion: 21, targetSdkVersion: 28 For, SDK version 1.6.8, We have compileSdkVersion: 28, minSdkVersion: 21, targetSdkVersion: 28 -->
For, SDK version 1.6.8
We have compileSdkVersion: 28, minSdkVersion: 21, targetSdkVersion: 28
Add below lines of code inside the application tag in the AndroidManifest.xml file
Add PhonePeSDKPlugin to your project (see Appendix at the end of this document).
Add the OnActivityResult method in the PhonePeSDKPlugin class as per your response requirement in the cordova plug-in.
Call Cordova.exec() method from your Cordova Native app to invoke the PhonePe module.
## Cordova Plug-In code
In the .js file add the following to check whether PhonePe app is installed or Not:
Install the PhonePe PreProd app. Refer to this [link](🔗).
If returns **true** then display the PhonePe option on the checkout page or if returns false then do not display the PhonePe option on the checkout page.
In the .js file add the following to initiate the payment process:
**base64EncodedBody** - pass the encoded payload request
**checksum** - pass the checksum value
**endPoint** - pass the endpoint
**xCallbackUrl** - This can be “” or else you can send your custom callback URL where you will receive the server to server callback response to your custom callback URL. Once the response is received you have to validate the checksum and invalid amount. Refer to this [link](🔗) for more details.
** success/error** - This is a Cordova plugin method that will receive a user interface callback response from the startPaymentTransaction method.
If data returns **User Completed** it indicates the payment has been completed.
If data returns **User Cancelled** it indicates the payment has been canceled just in case if the user presses the back button or aborts the transaction.
Inform merchant server about the completion of the transaction flow from merchant app
Merchant server should check the status with server to server callback or make the Check Transaction Status API call to the PhonePe server to check the transaction status (Even for User Cancelled callback)
The app should get the transaction status from the backend
Based on the result, the merchant must inform the user about the success or failure status of the transaction
Kindly maintain the parameter order sequence
For Accept Payment API, Refer to this [link](🔗).
Use the Check Transaction Status API to check the status of the payment transaction. Refer to this [link](🔗).
For refund API, Refer to this [link](🔗).