Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Google In-app billing - Which Google tutorial is the right one?

I would like to add some IAPs to my Android 4+ app. This seems to be quite easy, but there is one problem: Google offers two tutorials that describe how to use the latest IAP API v3 which use pretty different implemenations. Which one is the better/correct one?

Implementing In-app Billing describes how to implement a 'ServiceConnection' to bind an activity to 'IInAppBillingService'. The service is used directly to do all the IAP stuff like querying product information or performing purchases.

Preparing Your In-app Billing Application on the other hand describes how to use the IabHelper class to connect to the Service and run all IAP related Stuff.

I am confused about how these two tutorials are connected. There is no information about the relationship between the tutorials and the different approaches they describe.

So far I think, that the IabHelper is just a wrapper that should help to use the IInAppBillingService in a more convenient way. Is this right?

Using a convenience wrapper to make work with a complicated task more easy is often a good and nice idea. On the other hand a wrapper not only keeps the complicate implementations away from the developer but also the direct feedback/responses from the API. This can make debugging harder. Having this in mind: Which is the better solution? Using the API directly as described in the first tutorial or to use the IabHelper?

like image 521
Andrei Herford Avatar asked Sep 15 '14 07:09

Andrei Herford


People also ask

What is Google billing service?

Google Play's billing system is a service that enables you to sell digital products and content in your Android app. You can use Google Play's billing system to sell a one-time product or subscriptions on a recurring basis.


2 Answers

These tutorials are nice to learn how IABv3 works. However, if you are in a hurry or need to add IAB to several apps, the simplest and fastest way is to use this library: https://github.com/anjlab/android-inapp-billing-v3

like image 123
Rabi Avatar answered Oct 11 '22 13:10

Rabi


From my previous experience it is quite nice to read them both. And to use IabHelper as example of the proper in app purchase flow. First tutorial describes how to use Billing API and other describes with code block how to implement this API. For the fast and reliable code try to use existing code from second tutorial with IabHelper.

like image 45
Oleg Gordiichuk Avatar answered Oct 11 '22 12:10

Oleg Gordiichuk