j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

[Android] product invalid #86

Closed ghost closed 9 years ago

ghost commented 9 years ago

I am still blocked . When I print products on the console with store.products Here is what I am for my own product :

store.Product alias: "pack1" canPurchase: false currency: null description: null id: "com.example.pack1" loaded: false owned: false price: null state: "registered" title: null transaction: null type: "non consumable" proto: Object

And here is what I have with test product alias: "pack3" canPurchase: true currency: "EUR" description: "Sample description for product: android.test.purchased." id: "android.test.purchased" loaded: true owned: false price: "0,79 €" state: "valid" title: "Sample Title" transaction: null type: "non consumable" valid: true proto: Object

Any ideas ?

rafaellop commented 9 years ago

price: null ? Have you set the price?

ghost commented 9 years ago

Yes, I did ... I presume the app does not link with android console. several possibilities : product id not matching , still not available ... no idea how to debug this ?

rafaellop commented 9 years ago

Hmm... If everything is set in Play Store then I suppose your store object doesn't update the product. It's the only option now. Call store.register with your product and wait with the console output till you got the updated event and in the event only log the product to console, e.g.

store.register({id: 'com.example.pack1', type: store.CONSUMABLE});
store.when("product").updated(function (p) {
            console.log('id: ' + p.id);
            console.log('id: ' + p.price);
});

Hope this helps.

ghost commented 9 years ago

actually store.when("product").updated never fire ...

rafaellop commented 9 years ago

So you have your answer. You must go back to the docs and validate each step that Jean has described there.

j3k0 commented 9 years ago

Hey @rocket270 Did you make any progress?

rafaellop commented 9 years ago

I've come over a similar issue. I've a created new application and haven't published it yet. Now I'm getting a bunch of invalid product logs for all items I've got in the app. The steps I did was:

1) create the app and configure inapp in google play 2) create a release version of apk with its own license key in the billing_key.xml 3) upload the app to play store 4) create products for in app by importing them through csv exported from the previous app 5) fill the rest of the fields required to activate products (app screenshots, descriptions, etc)

Now the app is configured in the google play but in the alpha mode (not published). All fields required for publication are filled in and all checkmarks are green. All products are active. There's no errors, etc...

Then I install the app on a device with Google Play properly configured (the previous app works perfectly) and unfortunately the only thing I'm getting is a list of invalid products logs.

Jean, do you maybe have an idea how to make this work? Everyhing seems to be ok. I like the CSV method because there are 12 products each with 9 translations and doing this by hand would be such a big pain as the first time.

rafaellop commented 9 years ago

@j3k0 , I think I could find the reason. I have not succesfuly tested this (due to google assets update process which takes time), but it might be it. The new app has been instantiated by copying the previous app and changing config.xml data and cleaning the platform/android/ build folders. However, when digging, I've just found that I forgot to change the app identifier in one place. It is the android.json file located in the /plugins directory which is generated when plugins are added to the app. There's a section named installed_plugins which contains package name id. @rocket270 maybe this is your sources of problems as well?

"installed_plugins": { "cc.fovea.cordova.purchase": { "PACKAGE_NAME": "com.domain.oldapp" },

I hope that changing names in this file will be enough. How do you think? I don't want to rm and read d plugins because some of them are modified by me.

I'll let you know in few hours (Google schedule...) whether this worked. At the moment the app started to log init failed error which is a good sign because the change in the json seems to change something in the communication.

nickghall commented 9 years ago

I am having the same problem, the plugin is initializing but none of my apparently-valid products will update. Or rather, update gets called, but the product title, price, etc are still null after store.when("unlockgame").updated(function (p) gets called. My code and troubleshooting steps are detailed in http://stackoverflow.com/questions/27322639/cannot-retrieve-products-from-google-play-store-with-fovea-purchase-plugin, suggestions appreciated...

rafaellop commented 9 years ago

I said I'll write moe in few hours but in fact after a day I'm still nowhere. I've tried everything but I cannot still get validated products from the store though I get the \\o/ STORE READY \\o/" log. I have even removed the app from Google Play and created a new one with different app id, added new screenshots, descriptions, new signed and released apk, new license key, new products imported, etc. almost completely new app. There are only two things I haven't tried: 1) not to import products but to add them manually; 2) create new app locally from scratch step by step instead of using my codebase. 3) publish app instead of working in Alpha mode (however docs states it is not necessary to have it published) I'm doing this two things right now. I hope I'll have some better news tommorow. It's strange because it was like a piece of cake to add IAB to my previous app.

nickghall commented 9 years ago

Well that's disappointing - with three of us having this issue it would seem to be a bug. What's different between the new app where you're having this problem and the previous one where this plugin worked? Is there an older version of this plugin that has been confirmed to work on Android?

rafaellop commented 9 years ago

I suppose the problem is not on the plugin side, but rather cordova or google.

nickghall commented 9 years ago

Sure, anything's possible. @j3k0, if you can't repro this, please pipe up if you need any more info or logs or would like me to try anything. I've got time to work on this but I'm out of troubleshooting ideas.

nickghall commented 9 years ago

Here's the entire logcat from the store init. Is it problematic that the store.ready seems to be finishing well after the products are registered and store.refresh returns?

