Setting up SDK
The Cordova SDK is available on npm. You can download the latest version here.The SDK supports Android SDK version 19 and later, and iOS 10.3 and later. To install the SDK, run the following command in your project directory:
iOS
Add this to your application’sinfo.plist
file.
Step 1: Creating a subscription
Before you can process payments, you must create a subscription. Create an API endpoint on your server that generates the subscription and communicates with your frontend.Always create subscriptions from your backend. This API requires your secret key. Never call it directly from your mobile app.
After you create the subscription, you receive a
subscription_id
and a subscription_session_id
.
Step 2: Opening the subscription checkout payment page
After creating the subscription, open the payment page so the customer can complete the payment. To complete the payment:- Enable Subscription flow flag in Android Manifest
- Create a
CFSubscriptionSession
object. - Set payment callback.
- Initiate the payment
Enable subscription flow flag
Add the following entry inside the<application>
tag in your Android manifest file. If you do not enable the cashfree_subscription_flow_enable
flag, the SDK will not provide a payment callback.
Add this entry inside the
<application>
tag, Not inside the <activity>
tag.Create a subscription session
This object contains essential information about the subscription, including the subscription session ID (subscription_session_id
) and subscription ID (subscription_id
) obtained from creation step. It also specifies the environment (SANDBOX or PRODUCTION)
.
Setup payment callback
You need to set up callback handlers to handle events after payment processing. This must be set before callingdoSubscriptionPayment
.
Always call setCallback before calling
doSubscriptionPayment
method of SDKInitiate the payment
CalldoSubscriptionPayment()
to open the Cashfree subscription checkout screen. This will present the user with the payment options and handle the payment process.
Sample code
Sample Github code
Cordova Integration
Cordova Integration
Ionic Capacitor Integration
Ionic Capacitor Integration
Ionic Angular Capacitor Integration
Ionic Angular Capacitor Integration
NextJs Capacitor Integration
NextJs Capacitor Integration
We currently do not provide a dedicated SDK for the Capacitor framework. However, we have developed a Capacitor plugin that acts as a wrapper over our Cordova SDK. Click here for the sample capacitor app.
Step 4: Confirming the payment
After the payment is completed, confirm the subscription status to verify whether the payment was successful. The user will return to your activity after checkout.You must always verify payment status from your backend. Before delivering the goods or services, please ensure you call check the subscription status from your backend. Ensure you check the subscription status from your server endpoint.