star18bit star18bit - 2 months ago 15x
AngularJS Question

Initialization Android In App Billing using cordova plugin

In My ionic Cordova Application, I am using In App Purchase Plugin:

Here is the method that I use to initialise store:

debug: true, // Enable IAP messages on the console
ready: service.IAP.onReady,
purchase: service.IAP.onPurchase,
restore: service.IAP.onRestore,
error: service.IAP.onError

This Initialization works fine with iOS and all the products loading fine as well, But Android device does not load In Purchase.

I guess, For android there is a different initialization method.

I have added plugin in app:

cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="<BILLING_KEY>"

Please help.


Firstly, when I was using it, the npm version was a little buggy on android. Try removing it and adding it from Git.

cordova plugin add --variable BILLING_KEY="MIIB...AQAB"

Secondly, it looks like you are maybe using some older syntax. The doco for this plugin doesnt really have very good version control. There are different versions of doco all over the net. I think this is the latest version.

This is my initialisation code. See if it works for you too.

            products = ["my.test.product"];
            for (var i = 0; i < products.length; i++) {
                if ( {
                        id:    products[i],
                        alias: 'alias '+i,
                        type:   store.NON_CONSUMABLE


            // When everything goes as expected, it's time to celebrate!
            if ( store.ready(function() {
                console.log("\\o/ STORE READY \\o/");

            // After we've done our setup, we tell the store to do
            // it's first refresh. Nothing will happen if we do not call store.refresh()
            if ( store.refresh();

You can also send the store object to console.log to have a good look at it in chrome debugger.

Oh, and if you have more than one app, make sure you are using the correct BILLING_KEY by removing and readding the plugin.

Good Luck!