12-05 16:34:01.584: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'com.ineptech.wn.unlockgame registered'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'unlockgame registered'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'non consumable registered'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'registered'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'com.ineptech.wn.unlockgame updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'unlockgame updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'non consumable updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.585: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: queries ++ 'unlockgame approved'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.586: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: queries ++ 'updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.586: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.trigger -> triggering action refreshed", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.586: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: queries !! 'refreshed'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.586: I/chromium(25685): [INFO:CONSOLE(725)] "InAppBilling[js]: setup ok", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (725) 12-05 16:34:01.586: I/chromium(25685): [INFO:CONSOLE(725)] "InAppBilling[js]: load ["com.ineptech.wn.unlockgame"]", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (725) 12-05 16:34:01.701: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: android -> ready", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.704: I/chromium(25685): [INFO:CONSOLE(725)] "InAppBilling[js]: getAvailableProducts called!", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (725) 12-05 16:34:01.714: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: android -> loaded - []", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.714: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'com.ineptech.wn.unlockgame invalid'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.714: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'unlockgame invalid'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.715: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'non consumable invalid'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.715: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'invalid invalid'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.715: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'invalid'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.717: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'com.ineptech.wn.unlockgame updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.718: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'unlockgame updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.719: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'non consumable updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.719: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'invalid updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.720: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.722: I/chromium(25685): [INFO:CONSOLE(271)] "Product updated: com.ineptech.wn.unlockgame , title null , price null", source: file:///android_asset/www/js/index.js (271) 12-05 16:34:01.723: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'com.ineptech.wn.unlockgame loaded'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.727: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'unlockgame loaded'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.728: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'non consumable loaded'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.729: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'invalid loaded'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.729: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'loaded'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.730: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'com.ineptech.wn.unlockgame updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.732: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'unlockgame updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.732: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'non consumable updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.733: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'invalid updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.733: I/chromium(25685): [INFO:CONSOLE(452)] "[store.js] DEBUG: store.queries !! 'updated'", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (452) 12-05 16:34:01.734: I/chromium(25685): [INFO:CONSOLE(271)] "Product updated: com.ineptech.wn.unlockgame , title null , price null", source: file:///android_asset/www/js/index.js (271) 12-05 16:34:01.736: I/chromium(25685): [INFO:CONSOLE(725)] "InAppBilling[js]: getPurchases called!", source: file:///android_asset/www/plugins/cc.fovea.cordova.purchase/www/store-android.js (725) 12-05 16:34:01.739: I/chromium(25685): [INFO:CONSOLE(248)] "Purchase check shows unlockgame is not owned", source: file:///android_asset/www/js/index.js (248) 12-05 16:34:01.743: I/chromium(25685): [INFO:CONSOLE(253)] "\o/ STORE READY \o/", source: file:///android_asset/www/js/index.js (253)

rafaellop commented 9 years ago

I've done last tests and give up... I've built a completely new app from scratch, published it to the Alpha channel, added descriptions, screenshots, products, installed billing key, built release version of the apk and signed it, cleared cache for Google Play Store app and removed all data it kept on the device and the log caused that I threw my keyboard out the window:

12-06 01:38:26.300: I/Web Console(11976): INVALID PRODUCT: buyme_test alias: buyme_test ...
12-06 01:38:26.310: I/Web Console(11976): InAppBilling[js]: getPurchases called! 
12-06 01:38:26.310: I/Web Console(11976): \o/ STORE READY \o/ 

I've done literally everything according to the docs and still cannot make it works. Guys, please tell me, because this is the last chance I can see in this dark tunnel... Is it really enough to publish app to Alpha channel to test IAB from a device with the developer account used as the Google Play Store app account or is it obligatory to use this stupid community groups from G+ just to test this? For the previous app which was published it was enough to add email of testers in the general settings of the account and it worked. Now I must do some crazy stuff with creating a test account, create community group, add the fake user to the group, then create a profile for it on my device and then finally I'll be able to see that a product is downloaded? WTF ? Sorry but my nerves are like strings that anything can play on them arias...

rafaellop commented 9 years ago

I've just found when wandering the stack overflow that an app must published even in the alpha state. This is really unclear. For me publishing is making an app available to public. It seems that publish an app which has APK uploaded only to Alpha state is not the real publication but only a publication to the Alpha state :-\ Now I must wait till it propagate on the servers. So it is a good opportunity to go to sleep finally (2 AM here :/). I'll let you know tommorow.

nickghall commented 9 years ago

@rafaellop Sorry to be too late to help much but I think I had the same problem. For me, once I moved to Beta I did see test purchases come through using an account that had been added to the tester group (just put the email address in the Testers box, no need to make a Google+ group). That was using a different plugin though, I can't get anything to work on this one.

I'll wait a bit to see if anyone has any troubleshooting suggestions before I think about going back to the other plugin... Let me know if it works for you!

rafaellop commented 9 years ago

Ok, publishing the app solved all my troubles. So, even in the Alpha state the app must be published to get valid state of a store and products. @j3k0 please add this to the docs if possible. This would save me a lot of time. You can also add there a warning not to purchase the test product from Google android.test.purchased because it is impossible to validate it later and causes errors of invalidate certificate. Stock Overflow is full of questions related to this and I fell into this trap. The plugin is great!

j3k0 commented 9 years ago

Hey @rafaellop,

It's already mentioned in the setup guide: https://github.com/j3k0/cordova-plugin-purchase/wiki/HOWTO#create-android-applications

However, I understand it can be missed. When I'll have more time, I'd like to start putting together a "troubleshooting" document on the wiki. Publishing the app on Android will have to be among the first things to check on Android.