capacitor-plugin-cdv-purchase
v13.17.2
Published
In-App Purchases for Capacitor — iOS (StoreKit 2) and Android (Google Play Billing)
Maintainers
Readme
capacitor-plugin-cdv-purchase
In-App Purchase plugin for Capacitor 6+ — iOS (StoreKit 2) and Android (Google Play Billing).
This is the Capacitor edition of cordova-plugin-purchase, sharing the same API and adapter layer.
Installation
npm install capacitor-plugin-cdv-purchase
npx cap syncUsage
import { store, ProductType, Platform } from 'capacitor-plugin-cdv-purchase';
// Register products
store.register([{
id: 'my_subscription',
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY, // or Platform.APPLE_APPSTORE
}]);
// Listen for events
store.when()
.productUpdated((product) => { console.log('Product updated:', product); })
.approved((transaction) => transaction.verify())
.verified((receipt) => receipt.finish());
// Initialize
await store.initialize();Migrating from cordova-plugin-purchase
If you're using cordova-plugin-purchase in a Capacitor app:
npm uninstall cordova-plugin-purchase(andcordova-plugin-purchase-storekit2if installed)npm install capacitor-plugin-cdv-purchasenpx cap sync- Update your import to
import { store, ProductType, Platform } from 'capacitor-plugin-cdv-purchase'— the API is identical
Device info for receipt validation
When validating receipts, the plugin sends device information (OS, model, manufacturer) to the validator to support fraud detection and support requests. In Capacitor apps, this information is collected automatically via @capacitor/device through the Capacitor plugin proxy — no additional plugin installation is required.
Customize what is sent with store.validator_privacy_policy:
store.validator_privacy_policy = ['fraud', 'support', 'analytics'];See the privacy policy documentation for details.
Platform Support
| Platform | Native API | Minimum OS | |----------|-----------|------------| | iOS | StoreKit 2 | iOS 15+ | | Android | Google Play Billing 8.3 | API 23+ |
Documentation
Full API documentation: https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md
License
MIT
