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

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!