Hi there! I have developed Corona SDK project using amazon IAP function.
I think I have done all required, but IAP doesnt work.
Here is the all code and settings I hade.
in “build.settings” fine
plugins =
{
– key is the name passed to Lua’s ‘require()’
[“plugin.amazon.iap”] =
{
– required
publisherId = “com.amazon”,
},
},
in main.lua
local amazonProductList =
{
“comstormyweatherlightning”,
“comstormyweatherrainbow”,
“comstormyweatherhotcold”,
“comstormyweatherbonusmoves”,
“comstormyweatherbuyall”,
}
local function storeListener( event )
local transaction = event.transaction
if transaction.state == “purchased” then
print(“productIdentifier”, transaction.productIdentifier)
print(“receipt”, transaction.receipt)
print(“transactionIdentifier”, transaction.identifier)
print (“The user who made the purchase was”, transaction.userId)
--Entitle this SKU here:
if(transaction.productIdentifier == “comstormyweatherbonusmoves”) then
_G.MoveBonus = _G.MoveBonus + 3
elseif(transaction.productIdentifier == “comstormyweatherlightning”) then
_G.LightningBonus = _G.LightningBonus + 3
elseif(transaction.productIdentifier == “comstormyweatherrainbow”) then
_G.RainbowBonus = _G.RainbowBonus + 3
elseif(transaction.productIdentifier == “comstormyweatherhotcold”) then
if(HotCold) then
_G.Therm1Bonus = _G.Therm1Bonus + 3
else
_G.Therm2Bonus = _G.Therm2Bonus + 3
end
elseif(transaction.productIdentifier == “comstormyweatherbuyall”) then
_G.MoveBonus = _G.MoveBonus + 3
_G.RainbowBonus = _G.RainbowBonus + 3
_G.LightningBonus = _G.LightningBonus + 3
_G.Therm1Bonus = _G.Therm1Bonus + 3
_G.Therm2Bonus = _G.Therm2Bonus + 3
end
elseif transaction.state == “restored” then
print(“productIdentifier”, transaction.productIdentifier)
print(“receipt”, transaction.receipt)
print(“transactionIdentifier”, transaction.identifier)
print (“The user who made the purchase was”, transaction.userId)
--Entitle this SKU here:
elseif transaction.state == “revoked” then
print(“productIdentifier”, transaction.productIdentifier)
print(“receipt”, transaction.receipt)
print(“transactionIdentifier”, transaction.identifier)
print (“The user who has a revoked purchase is”, transaction.userId)
--Revoke this SKU here:
elseif transaction.state == “failed” then
print(“Transaction failed”, transaction.errorType, transaction.errorString)
--display an error message here
end
end
local function loadProductsListener( 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
end
store = require “store”
if system.getInfo(“targetAppStore”) == “amazon” or system.getInfo(“environment”) == “simulator” then
store = require “plugin.amazon.iap”
store.init( storeListener )
print("The currently logged in user is: ", store.getUserId())
store.restore()
store.loadProducts(amazonProductList, loadProductsListener)
end
purchase calling
…
store.purchase(“comstormyweatherbonusmoves”)
…
store.purchase(“comstormyweatherbuyall”)
…
store.purchase(“comstormyweatherlightning”)
…
store.purchase(“comstormyweatherrainbow”)
Please help me why it doesn not work?
where I made mistake?
PS: I add amazon app tester’s json file
amazon.sdktester.json
{
“comstormyweatherlightning” : {
“itemType”: “CONSUMABLE”,
“price”: 0.99,
“title”: “LightningBolt”,
“description”: “Gain 3 Lightning Bolts”
},
“comstormyweatherrainbow” : {
“itemType”: “CONSUMABLE”,
“price”: 0.99,
“title”: “Rainbow”,
“description”: “Gain 3 Rainbow bonuses”
},
“comstormyweatherhotcold” : {
“itemType”: “CONSUMABLE”,
“price”: 0.99,
“title”: “HotCold”,
“description”: " Gain 3 of Hot or Cold bonuses"
},
“comstormyweatherbonusmoves” : {
“itemType”: “CONSUMABLE”,
“price”: 0.99,
“title”: “BonusMoves”,
“description”: “Gain 3 Bonus Moves (each adding 5 extra moves)”
},
“comstormyweatherbuyall” : {
“itemType”: “CONSUMABLE”,
“price”: 2.99,
“title”: “BuyAll”,
“description”: “Gain 3 additional of ALL bonuses”
}
}