Showing posts with label plugin. Show all posts
Showing posts with label plugin. Show all posts

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.

Saturday, December 22, 2012

In-App Billing setback

Just when I thought we were so close... in signing up for Apple Developer and Google Developer accounts, I found that both have restrictions that you must use their markets for purchasing any digital goods in the application.  I failed to anticipate that restriction :-(   My in-app purchasing is not done with their markets.  Actually, it isn't even in-app purchasing technically, because I link out to our web site to do a purchase.  That's also against the terms of both companies.

So.... I need to implement in-app billing for both Apple and Android.  Luckily, very recently an in-app billing Phonegap Plugin was made for just that purpose!  Plugins are separate per OS, so that meant I also needed to split the market page into a version for each OS.  I tried the Android one first, and it worked!  You just use Google's test product IDs, and they come back with fake success messages.  So cool to see the Google Play market open for the first time.

But then.... I discovered that the Plugin seems to be missing a few key features I needed, like the purchaseToken and the API call to consume an in-app purchase.  It looks like I may need to do those parts of the plugin myself.  If I succeed in improving the plugin, of course I would want to share those changes with other PhoneGap users.  That means that I've finally made my way to the GitHub community.  I feel like I'm just barely understanding everything I'm doing, so hopefully I don't make a fool of myself there.  It may be too late as I've already tried to message someone and hopefully didn't send the message to a bunch of people :-/

So much to learn!