lwc:programming:mobile:cordova_phonegap:inapp_purchases

The InApp Purchase plugin works with both iOS and Android and works with Crosswalk (v 11.40.xxx at least)

the name of the purchase needs to exactly match that in the code. There's no prefix to it i.e. the app bundle or ID is not prefixed to it. It seems however typical to manually add the app bundle or ID to the item. This seems like good practice especially when considering in for Google Play at least the name of the item needs to be unique, I believe, even across apps. For Android the app needs to be published. That's OK as you can publish while in Alpha or Beta stage so it still isn't public. This means:

  • you must create a signed released copy that isn't debuggable and upload that
  • you can load in your device a signed released copy that is debuggable for testing, but it must still be a signed, release copy and the version numbers must match
  • you actually have to wait several hours (6-8?) for Google play to actually publish the app before it will work
  • yes you have to upload screenshots and all the rest to actually publish the thing

It appears that both platforms support nonconsumable and consumable items, even though they are handled quite differently. Consumable items have not been tested yet in Android but it appears the plugin handles them and the handling is invisible to the developer. Android: no extra permissions are needed a working example for Android (maybe) and iOS (definitely) is in a folder called cordova-plugin-purchase-demo-3.6.3

  • you must use a sandbox tester as your user when you try to purchase the item. To create the sandbox tester go to iTunes Connect → Users and Roles → Sandbox testers
  • log out of the iTunes on the real device with the real user. You will have to be logged in as the sandbox tester for this to work. You can log in through the app itself.
  • according to the docs, if you accidentally use the sandbox tester as a “real” user on iTunes, it will no longer work for testing.
  •  The bundle ID absolutely has to match
  • V 0.3.11 and above require Cordova 5.1.1 or later

Android:

  • There's a bug where the billing ID isn't correctly inserted. See directions here for fixing. 
  • lwc/programming/mobile/cordova_phonegap/inapp_purchases.txt
  • Last modified: 2020/11/26 22:37
  • by John Harrison