2023-2024 cordova plugin to add in-app purchases and subscriptions into an iOS or Android app
MIT License
jump to: PLUGIN USAGE | Testing App | Demo App | Cordova | ADD IN APP PURCHASES | Testing Tips | Future Improvements | cozycode.ca | Open Source License
Cordova plugin to add in-app purchases (and subscriptions) into an app. Use JavaScript to view, make, and complete purchases.
Updated 2024 for Cordova with current: Android: Billing Library 7 (released May 2024) (verifies receipts internally) iOS: StoreKit (not StoreKit 2, released 2021, which is only available for iOS 15 and up) (does not verify receipts currently - it returns them, and can be verified if needed) Amazon Fire: compatible, but untested Browser: not implemented Windows: not implemented
If you notice any issues, submit here: github issues
Based on the original plugin working for many years made by Alex Disler (c) 2016 MIT, which is out of date for writing new apps: cordova-plugin-inapppurchase
Forked from another plugin, which is kept updated as well, if this plugin is broken, try this plugin: cordova-plugin-inapppurchase2
This new plugin distribution makes significant changes to the Google Play Billing Library and plugin integration code.
Have a good one! 😀
Add these calls inside of your cordova JavaScript to make in-app purchases and subscriptions:
inAppPurchases.getAllProductInfo(productIds)
inAppPurchases.restorePurchases()
inAppPurchases.purchase(productId)
inAppPurchase.completePurchase(productId,consume)
The plugin creates an inAppPurchases
object which can make calls to the store.
After creating App Store and Google Play accounts and in-app products, this app can test purchases. Download test app here: cordova-plugin-inapppurchases Test App
This app shows how to use this plugin to load and make purchases in a Cordova app: Download demo app here: cordova-plugin-inapppurchases Demo App
How to create a Cordova app:
npm install -g cordova
cordova create directory_name com.your_name_or_company.your_app_name
Cordova is an open source project maintained by Apache that lets you make apps written in HTML, css, and JavaScript. You can create cross-platform apps to publish on the Google Play Store for Android, and the Appstore for iOS, MacOS, and Apple devices.
cordova-plugin-inapppurchase
(first plugin worked for years)cordova-plugin-inapppurchase-2
(active and almost fully working plugin by Wccrawford)cordova-plugin-purchase
(not updated to work in latest Android and iOS)cordova plugin add cordova-plugin-inapppurchases
In the Google Play Store and iOS app store, add your in app purchases and subscriptions (set product ids here, for example, com.name_or_company.app_name.purchase_product_name) (see testing tips below)
www/manifest.json
, containing:
{ "play_store_key": "<Base64-encoded public key from the Google Play Store>" }
Add buy buttons (or any UI you make) to your Cordova html code
Add calls to the plugin with the inAppPurchases
object in your Cordova JavaScript code
Test that your in-app purchases are working with test accounts
see common error messages to handle other results
MIT Licensed (MIT)
Copyright © 2023 cozycode.ca
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.