Integrate the Cashfree Subscription Cordova SDK from npm to capture mandate authorisations and run recurring billing inside hybrid Cordova or Capacitor apps.
The Cordova SDK is available on npm. You can download the latest version 1.0.12.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:
npm install cordova-plugin-cashfree-pg# Or Install with latest tagnpm install cordova-plugin-cashfree-pg@latest# Add Plugincordova plugin add cordova-plugin-cashfree-pg# With Ionic Cordova platformionic cordova plugin add cordova-plugin-cashfree-pg
# Install with capacitor tagnpm install cordova-plugin-cashfree-pg@capacitor# Ionic Capacitor setup# Install Core library (once per project)npm install @awesome-cordova-plugins/core# Install Awesome Cordova Plugins TypeScript wrapper for CashFree PGnpm install @awesome-cordova-plugins/cashfree-pg# Update native platform project(s) to include newly added pluginionic cap sync
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.
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.
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).
Call doSubscriptionPayment() to open the Cashfree subscription checkout screen. This will present the user with the payment options and handle the payment process.
function initiateSubscriptionPayment() { var cfSubscriptionPayment = { "session": { "subscription_session_id": SESSION_ID, "subscription_id": ORDER_ID, "environment": ENV } } CFPaymentGateway.doSubscriptionPayment(cfSubscriptionPayment)}
We currently do not provide a dedicated SDK for the Capacitor framework. However, we’ve developed a Capacitor plugin that acts as a wrapper over our Cordova SDK. See the sample Capacitor app.
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 check the subscription status from your backend. Ensure you check the subscription status from your server endpoint.