Google IAP v3 will not initialize - store.isActive always returns false

Hi all, I’m trying to use the Google IAP v3 plugin…  however, store.isActive always returns false.

I have set everything up correctly and read over and over the docs to make sure all is set up correctly…

First, I have build.settings set up correctly with the plugin, billing permission and license key as specified in http://docs.coronalabs.com/daily/plugin/google-iap-v3/index.html

Next, in the guide as in here: http://docs.coronalabs.com/daily/guide/monetization/IAP/index.html the following statement seems wrong:  " Now you should build your app — even if it’s still in development — to create a .apk file which can be uploaded to the Google Play Developer Console. Once it’s uploaded, you must activate it, but do not publish it yet!"  I believe Google docs say that you must upload a signed APK to either alpha or beta and publish it.  I have done this - it’s up in alpha and fully published.  

  • My IAPs are all up on Google Play and made active, ready to use.
  • My device and the build published in Alpha on Google play both use the same version code - so no discrepency there.
  • IAPs and published APK have been live for days now so no propogation delay there…
  • The Google account I’m using on my device (logged into Google Play app) is not my developer account.  Also, this Google account is set up as a test account in Google Play Dev Console. Also, I have a Google Group set up with this account in it so that in Alpha/Beta testing this account has access…
  • Older device (HTC First) with Android version like 4.1.1 so should be no problem there…

Next, here’s sample code up to the store.isActive call…

I have a “Store” lib (capital “S”) that contains all of my store code.   _ It’s running perfectly on iOS. _  Within Google, I have errors…

Including the store lib correctly…

Store.initialize = function() if device.isApple or device.isGoogle then store.init( store.target, Store.callback ) native.showAlert("STORE INIT", tostring(store.isActive), {'OK'}) end end

On system applicationStart and applicationResume I’m calling an initialize function which runs this code…

if device.isApple or device.isGoogle then store.init( store.target, Store.callback ) native.showAlert("STORE INIT", tostring(store.isActive), {'OK'}) end

In that function when run, the native alert on the device returns false for store.isActive.

Next, when I try to actually load products, I do this…

native.showAlert("LOAD PRODUCTS", tostring(store.isActive) .. ' / ' .. tostring(store.canMakePurchases), {'OK'}) if store.isActive then if store.canLoadProducts then store.loadProducts( Store.UID, Store.process ) end end

In this case, the native alert returns “false / true”.   The conditional below never runs because store.isActive is false.   Store.UID is simply a table with IAP identifiers and Store.process is a callback to handle the return from loadProducts.  Again, in iOS this is working just fine.

Rob or anyone else…  any ideas or insight you can shed on this issue?  Thanks!!

Nate

Would anyone at Corona have any insight into what could be causing this?  Thanks.

Hi @borderleap,

It’s a little hard to follow your code flow because I don’t know what functions you have in what places, what order they’re called in, how/when the “Store” module is require()-d, etc. Also, are you initializing the store in multiple places? Basically, the code you show isn’t really enough to help diagnose what’s going on.

Best regards,

Brent

P.S. - I really like your Alpha Omega game, well done! It’s a real brain-bender as the challenge level increases in later levels. :slight_smile:

Hey there Brent - thanks for the comments about Alpha Omega!  :)   Appreciate your getting back to me - hope I can clarify a few things…

  1.   My “Store” lib contains the actual “store” lib…  I call Store.initialize() from a system event listener on both applicationStart and applicationResume.  The “device” lib is another one that I use to check for iOS vs Android…

    Store.initialize = function() if device.isApple or device.isGoogle then store.init( store.target, Store.callback ) native.showAlert(“STORE INIT”, tostring(store.isActive), {‘OK’}) end end

The native alert that returns always has store.isActive as “false”.

Next, from another lib in the game I also require Store…  I call Store.load() from there when hints are needed - when the hint panel needs to show up:

Store.load = function() native.showAlert("TEST", tostring(store.isActive) .. ' / ' .. tostring(store.canMakePurchases), {'OK'}) if store.isActive then if store.canLoadProducts then store.loadProducts( Store.UID, Store.process ) end end end

Problem is, when I even get to this call, store.isActive is false so it never gets down to loadProducts…

Hope that helps!!

Hi @borderleap,

Where do you require() the store and (ideally) use device detection to decide whether to load the Corona store.* module (iOS) or the Google IAP v3 plugin? Do you do that in main.lua? I would suggest that it be done there, so you’re ready to use the store whenever it’s needed.

Then, when you go to init() the store, make sure (fairly obviously) that it’s using the same variable/reference that you used to require() the store to then init() the store… I suppose you could pass that reference over to your “Store” lib and initialize the store in there.

Also, you should probably wait a short bit after “applicationStart” to initialize the store. Let the app get up and running for a few seconds, or let it reach the title screen or something, then init() the store.

Anyway, try a few of these things and let me know what happens.

Thanks,

Brent

Hey Brent, so I finally got it to work :slight_smile:   It was an error in the way I was including the Google license key.  Thanks for your help!!!

Nate

Would anyone at Corona have any insight into what could be causing this?  Thanks.

Hi @borderleap,

It’s a little hard to follow your code flow because I don’t know what functions you have in what places, what order they’re called in, how/when the “Store” module is require()-d, etc. Also, are you initializing the store in multiple places? Basically, the code you show isn’t really enough to help diagnose what’s going on.

Best regards,

Brent

P.S. - I really like your Alpha Omega game, well done! It’s a real brain-bender as the challenge level increases in later levels. :slight_smile:

Hey there Brent - thanks for the comments about Alpha Omega!  :)   Appreciate your getting back to me - hope I can clarify a few things…

  1.   My “Store” lib contains the actual “store” lib…  I call Store.initialize() from a system event listener on both applicationStart and applicationResume.  The “device” lib is another one that I use to check for iOS vs Android…

    Store.initialize = function() if device.isApple or device.isGoogle then store.init( store.target, Store.callback ) native.showAlert(“STORE INIT”, tostring(store.isActive), {‘OK’}) end end

The native alert that returns always has store.isActive as “false”.

Next, from another lib in the game I also require Store…  I call Store.load() from there when hints are needed - when the hint panel needs to show up:

Store.load = function() native.showAlert("TEST", tostring(store.isActive) .. ' / ' .. tostring(store.canMakePurchases), {'OK'}) if store.isActive then if store.canLoadProducts then store.loadProducts( Store.UID, Store.process ) end end end

Problem is, when I even get to this call, store.isActive is false so it never gets down to loadProducts…

Hope that helps!!

Hi @borderleap,

Where do you require() the store and (ideally) use device detection to decide whether to load the Corona store.* module (iOS) or the Google IAP v3 plugin? Do you do that in main.lua? I would suggest that it be done there, so you’re ready to use the store whenever it’s needed.

Then, when you go to init() the store, make sure (fairly obviously) that it’s using the same variable/reference that you used to require() the store to then init() the store… I suppose you could pass that reference over to your “Store” lib and initialize the store in there.

Also, you should probably wait a short bit after “applicationStart” to initialize the store. Let the app get up and running for a few seconds, or let it reach the title screen or something, then init() the store.

Anyway, try a few of these things and let me know what happens.

Thanks,

Brent

Hey Brent, so I finally got it to work :slight_smile:   It was an error in the way I was including the Google license key.  Thanks for your help!!!

Nate