How it works
UPI Intent uses a deep link that starts withupi://pay. On Android, when your customer taps Pay, your checkout passes this link to the operating system, which lists the installed apps that can handle it. On iOS, there is no system app picker for UPI links. Each UPI app uses its own proprietary URL scheme, such as phonepe:// or paytmmp://, so your checkout must detect the installed apps and open the one your customer selects. The Cashfree iOS SDK does this for you. The selected app opens with the amount and your business name filled in, and your customer approves the payment with their UPI PIN. The app then returns the customer to your checkout, and Cashfree sends you the final payment status.
Integration options
Choose an integration option that matches your checkout:Use the Cashfree SDKs or Hosted Checkout
With this option, you don’t write UPI-specific code. On Android, the operating system shows the UPI app picker as soon as the link opens. On iOS, the Cashfree iOS SDK detects the installed UPI apps and opens the one your customer selects. This option works with the following Cashfree SDKs: It also works with Hosted Checkout when it opens in a mobile browser or through a full-page redirect.On Android, the operating system lists the installed UPI apps that can handle the
upi://pay link. On iOS, some in-app browsers, such as those in social media apps, may not open UPI app links and show no error. If much of your iOS traffic comes from in-app browsers, also offer dynamic QR codes or UPI Collect, which iOS still supports.Handle UPI links in a WebView
A WebView doesn’t hand links to other apps the way a mobile browser does. If you load Hosted Checkout inside a WebView, the UPI option appears but does nothing when tapped. To fix this, your app must intercept the UPI link and open the matching app. The following table summarises what your app must do on each platform:
For the code samples, use the following guides:
- UPI Intent in WebView explains the changes for Android and iOS apps.
- Custom Checkout for Android shows how to intercept UPI app schemes in an Android WebView.
- Custom Checkout for iOS shows how to declare and open UPI app schemes in a
WKWebView.
Get the UPI link from the Order Pay API
If you build your own checkout, request the UPI link from Cashfree and open it yourself. Before you begin, make sure that you have the following:- API keys from the Merchant Dashboard.
- Server-to-server (S2S) payments enabled for your account. To enable it, fill out the Support Form.
- From your server, create an order with the Create Order API. The response contains a
payment_session_id. It doesn’t contain a UPI link. - Call the Order Pay API with the
payment_session_id, and setpayment_method.upi.channeltolink. - On the customer’s device, open the
upi://paylink fromdata.payload.default, or an app-specific link, such asdata.payload.phonepe. - Wait for the payment webhook, and then confirm the final status before you fulfil the order.
Sequence diagram for developers
Sequence diagram for developers
The following diagram shows the API calls in a custom integration:
Request
Send the request toPOST /pg/orders/sessions. Use https://sandbox.cashfree.com/pg for testing and https://api.cashfree.com/pg for production. This API authenticates with the payment_session_id, so it doesn’t need your client ID and secret. Pass the x-api-version header with the API version you use.
The following table describes the request parameters for a UPI link:
Response
The following table describes the response fields that you use for UPI Intent:
If the request fails, the API returns an error object with
message, code, and type. For all error codes, see the Order Pay API reference.
The following example requests a UPI link:
Test UPI Intent
Use the Cashfree UPI simulator app on an Android device or emulator to approve or decline UPI Intent payments in the sandbox environment.Troubleshooting
Customers see a QR code instead of UPI app icons on mobile
Customers see a QR code instead of UPI app icons on mobile
This usually happens when your checkout runs inside a WebView that doesn’t handle UPI links. Add the handling described in UPI Intent in WebView.
The UPI option does nothing when an iOS customer taps it
The UPI option does nothing when an iOS customer taps it
This usually happens when the customer is in an in-app browser that blocks UPI links. Offer a dynamic QR code or UPI Collect as an alternative for iOS traffic from in-app browsers.