3

Trying to implement in-app purchases to my ionic project. Not sure which one to go with, there are limited amount of resources for both.

I've found these tutorials:

In-App-Purchase: https://alexdisler.com/2016/02/29/in-app-purchases-ionic-cordova/

In-App-Purchase2:

  1. https://medium.com/@andrew.thielcole/in-app-purchases-with-ionic-3-af13b21f49f2

  2. https://github.com/thielCole/ionic-iap2

Is there one that is more preferred over the other? I'm using Ionic 3 and not sure where to start.

EDIT: Added second link for in-app-purchase2 per @franswa 's suggestion

Dheeraj Gupta
  • 372
  • 5
  • 20
cdh429
  • 337
  • 3
  • 11
  • 20
  • I am using the first one and it works fine.I tested the second one last month and had some issues but now it should work fine. Take a loot at this repo for the second one: https://github.com/thielCole/ionic-iap2 – franswa Mar 09 '18 at 19:15
  • Thank you I'll check it out - I'm reading that they're a good amount of crashes (mostly in the android) for the first in-app-purchase, what has been your experience? @franswa – cdh429 Mar 12 '18 at 16:36
  • I did quite a lot of testing and it worked fine, no crashing. – franswa Mar 13 '18 at 08:07
  • How do you test these? Seeing as Ionic Serve (and I believe ionic view) doesnt use cordova? How would you test the Apple and Android payment processes with ionic 3? @franswa – cdh429 Mar 13 '18 at 19:03

1 Answers1

5

As said in the comments I did a lot of testing with In-App-Purchase: https://alexdisler.com/2016/02/29/in-app-purchases-ionic-cordova/

Everything went fine. You have to deploy the app on the device for the testing:

ionic cordova run android --device

Then you have to create a product in the Google Play store and buy this test IAP from the app (using another account - not your developer account: the Google Account on the test device should not be the same as the developer account). The process is not so easy... but you can find good documentation online. Here's a useful link: https://github.com/j3k0/cordova-plugin-purchase/wiki/HOWTO#setup-android-applications

[UPDATE FROM NOV 2018]

franswa
  • 836
  • 1
  • 9
  • 21
  • Ok great, I got the device fired up - I'm (obviously) running into some errors. What's your best tactic to debug? Is there any way to bring up a console? – cdh429 Mar 15 '18 at 15:50
  • @cdh429 A simple vote up would have shown appreciation for answering your question. Acting 'cool' is not cool. Give the answer a vote up if he answered your question. – Olu Adeyemo Nov 17 '18 at 20:31
  • @franc Cooler than the other side of the pillow – cdh429 Nov 18 '18 at 21:08
  • 1
    I implemented In App Purchases 2 and I keep seeing this issue when I run my app: `TypeError: this.store.when(...).registered is not a function`. Similar type of errors occur for the other methods as well, such as: `TypeError: this.store.when(...).expired is not a function`. My codes are: `this.store.when(productId).expired((product: IAPProduct) => { alert('expired'); });`. I am running my app in a browser, if that helps. – Devner Mar 03 '20 at 00:16