In App purchase 2 plugin issue, product price is showing null for android. It works on iOS

Hi Everybody,

I’m trying to open another topic about this since the other one is getting completely ignored:

Is this In App purchase 2 plugin not supported anymore? Or am I doing something wrong?

Thanks and regards,
Alex

1 Like

Hello Alex,

What version of cordova-plugin-purchase is installed? First make sure you’re using the latest version, the problem might occur if you’re using an outdated version.

Regards

Hi JC,

Thanks a lot for replying!
I was using 8.1.0 for a while. But I’ve now upgraded to:
cc.fovea.cordova.purchase 10.1.1 “Purchase” (directly from my cordova plugin list)
and I’m still getting the error.

Thanks and regards,
Alex

OK, can you provide a full log? You can set store.verbosity = store.DEBUG before the initial call to refresh() to get as much logs as possible.

EDIT: I had to cut the body. Let me know if this is enough or I’ll figure out a way to send the whole content

Here it goes. This has several changes I did for testing already in the id of products. None of them worked. The “original” that’s in production is all without the package name, so, vegglypremium here for example is in production, works for purchasing but the details (price, description etc) come with null.

[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configurePurchasing - Starting Configurations
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configurePurchasing - Starting Configurations
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Registering Consumable “1coin”
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: state: 1coin -> registered
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: store.trigger -> triggering action refreshed
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: refresh -> checking products state (1 products)
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: refresh -> product id 1coin (1 Coin)
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: in state ‘registered’
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: store.trigger -> triggering action re-refreshed
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: iabGetPurchases()
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: iabSetPurchases:
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: inappbilling.getPurchases() -> Success
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: -> object
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: ->
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: store.trigger -> triggering action refresh-completed
[app-scripts] [20:30:43] console.log: store ready
[app-scripts] [20:30:43] console.log: Store is Ready: undefined
[app-scripts] [20:30:43] console.log: Products: [{“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“registered”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:false,“canPurchase”:false,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null}]
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: iabUpdatePurchases:
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: state: 1coin -> valid
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called for 1coin
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated: {“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“valid”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:true,“canPurchase”:true,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null,“valid”:true}
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Purchase was Cancelled. {“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“valid”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:true,“canPurchase”:true,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null,“valid”:true}
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called for 1coin
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated: {“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“valid”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:true,“canPurchase”:true,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null,“valid”:true}

From your code, it looks like your code is a little wrong. store.refresh() should only be called once. I wonder if you are also re-registering the same product?

Anyway, I think the fix is to make sure you do this:

  1. register all your products (store.register(...))
  2. call store.refresh() (only once)

You can use store.ready(function() { ... }); to run some code only after all products have been loaded.

Ok. This was indeed happening. But I changed it to call it only once and it still failed. I even changed it to register only one product and the details still come all null. I updated the comment above but here it goes again, since I think it should be easier and cleaner to understand what’s going on.

BTW, after upgrading to the latest plugin version, I only removed and re-added the platform Android, rebuilt and run. Should that be enough?

[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configurePurchasing - Starting Configurations
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configurePurchasing - Starting Configurations
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Registering Consumable “1coin”
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: state: 1coin -> registered
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: store.trigger -> triggering action refreshed
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: refresh -> checking products state (1 products)
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: refresh -> product id 1coin (1 Coin)
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: in state ‘registered’
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: store.trigger -> triggering action re-refreshed
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: iabGetPurchases()
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: iabSetPurchases:
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: inappbilling.getPurchases() -> Success
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: -> object
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: ->
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: store.trigger -> triggering action refresh-completed
[app-scripts] [20:30:43] console.log: store ready
[app-scripts] [20:30:43] console.log: Store is Ready: undefined
[app-scripts] [20:30:43] console.log: Products: [{“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“registered”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:false,“canPurchase”:false,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null}]
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: iabUpdatePurchases:
[app-scripts] [20:30:43] console.log: [store.js] DEBUG: state: 1coin -> valid
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called for 1coin
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated: {“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“valid”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:true,“canPurchase”:true,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null,“valid”:true}
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Purchase was Cancelled. {“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“valid”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:true,“canPurchase”:true,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null,“valid”:true}
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated called for 1coin
[app-scripts] [20:30:43] console.log: PurchaseServiceProvider.configureProduct - Updated: {“id”:“1coin”,“alias”:“1
[app-scripts] Coin”,“type”:“consumable”,“group”:"",“state”:“valid”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“countryCode”:null,“loaded”:true,“canPurchase”:true,“owned”:false,“introPrice”:null,“introPriceMicros”:null,“introPricePeriod”:null,“introPriceNumberOfPeriods”:null,“introPricePeriodUnit”:null,“introPriceSubscriptionPeriod”:null,“introPricePaymentMode”:null,“ineligibleForIntroPrice”:null,“discounts”:,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null,“valid”:true}

Hold on. I think I got it! There was still a store.ready called before everything. I’ll undo everything I did and test to confirm everything is still working but the details are now coming so don’t worry about it for now.

I’ll update once I have confirmation.
Thanks a lot for the help!

Alex

I confirm this is working now!
I’ll still test on iOS now to confirm it still works there but there’s no reason to believe it won’t.

Thanks a lot, JC!

@jchoelt I keep getting a product invalid message when running in iOS emulator. Can we NOT test this on emulator? Does it have to be on a real device?

@afelipelli I’m still trying to get this working in iOS. I keep getting an invalid product. In the app store it says I’m missing meta data.

[store.js] DEBUG: state: productname -> invalid

The tutorials I’ve watched never added any meta data for the products in the store. Did you have to add the screenshots in App Store and the video just to test?

Hi there,

I do believe you have to test on a real device.

Now, screenshots and video of the in-app purchase products I haven’t put in the app store even in production. I do have screenshots of the app itself but not the products.

In my case, the issue was that I was calling store.refresh() more than once. When I fixed that, it started working fine.

I hope it helps

@DMoney were you able to fix this error?
I have this very same problem.
In my case, it still works on iOS real device and Xcode emulator.
On android, it’s not working on emulator neither on real device.

I get the error [store.js] DEBUG: state: product.name -> invalid

My products are subscriptions and I have checked the BILLING_KEY value, it’s all right.

@victorpinheiro0 I got it working on iOS but I still have not been able to resolve the issue on Android. Just like you, iOS works on the emulator and real device.

My products are non-consumable but it shouldn’t matter. And I’ve followed the tutorials but I don’t see the BILLING_KEY in PlayStore. Is that required?