Saturday, January 5, 2013

Phonegap In App Billing plugin for Android - v2 API

Yesterday I got motivated to make my first PhoneGap contribution.  I planned to add some calls to a couple of API functions that weren't implemented in the plugin.  I don't know Java, but I hoped that I could just copy some parts that were making other API calls and just make the changes for the calls that I needed.

As I started looking at the Java code in the plugin, I noticed that there was basically just one API call being made with a different command message being sent as a parameter.  That wasn't what I was expecting to see.  So I started looking back at the Android API documentation and found that the calls being used in the plugin were from the version 2 (v2) API.  The v3 API is the latest, but just came out in last month or so.  But its quite a bit different.  So essentially the plugin would need a major upgrade to support the v2 API.  Not knowing Java, that seemed to be too much for me, so I had to give up on helping with the plugin :-(

And MonsterCache will just have to get by with the v2 API features for now.  The two v3 features I was trying to implement were:

  • Getting the list of available products and prices from the store.  I can store those myself, but getting them from the Play store may send you a converted currency in other countries, I'm not sure.
  • Consuming items.  In v3 all items in the store are "Managed", meaning Google keeps track of whether a user has bought them so that they don't have to be bought again.  But if your item should able to be bought again -- like in-game currency -- then you have to "consume" the item so that the user can buy it again.  In v2 though, they have "Unmanaged" items, and you can still make those in the Play store, so v2 still works
So once I coded for v2, it looks like Android In App Purchasing is working.  I'll have to have my test user (my wife) run a test tomorrow to be sure.  Google doesn't let you buy your own product.

I also got a JQuery popup dialog working today.  That was very good because I have lots of basic ugly alert() boxes that I could replace now with something that would look better.

Tomorrow I'm going to take a shot at the iOS In App Billing plugin.

No comments:

Post a Comment