Hi, so I’ve searched the entire net to no avail. I’ve read through every Corona thread and tried everything and I just can’t seem to figure this out…
So I’ve tried implementing IAP into my app using this code from the code exchange: (http://web-c1.anscamobile.com/code/super-simple-iap-1-line). And here are the things I’ve done so far:
* I’ve set up my billing information in ITC
* Created the iap products in ITC and specified a product ID like so: com.domainName.appName.iapProduct
* I have added the iap code into my project, modifying it to suit my needs:
module(..., package.seeall)
local store = require("store")
local callback = nil
--To get a price from any screen, just call iap.localizedPrices[XX] and replace the XX with the item number that you'd like
localizedPrices = {};
--[[
Fill out this section with the price that you want (otherwise it will load the prices dynamically)
\*\*\*\*\*\*Uncomment this section if you want to override the prices that it fetches\*\*\*\*\*\*
]]--
localizedPrices[1] = "$0.99"
--Fill out this section with all your product IDs. Add or remove them as necessary
local productID = {}
productID[1] = "com.domainName.appName.iapProduct" --buyItem1
--If you specifed a callback, then your callback function (in another lua file) would be something like this:
--[[
local function callback(state)
if (state == "purchased") then
elseif (state == "cancelled") then
elseif (state == "failed") then
end
end
iap.buyItem1(callback)
]]--
function transactionCallback(e)
local trans = e.transaction
if (trans.state == "purchased") then
if (trans.productIdentifier == productID[1]) then --item1
print ("success buying product 1! Give the user the item here, or in the callback (see comments above)");
end
elseif (trans.state == "cancelled") then
print("player cancelled; you may want to show an alert here")
elseif (trans.state == "failed") then
print("transaction failed")
print("event.transaction.errorType = " .. tostring(trans.errorType))
print("event.transaction.errorString = " .. tostring(trans.errorString))
native.showAlert("Oops!" , "Please check your internet connection and try again." , {"Dismiss"}, none)
end
if (callback ~=nil) then callback(trans.state); end
native.setActivityIndicator(false)
store.finishTransaction(trans)
end
store.init(transactionCallback)
local function loadedCallback(e)
for i=1, #e.products do
table.insert(localizedPrices, i, tostring(e.products[i].price))
end
end
store.loadProducts(productID, loadedCallback)
--These are the functions that you call from another lua file.
-- Example: you'd call something like: iap.buyItem3(callback)
function buyItem1 (callbackFunction)
store.purchase({productID[1]})
native.setActivityIndicator(true)
callback = callbackFunction
end
-----------
-- Using this line underneath here to call this module from another lua file:
iap.buyItem1(callbackFunction)
-----------
Now after calling the function and trying to perform the purchase, I keep getting the “failed” transaction state, and the errorType “Unknown” and errorString “Cannot connect to iTunes Store”. I have no clue what can be causing this… I am on a jailbroken device but when sending the app in for review Apple also rejected the app for this very reason, you cannot complete the purchase…
I have tried deleting the app, reinstalling, recreating the iap product, changing the product id multiple times. It feels like I’ve tried just about anything and that there is something I’m missing…
Has anyone had the same issue and can offer some tips and advice? I’m just mainly out of ideas and can’t think of anything else to try anymore, been struggling with this all day now…
Thanks in advance, [import]uid: 14018 topic_id: 29098 reply_id: 329098[/import]