Anyone implemented In-app billing in Cordova as a working PlugIn? or is there another way?

3,206 views
Skip to first unread message

Akeman

unread,
May 24, 2012, 12:23:47 PM5/24/12
to phon...@googlegroups.com
Hi All,

We are now getting to the part where we are well out of our comfort zone. We want to allow a single item, the app, to be bought within our application.

Can anyone point in the direction of a good tutorial for this functionality that will make sense to HTML/Javascript coders?

Cheers

Tim

Asif Ytzhak

unread,
May 24, 2012, 2:24:11 PM5/24/12
to phonegap
Hi,
I'm also looking for a plugin that can invoke Android In-App Billing
from Cordova apps.
We already have In-App Purchases for iOS apps (using this great
plugin: https://github.com/phonegap/phonegap-plugins/tree/master/iOS/InAppPurchaseManager),
but an Android equivalent plugin is really missing.
I've searched the net and found only this plugin, which seems to not
be working:
https://github.com/luoihoc/CallbackBillingPlugin

It would be great if someone who have implemented a working In-App
Billing for Android Cordova apps will share it with us.

Cheers.

Horst

unread,
Aug 15, 2012, 10:52:49 AM8/15/12
to phon...@googlegroups.com
I have tried your version with 1.8.1 and 1.9.0. But i always get the message "Failed to start the purchase process" or "Failed to get ownded item list".
I have tried with signed app on real device and also added some Items to the app (i think for android.test.xxx it should not matter).

Any idea what can be wrong?


best regards
Horst

Horst

unread,
Aug 17, 2012, 5:37:48 AM8/17/12
to phon...@googlegroups.com, tim.b...@akemansolutions.com
Hello Roger,

can you give more details, how you done it?

Set up the test project with android.test.items? On real device? Signed app? Set up something in Play Store?

best regards
Horst

Roger Large

unread,
Aug 17, 2012, 11:46:17 PM8/17/12
to phon...@googlegroups.com, tim.b...@akemansolutions.com
Ya just with the test items and workflow... just got it working on 2.0 tonight migrating everything to that.... i have items set up in the app store i will try but don't for see any problems

Roger Large

unread,
Aug 17, 2012, 11:53:59 PM8/17/12
to phon...@googlegroups.com, tim.b...@akemansolutions.com
To get it to work on 2.0 do this:

Change all of the varabiles in plugin billing from this:

CallbackBillingPlugin.prototype.test = function(success, fail) {
PhoneGap.exec(success, fail, "CallbackBillingPlugin", "test", []);
};
    
To this:

window.CallbackBillingPlugin.prototype.test = function(success, fail) {
PhoneGap.exec(success, fail, "CallbackBillingPlugin", "test", []);
};

On everyone just not the first one.... and at the bottom remove this:

PhoneGap.addConstructor(function() {
PhoneGap.addPlugin("CallbackBillingPlugin", new CallbackBillingPlugin());
});

and REPLACE with this:

window.CallbackBillingPlugin = new CallbackBillingPlugin();

In index.html change all the :

window.plugins.BLABLABLABLA

TO JUST:

window.BLALBBLALBAL

AND THATS IT AND IT WORKS FOR ME...

roger

doubledutch

unread,
Sep 4, 2012, 12:12:08 PM9/4/12
to phon...@googlegroups.com, tim.b...@akemansolutions.com
Just a small footnote for those working in Eclipse. Probably very obvious but to use before you can compile this plug-in into your eclipse project I had to:

- create package: com.android.vending.billing
- drag IMarketBillingService.aidl to that package in eclipse


doubledutch

unread,
Sep 4, 2012, 1:37:28 PM9/4/12
to phon...@googlegroups.com, tim.b...@akemansolutions.com
I'm very close getting this to work (I think) but falling over at the final hurdle wonder if someone could point me in the right direction

- Code is installed and compiles in Eclipse
- Configured in app purchase item in Google play
- APK is signed correctly (I believe) but besides the product ID I configured in google play - I have not changed anything else in my phonegap code (should I personalize anything else?)
- I call this code:

        function TryInAppPurchase()
        {
            var    productId = "100_monkey_nuts";
            window.CallbackBillingPlugin.requestPurchase(
                    function(s) {
                        var data = $.parseJSON(s);
                        ConsoleLog('AndroidIAP - requestPurchase: SUCCEED');
                        ConsoleLog('AndroidIAP - requestPurchase: '+ data.event);
                        if (data.event == 'onRequestPurchaseResponse') {
                            ConsoleLog('AndroidIAP -  productId = '+ data.productId);
                            ConsoleLog('AndroidIAP -  responseCode = '+ data.responseCode);
                            ConsoleLog('AndroidIAP - ------------------------------');
                        } else if (data.event == 'onPurchaseStateChange') {
                            ConsoleLog('AndroidIAP -  purchaseState = '+ data.purchaseState);
                            ConsoleLog('AndroidIAP - ------------------------------');
                        }
                    },
                    function(f) {
                        ConsoleLog('AndroidIAP - requestPurchase: FAILED');
                        ConsoleLog('AndroidIAP - ------------------------------');
                    },
                    productId
                );
        }

But I get the errors:

requestPurchase FAILED (and nothing more helpful....)

Not sure where to look now. Any thoughts?

inator

unread,
Nov 3, 2012, 11:26:41 AM11/3/12
to phon...@googlegroups.com
@geothird - I downloaded and have run your ported code successfully, with one exception.  When I try to list the purchased items I always get "No owned items found" even after making a test purchase.  Do you get the same result?

On Sunday, July 22, 2012 1:02:29 PM UTC-7, geothird wrote:
Not sure if this helps you, but I updated the plugin project to work with cordova-1.9.0, it will only work on a physical device not in the emulator otherwise you get the "Could not bind to service." error. 

Tor Claesson

unread,
Feb 25, 2013, 12:12:30 PM2/25/13
to phon...@googlegroups.com
I keep getting a "Signature verification failed"-error.
Anyone know what might cause this?

Den onsdagen den 28:e november 2012 kl. 21:54:49 UTC+1 skrev Oliver Lienhard:
Hi

i tried your example in cordova 2.2. All seams to work, but when i cklick the button buy, i get the error: requestPurchased Failed

In the eclipse console:
CallbackBillingPlugin CALLED
productID = bonsai.manager.pro
Request Purchase: bonsai.manager.pro 
an then nothing more.....
There has to popup the google play store purchase window right?

In Google Play i added an in app purchase item bonsai.manager.pro same name in the dropdown value.

Do i miss somthing else?

Thanks for any idea

Tor Claesson

unread,
Feb 26, 2013, 2:01:38 AM2/26/13
to phon...@googlegroups.com
Never mind, I started using Poiutrez's InAppBilling-plugin instead, works like charm for me. =)
https://github.com/poiuytrez/phonegap-plugins/tree/master/Android/InAppBilling

poiuytrez2

unread,
May 24, 2013, 10:51:22 AM5/24/13
to phon...@googlegroups.com
I have just pushed the in app billing plugin v3 for cordova on my repository :


On Friday, May 17, 2013 12:33:50 PM UTC+2, br...@itsybits.net wrote:
Does anyone have an updated plugin for v3? We're trying to get our new app to work with IAP on Android but haven't found anything for API version 3... thoughts?

Robert Eroh

unread,
Nov 12, 2014, 6:57:40 PM11/12/14
to phon...@googlegroups.com
There is now a cordova plugin that works for both ios and android:
Reply all
Reply to author
Forward
0 new messages