Cordova SDK

Add in-app purchases and paywalls to your Apache Cordova app with one JavaScript API for iOS and Android.

The Cordova plugin is on the roadmap and is not published yet. cashsdk-cordova does not resolve from any registry today, so the code on this page describes the intended API rather than a package you can install.

Shipping now? Use the iOS or Android SDK, which are available today. To be notified when this one lands, contact support@cashsdk.com.

The CashSDK Cordova plugin brings the same offerings-and-entitlements API to Apache Cordova apps. It wraps StoreKit 2 on iOS and Play Billing on Android and exposes a single, promise-based JavaScript API that runs unchanged on both platforms.

Install#

Add the plugin with the Cordova CLI:

bash
cordova plugin add cashsdk-cordova

The plugin installs its native iOS and Android dependencies for you. Rebuild the platform projects afterward:

bash
cordova prepare

Configure#

The plugin is available once Cordova fires deviceready. Configure CashSDK there, before any screen that reads entitlements, using your publishable key.

js
import { CashSDK } from "cashsdk-cordova";

document.addEventListener("deviceready", () => {
  CashSDK.configure({ publishableKey: "csk_pk_…" });
});

Only publishable keys (csk_pk_… / csk_pk_…) belong in your app bundle. Keep secret keys (csk_sk_…) on your backend.

Fetch offerings#

An offering holds the packages you present on a paywall, such as monthly and annual.

js
const offering = await CashSDK.offerings();

const monthly = offering.monthly;
const annual = offering.annual;

Purchase#

Pass a package to purchase. CashSDK drives the native store flow, validates the receipt server-side, and resolves with the customer's updated entitlements.

js
const result = await CashSDK.purchase(offering.monthly);

if (result.entitlements.pro?.isActive) {
  unlockPro();
}

Check entitlements#

Read entitlements from any purchase or restore result to gate features.

js
if (result.entitlements.pro?.isActive) {
  // Show premium content
} else {
  // Show the paywall
}

Restore purchases#

Let customers recover access on a new device or after a reinstall.

js
const result = await CashSDK.restorePurchases();

if (result.entitlements.pro?.isActive) {
  unlockPro();
}

Identify the customer#

Link the SDK to your own user ID so entitlements follow the customer across devices and platforms. Call identify after the user signs in.

js
CashSDK.identify("u_812");

Next steps#