Cordova/Phonegap In App Billing Plugin

I have already mentioned the plugin that I have been working on, for cordova/phonegap for the sake of providing in app billing capabilities in hybrid applications on andorid or iOS. As this plugin has reached a good point which can be practically used now, I thought I would give a short intro to it and to its goals.

What was wrong with other plugins?

Thats the very first question that someone would ask if they are already familiar with other plugins which provide the same functionality. Thats right, there are actually a bunch of other similar plugins which provide the same functionality to cordova based application. Some for iOS and some for android. And thats exactly where the problem begins. Those plugins are written either by the guys who mainly do iOS development or by the guys who mainly do android development. Any single of them does the job perfectly in one platform but not on both.

So first of all you (as developer of a cordova based application) has to deal with two plugins, each for one platform. Even thats not the major problem, the main problem is in concepts and how each platform (iOS and android) approaches towards in app billing. There are a lot of differences that I’m not going into their details but if you are curious I did a through research on both of them and the (kind of) report can be seen here. Result is each of those two plugins have a completely different process. You have to deal with different workflows and in no time you JavaScript code becomes too messy. At some point the code is so hard to debug and test that its actually not possible any more to verify the functionality.

Can we solve incompatibilities?

To be honest I dont think so! the problem is some of these incompatibilities are down in the roots of systems. What however possible is, is to reduce those incompatibilities to a minimum set and even try to avoid those minimum set as you are developing the application. Thats how I tried to structure this plugin. One reason to provide those minimum set of incompatibilities in this plugin is some extreme cases that such functionality is needed.

Thats how I tried to unify the functionality between two platforms.

Is there any other solution to this unified way?

Actually there are some other ways like AppMobi’s payment service or the similar one for CocoonJS. The thing is that almost all of those solutions have either some not acceptable dependencies (like external 3rd party services) or do work only if you are compiling with their service. As an example what I see in AppMobi is the unacceptable setup step that you have to do on their service in addition to what you do in iTunes and Google Play, why the hell to setup yet another store details? And why to depend on another service that may fail?

Another problem is the lack of critical data they provide. Using some of those services it is simply impossible to get your hands on the validation data of a purchase! you have to simply accept whatever their JavaScript API is returning to you. I see this practical only when you are doing a very small app, but when it comes to real world programs, it is simply useless.

So what?

So I took two of the best implementations of open source plugins available for in app billing and worked on both of them to be unified on JavaScript side and to provide (nearly) one single way of interaction with stores. There are some really extreme cases where you shall deal with additional functionality provided for iOS but thats pretty straight forward to tackle.

Whats the status?

The plugin is pretty mature on android, tested and used on multiple devices. Even though the iOS code is also modified and is pretty much worked on, I only had the chance to test it on android as my iTunes developer account is not currently setup for doing purchases but as soon as it is, I will also throughly test it on iOS. Or maybe some guy who already has such account take over that part and help me do the through test on iOS too.

Where to start?

All these stories told, you can head over to GitHub and grab the code here. The full documentation on getting started with the whole plugin and stores setup and also the JavaScript API is described also on the wiki. You can even find a sample application which I use for doing the tests here.

The plugin is also registered on Phonegap Build, the current version (v0.0.3) is at the time of writing this text in “Pending Review” status but two older versions are available. I would however recommend waiting for the approval of this final version if you plan to use the build service of Adobe. You can find the plugin under the name “Multiplatform InAppBilling”.

At the end if you need help of if you find any bugs, just let me know on the GitHub’s bug tracker. I would be happy to help or get help from you.

comments powered by Disqus