Skip to main content
Cashfree’s Cordova SDK provides a payment solution that integrates the payment gateway into your Cordova and Capacitor applications, supporting both Android and iOS platforms. The SDK offers multiple checkout flows including web checkout and UPI Intent checkout.
This document includes instructions for both Cordova and Capacitor SDK integrations.

Key benefits

The Cordova SDK offers the following advantages for your payment integration:
  • Multiple checkout flows: Provides web checkout and UPI Intent checkout options to suit different integration needs.
  • Cross-platform support: Seamlessly supports Android (SDK version 19+) and iOS (deployment target 11+) platforms.
  • Secure and compliant: Securely handles payment processing with built-in security measures managed by the SDK.

Prerequisites

Ensure you complete the following tasks before starting the integration: The Cordova integration consists of three essential steps:

Step 1

Create an order

Step 2

Open the checkout page

Step 3

Confirm the payment
The step-by-step guide for each step of the integration process is as follows:

Step 1: Create an order Server-side

To integrate the Cashfree Payment Gateway, you must first create an order. Complete this step before you process any payments. Configure an endpoint on your server to handle order creation. You can’t call this API from the client-side.
Create orders through your server as this API requires your secret key. Don’t call it directly from your mobile application.
API request for creating an order
Here’s a sample request for creating an order using your desired backend language. Cashfree offers backend SDKs to simplify the integration process.
After successfully creating an order, you will receive a unique order_id and payment_session_id that you need for subsequent steps. You can view the complete API request and response for /orders in the Create Order API.

Step 2: Open the checkout page Client-side

Once the order is created, the next step is to open the payment page so the customer can make the payment.

1. Set up the SDK

The Cordova SDK is hosted on npm. You can download the latest version 1.0.12. The Cordova SDK supports Android SDK version 19 and above and iOS minimum deployment target of 11 and above.
Capacitor SDK: The code snippet below also includes Capacitor SDK integration instructions.
Navigate to your project and run the following command:

iOS configuration

Add this to your application’s info.plist file:
For iOS, run the following commands:

2. Select a payment flow

The Cordova SDK offers the following payment flows:
In this flow, the SDK provides a webview-based checkout implementation to facilitate a quick integration with the payment gateway. Your customers can fill in the necessary details in the web page and complete the payment. This mode handles all the business logic and UI components to make the payment smooth and easy to use.
This flow is for merchants who want to provide UPI Intent functionality using Cashfree’s mobile SDK. In this flow, the SDK provides a pre-built native Android screen to facilitate integration with the payment gateway. Your customers see a list of UPI apps installed on their phone which they can select to initiate payment. This mode handles all the business logic and UI components to make the payment smooth and easy to use. The SDK allows you to customise the UI in terms of colour coding and fonts.

3. Complete the payment

To complete the payment, follow these steps:
  1. Create a CFSession object.
  2. Set up payment callback.
  3. Initiate the payment using the payment object.

Create a session

This object contains essential information about the order, including the payment session ID (payment_session_id) and order ID (order_id) obtained from Step 1. It also specifies the environment (SANDBOX or PRODUCTION).

Set up the payment callback

The SDK exposes a CFCallback interface to receive callbacks from the SDK once the payment flow ends. The callback supports two methods:
Always call setCallback before calling the doPayment method of the SDK.

Initiate the payment

This flow is for merchants who want to provide UPI functionality using Cashfree’s mobile SDK without handling other modes like cards or net banking.

Sample code

Complete code examples demonstrating the implementation of both Web Checkout and UPI Intent Checkout flows are shown below:

Sample GitHub code

You can explore working integration examples for various frameworks on GitHub:
Sample UPI Test apk
Cashfree doesn’t currently provide a dedicated SDK for the Capacitor framework. However, a Capacitor plugin has been developed that acts as a wrapper over the Cordova SDK. See the sample Capacitor app.

Step 3: Confirm the payment Server-side

Once the payment is completed, you need to confirm whether the payment was successful by checking the order status. Once the payment finishes, the user will be redirected back to your activity.
You must always verify payment status from your server. Before delivering the goods or services, ensure you check the order status from your server and verify it from your server endpoint.
To verify an order you can call our /pg/orders endpoint from your backend. You can also use our SDK to achieve the same.

Testing

You should now have a working checkout button that redirects your customer to Cashfree Checkout. If your integration isn’t working:
  • Open the Network tab in your browser’s developer tools.
  • Click the button and check the console logs.
  • Use console.log(session) inside your button click listener to confirm the correct error returned.

Error codes

To confirm the error returned in your application, you can view the error codes that are exposed by the SDK.
The following are some of the error codes that are exposed by the SDK: