UPI
The Unified Payments Interface (UPI) is a real-time payment system that allows users to transfer funds between bank accounts using their mobile phones. UPI has revolutionized the way people make payments in India, making it faster, more efficient, and more convenient.
One of the key features of UPI is the intent mechanism, which enables seamless payment flows between different apps and services. With the intent mechanism, users can initiate a payment from within any app or service that supports UPI payments, without having to switch to a separate payments app.
To enable seamless payment flow using the UPI intent mechanism, developers need to integrate the UPI SDK into their apps or services. The UPI SDK provides a set of APIs that allow developers to initiate UPI payments from within their apps or services.
Prerequisites
- Business channels must accept UPI and be verified merchants by NPCI/banks.
- Ensure you have the details required to accept payments using UPI ID with your bank.
- Ensure that you have all of the required APIs from your bank to check the status of a payment.
- Note that every transaction should use a unique transaction ID.
Getting Started
The UPI intent mechanism works by using a deep link to launch the UPI payments app on the user's device.
Let's look into the intent.
The <span class="text-color-code">Intent.action</span> is simply <span class="text-color-code">ACTION_VIEW</span>, which is usually used to display data to the user.
And the data is just the URI of a specific format that is expected.
The scheme and authority are used to link and map supported applications, reducing ambiguity.
The rest of the query parameters are as follows:
There are two ways to start UPI intent flow
- Implicit Intent flow
- Explicit Intent flow
Implicit Intent flow
In the Implicit Intent flow, your application will allow the user to choose from all the available apps that can handle UPI payments and are ready for UPI payments. It is also a mandatory option that your application should support as per NPCI.
To display all supported applications, create an Intent chooser.
Now, register for activity result
And, launch accordingly
Explicit Intent flow
In the Explicit Intent flow, your application will target a specific application instead of all available applications, and the operating system will launch that specific application directly. However, this method is not required, but it will greatly improve the user experience.
First, we need the package of the application that we need to target our intent to. For example, here is the list of packages of some of the applications that support UPI intent flow;
Google Pay - <span class="text-color-code">com.google.android.apps.nbu.paisa.user</span>
Paytm - <span class="text-color-code">net.one97.paytm</span>
PhonePe - <span class="text-color-code">com.phonepe.app</span>
You can find the list of other supported apps here.
Now add this info to the intent
And, launch accordingly
What if the user does not have that specific application installed?
In that case OS will throw the following error
Error: <span class="text-color-code">android.content.ActivityNotFoundException: No Activity found to handle Intent</span>
We can check whether that particular application is installed and is ready for UPI payments with the following methods:
The result of the above two methods can be used to display only the available explicit UPI payment option.
Here is how you can access the app icon and label with help of <span class="text-color-code">PackageManager</span>:
However you can directly access the icon and label of the application, and use them directly, but it is recommended to use the guidelines provided by each application.
For example here is the brand guideline for Google Pay.
Android 11 requirements
Merchants who target API level 30 or higher and run on Android 11 will only be able to view a limited number of apps.
To include the specific application app, include the package name in <span class="text-color-code"><package></span> elements inside the <span class="text-color-code"><queries></span> element.
Note
At this moment payment receiver should be a valid merchant with all the required details with it, like merchant code, sign, etc., which will be provided to you by the provider.
In conclusion, the UPI intent mechanism is a powerful tool for enabling seamless payment flows between different apps and services. By integrating the UPI SDK into their apps or services, developers can provide a more convenient and efficient payment experience for their users, while also driving higher conversion rates for their businesses.
References: https://developers.google.com/pay/india/api/android
Send us a quick query