Hi tamkinp,
That was a typo (I fixed it in my original post). I am indeed checking store.canLoadProducts.
In terms of my code, since I’m doing a cross platform app it is a little messy with if thens to cover all the app stores and slightly different requirements for each, but I’ll snip out some of the relevant parts here:
EDIT: ugh. This forum editor/tagging really screwed up the indentation of my code when I used the lua tags. Had to revert back to normal text for the lua code parts.
from build.settings:
["plugin.amazon.iap"] = { publisherId = "com.amazon",}, --comment out when NOT building for Amazon store? --["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", }, -- comment out when building for iOS or Amazon Android, otherwise won't build for iOS. waiting for plugin to be enabled for iOS. App will force quit on Amazon Android version since it can't find google play store. How to do leaderboards on Amazon version? },
from main.lua:
–in app purchases in Corona
local store = require(“store”) --covers Apple and Google Play stores
if store.target == “amazon” then
store = require “plugin.amazon.iap” --covers Android for Amazon store
end
From my IAP scene: This is a little tough to follow but I’ll snip out the relevant bits in the order it runs:
--initialize the store
if Component:testNetworkConnection() == true then
if store.availableStores.apple then
currentProductList = appleProductList
store.init(“apple”, transactionCallback)
print(“Using Apple’s in-app purchase system.”)
elseif store.availableStores.google then
currentProductList = googleProductList
store.init(“google”, transactionCallback)
print(“Using Google’s Google Play Android In-App purchase system.”)
elseif store.target == “amazon” then-- amazon IAP plugin doesn’t support store.availableStores API so need to use store.target
--amazon store
currentProductList = amazonProductList
store.init(transactionCallback)
print(“Using Amazon’s Android In-App purchase system.”)
--elseif then
--TODO add Nook store IAP functionality
elseif isSimulator == true then
currentProductList = simulatorProductList
else
print(“In-app purchases is not supported on this system/device.”)
native.showAlert(“Store purchases are not supported on this system/device.”,
{ “OK” }, onClose )
end
else
native.showAlert( strings:getString(“alertNoNetworkDetected”), strings:getString(“alertNetworkRequiredForIAP”), { strings:getString(“alertNetworkCloseButton”) }, onClose )
end
timer.performWithDelay (500, setupMyStore)
after the 500 ms delay, setupMyStore fires:
function setupMyStore(event)
if store.isActive or isSimulator then
print("store.canLoadProducts = "…tostring(store.canLoadProducts))
if (store.canLoadProducts) then
– Property “canLoadProducts” indicates that localized product information such as name and price
– can be retrieved from the store (such as iTunes). Fetch all product info here asynchronously.
store.loadProducts( currentProductList, loadProductsCall
else
print(“can’t load products, either google play or simulator, or a problem!”)back )
print (“After store.loadProducts, waiting for callback”)
if store.canLoadProducts was true then it would continue to my loadProductsCallback function, but it never gets here since it store.canLoadProducts is false for some reason. But here’s the loadProductsCallback anyway:
function loadProductsCallback( event )
local products = event.products
for i=1, #event.products do
print(event.products[i].title)
print(event.products[i].description)
print(event.products[i].localizedPrice)
print(event.products[i].productIdentifier)
end
for i=1, #event.invalidProducts do
print(event.invalidProducts[i])
end
– save for later use
validProducts = event.products
invalidProducts = event.invalidProducts
unpackValidProducts()
end
I also have a transactionCallback function that I know functions correctly for the other app stores, so I won’t include it here, but so far it doesn’t matter since the product ids/skus are not being grabbed from the ones I set up for Amazon.
And here is the amazon.sdktester.json file (actual skus removed) I placed on the device inside the …/sdcard/ folder on the device.
{ "...candy101": { "itemType": "CONSUMABLE", "price": 0.99, "title": "Candy Bag", "description": "Big bag with 1,000 pieces of Candy! TEST AMAZON", "smallIconUrl": "http://www.hardboiledindustries.com/page4/files/stacks\_image\_19.png" }, "...candy201": { "itemType": "CONSUMABLE", "price": 1.99, "title": "Candy Bowl", "description": "Large bowl filled with 2,500 pieces of Candy! TEST AMAZON", "smallIconUrl": "http://www.hardboiledindustries.com/page4/files/stacks\_image\_19.png" }, "...candy301": { "itemType": "CONSUMABLE", "price": 2.99, "title": "Candy Wagon", "description": "Huge wagon filled with 7,500 pieces of Candy! Get more and save! TEST AMAZON", "smallIconUrl": "http://www.hardboiledindustries.com/page4/files/stacks\_image\_19.png" }, "...candy401": { "itemType": "CONSUMABLE", "price": 3.99, "title": "Candy Barrel", "description": "Barrel bursting with 7,500 pieces of Candy! Get more and save! TEST AMAZON", "smallIconUrl": "http://www.hardboiledindustries.com/page4/files/stacks\_image\_19.png" }, "...candy501": { "itemType": "CONSUMABLE", "price": 4.99, "title": "Candy Crate", "description": "Massive crate filled with 10,000 pieces of Candy. A steal! TEST AMAZON", "smallIconUrl": "http://www.hardboiledindustries.com/page4/files/stacks\_image\_19.png" }, "...candy601": { "itemType": "CONSUMABLE", "price": 9.99, "title": "Candy Crane", "description": "Construction crane spilling with 25,000 pieces of Candy! Best deal! TEST AMAZON", "smallIconUrl": "http://www.hardboiledindustries.com/page4/files/stacks\_image\_19.png" } }
At first I thought perhaps the delayed setupMyStore function was getting called to early, before the store.init fired, but checking the logcat debugging prints I see it is getting called after. Here’s part of the logcat log with my debugging statements:
I/Corona ( 4827): Output string :: Using Amazon's Android In-App purchase system. I/Corona ( 4827): I/Corona ( 4827): Output string :: GameStats:getDisplayAdsState() = false I/Corona ( 4827): I/Corona ( 4827): Output string :: removeBannerAd I/Corona ( 4827): I/Corona ( 4827): Output string :: removing cookie rotate listener I/Corona ( 4827): I/Corona ( 4827): Output string :: store.canLoadProducts = false I/Corona ( 4827): I/Corona ( 4827): Output string :: can't load products (google play or simulator... I/Corona ( 4827): I/Corona ( 4827): Output string :: Loading product list I/Corona ( 4827): I/Corona ( 4827): Output string :: Product list loaded I/Corona ( 4827): I/Corona ( 4827): Output string :: Country: US I/Corona ( 4827): I/Corona ( 4827): Output string :: Found 6 valid items
Thanks for taking a look.