Home
Last updated
Last updated
In-App Purchases for Cordova, Capacitor, and Ionic
Need professional help and support? Contact Me.
This plugin allows In-App Purchases (IAP) to be made from Cordova, Capacitor, and Ionic applications using a single, unified JavaScript API.
It simplifies handling in-app purchases across multiple platforms by abstracting platform-specific complexities.
Supported Platforms & Features:
Consumables
✅
✅
✅
✅
Multi-Quantity Consumables
✅
Non-Consumables
✅
✅
✅
Auto-Renewing Subscriptions
✅
✅
✅
Non-Renewing Subscriptions
✅
✅
Restore Purchases
✅
✅
✅
✅
Payment Requests
✅
✅
[Receipt Validation][iaptic]
✅
✅
✅
✅
Introductory Offers
✅
✅
✅
Promotional Offers (iOS)
✅
Subscription Offers (GP)
✅
✅
Manage Subscriptions UI
✅
✅
✅
Manage Billing UI
✅
✅
✅
¹ Requires the cordova-plugin-purchase-braintree extension.
This documentation provides guides and use cases for implementing In-App Purchases (IAP) using the cordova-plugin-purchase
plugin (version 13+).
Key Sections:
Introduction: Overview and core concepts.
Discover: Learn about IAP technology, the plugin's approach, and the critical importance of receipt validation.
Use Cases: Step-by-step guides for implementing specific product types (Consumables, Subscriptions, etc.) on different platforms (App Store, Google Play, Braintree, Test). Includes setup instructions.
API Reference: Detailed documentation for all classes, methods, and properties.
Troubleshooting: Solutions for common problems.
Migration Guide (v13): Instructions for upgrading from older versions.
(No specific Capacitor integration code is needed; use the Cordova plugin directly via the CdvPurchase
global namespace as shown in the examples).
(Use without @ionic-native/in-app-purchase-2
for plugin versions 13+).
See the Introduction for optional plugins that enhance functionality (Network Information, Advanced HTTP).
This example demonstrates the basic flow using the built-in Test Platform, which requires no App Store or Google Play setup.
1. Wait for Device Ready:
Ensure all plugin interactions happen after the deviceready
event.
2. Initialize Store & Register Product:
Inside your initializeStore
function:
3. Setup Event Listeners: Handle the purchase lifecycle events.
4. Display Product and Purchase Button: Create functions to show product info and trigger the purchase.
Note: This example uses the CdvPurchase
global namespace.
Contributions are welcome! Please read CONTRIBUTING.md for details on how to edit the documentation and submit changes.
This plugin is maintained thanks to its sponsors. See the full README on GitHub for details.
Licensed under the MIT License.