3 min read
IapticBlog

Native Capacitor Plugin for In-App Purchases

Simpler setup, proper ES module imports, future-proof

The cordova-plugin-purchase plugin now ships with a native Capacitor edition. If you're using the Cordova plugin inside a Capacitor app, you can switch to the dedicated Capacitor package for a cleaner integration.

What Changed

The plugin now provides a native Capacitor bridge alongside the existing Cordova bridge:

  • iOS: Native StoreKit 2 integration
  • Android: Native Google Play Billing 8.3 integration
  • Same API: The CdvPurchase.Store API is identical -- your purchase logic stays the same

The key difference is how you install and import the plugin.

Why Switch

Simpler setup -- Install with npm and sync, no Cordova compatibility layer needed:

npm install capacitor-plugin-cdv-purchase
npx cap sync

Clean ES module imports -- No more globals. Import what you need directly:

import { store, ProductType, Platform } from 'capacitor-plugin-cdv-purchase';

Future-proof -- The Capacitor package follows modern JavaScript module conventions and integrates natively with the Capacitor build pipeline.

How to Migrate

  1. Uninstall the old plugin (and cordova-plugin-purchase-storekit2 if installed):

    npm uninstall cordova-plugin-purchase cordova-plugin-purchase-storekit2
    
  2. Install the Capacitor plugin:

    npm install capacitor-plugin-cdv-purchase
    npx cap sync
    
  3. Update your imports:

    // Before (Cordova global):
    const store = CdvPurchase.store;
    
    // After (ES module):
    import { store } from 'capacitor-plugin-cdv-purchase';
    
  4. The rest of your code stays the same.

Get Started