[Solved] In-app billing: why doesn't loadProductsCallback fire?

Yikes, this is what happens as soon as I post things on Forum. The thing is, I added the store.canLoadProducts to the code when I was unable to get the products to load on my Android device. The internet connectivity issue made the process excruciating for me. Anyhow, I just went back to the basics, and read the in-app billing blog post, and it does state that store.loadProducts() function works for iOS in-app purchases only.

And now, I looked at the in-app billing sample code (that comes with Corona SDK) once again and more carefully. Now I realize I was going about doing this completely wrong. It looks like what I need to do is to manually assign/insert my in-app products to validProducts table (rather than calling a function to do so, which is the case with iOS version). It’s so strange, but writing out a problem actually helped me see the problem.


I don’t understand why store.canLoadProducts returns false. I’ve run my Android build on Galaxy 2S, and it still returns false.

I use the same code base to build both iOS version and the Android version, and iOS version works perfectly fine and I can purchase IAP products from iTunes sandbox without any problem, but I can’t get the product to load on Android device. What can possibly block products from loading properly on an Android device that can handle in-app billing?

Here’s the relevant code I’m using on main.lua:
[lua]if (_G.isIAP == true) and (not isSimulator) then

– this is the print statement that returns “false”, and because it returns false,
– store.loadProducts never gets triggered.
– I even tried calling store.loadProducts outside the if-statement to make sure
– it gets fired – but even if it gets fired, loadProductsCallback never fires anyway.
print("store.canLoadProducts = " … tostring(store.canLoadProducts))

function setupMyStore(event)
if (store.isActive) and (store.canLoadProducts) then
store.loadProducts( productsForSale, loadProductsCallback )
else
print(“this device does not support in-app billing”)
end
end

if store.availableStores.apple then
store.init(“apple”, transactionCallback)
elseif store.availableStores.google then
store.init(“google”, transactionCallback)
else
print(“this device does not support in-app billing”)
end
timer.performWithDelay (1000, setupMyStore);
end[/lua]

My build.settings looks like this:
[lua]android =
{
usesPermissions =
{
“com.android.vending.BILLING”,
},
},[/lua]

I have no androidPermissions and no other usesPermissions.

On Developer Console, I have my game listed (still unpublished) with in-app products added. All of the in-app products are in published state.

This past few days, I’ve had horrendous internet connectivity (thanks to AT&T’s DSL line, which we are about to ditch) and had massive trouble generating builds, but I feel I’ve tested enough to know that whatever is wrong isn’t my build.

What am I missing? Why the store cannot load products? What can possibly cause the store.canLoadProducts to be false?

I’d so appreciate any insight and help.

Naomi

Edit: My problem must have something to do with the setting of my game at Developer Console, but I’m just unable to spot it. The internet connectivity issue has caused lots of grief, including adding the APK file (which failed one too many times before it finally made it). That said, FWIW, I’m using daily build 783.

[import]uid: 67217 topic_id: 24838 reply_id: 324838[/import]

In case others get stuck like I did, here’s the edited version of the setupMyStore function (which I have to test as soon as the build is made, but I think it would do the job).

Naomi

Edit: Just remembered to clean this up.

[lua]function setupMyStore(event)
if (_G.isApple == true) then
store.loadProducts( productsForSale, loadProductsCallback )
elseif (store.isActive) then
– 6 is the total number of validProducts available at the store
– productsForSale is the table that lists in-app product ID
for i=1,6 do
validProducts[i] = {};
validProducts[i].productIdentifier = productsForSale[i];
end
else
print(“this device does not support in-app billing”)
end
end[/lua] [import]uid: 67217 topic_id: 24838 reply_id: 100723[/import]