npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-inapppurchases

v3.1.1

Published

Cordova plugin to add in-app-purchases (and subscriptions) into an app, use javascript to view, make, and complete purchases.

Downloads

106

Readme

Cordova-Plugin-InAppPurchases

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! :grinning:

PLUGIN USAGE

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.

see how to add the plugin

see more on using the plugin

Testing App

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

Demo 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

CREATE AN APP WITH CORDOVA

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.

ADD IN APP PURCHASES

  1. Add the plugin The spelling of this plugin is cordova-plugin-inapppurchases with an s, (more plugins we've tested but were not fully working December 2022:
  • 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
  1. 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)

    • For the Google Play Store, retreive your Base64 Billing Key in monetization to use in the app Create a file within your cordova project at: www/manifest.json, containing:
    { "play_store_key": "<Base64-encoded public key from the Google Play Store>" }
  2. Add buy buttons (or any UI you make) to your Cordova html code

  3. Add calls to the plugin with the inAppPurchases object in your Cordova JavaScript code

  4. Test that your in-app purchases are working with test accounts

Testing Tips

see common error messages to handle other results

Android

  1. create a test track (closed works) and add an email address with a Google Play account
  2. after adding the plugin, build an aab file and add it to the Google Play test track, this enables the Google Play billing library for your app
  3. get your base64 billing key in the monetization section to add to the www/manifest.json
  4. make "products" with ids on the google play store in the in-app products and subscriptions sections
  5. log into your test account on your device and make purchases
    • use a real android device to test, simulators don't support billing (see the error message)
    • Google Store doesn't make a difference between consumable and non-consumable in-app purchases, don't call inAppPurchases(product_id,is_consumable); with is_comsumable=true for non-consumable purchases because it will consume them too

iOS

  1. create in app-purchases and subscriptions on App Store Connect, takes up to an hour to enable after creating the first one
  2. to enable testing, create a build and upload it to App Store Connect (once you do it for one app, you may not need to do this step again)
  3. create test accounts in the TestFlight section of App Store Connect
  4. now you can log in to test accounts in the test device's settings, or the prompt that comes up in a simulator and test out in-app purchases
    • you should be able to test without having to submit your app for review

Future Improvements

  • [ ] update to also include Storekit 2, in a couple years
  • [ ] will not add internal receipt checking for iOS, mostly helpful for MMOs
  • [ ] support Windows apps
  • [x] tested working 2023 with Google Play Billing Library 5 for consumables, non-consumables, and subscriptions
  • [x] tested working 2023 with StoreKit for consumables, non-consumables, and subscriptions

More from cozycode.ca

Open Source License

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.