Ok so here we go. I really need help here. I have an awesome, amazing update for my app, and the only thing holding me back is the in-app purchase, it didnt have one before, now I am adding one. I sent 16 hours straight trying to get it to work and nothing. So, let me preface by saying I am using a Jailbroken iPhone 3g. I dont want it jailbroken but thats the way I got it, and I am just kind of scared to restore it to factory default. I am going to post the relevant code and then the problems:
local ui = require(“ui”)
local store = require(“store”)
local validProducts, invalidProducts = {}, {}
local listOfProducts =
{
“com.apphappystudios.glowtunes.soundpack1”,
}
restoreButton = ui.newButton
{
defaultSrc = “buttonRestore.png”,
defaultX = 80,
defaultY = 30,
overSrc = “buttonRestoreDown.png”,
onRelease = restoreSounds,
overX = 80,
overY = 30,
text = “”,
font = “Helvetica”,
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
restoreButton.xOrigin = 330; restoreButton.yOrigin = 275
buyButton = ui.newButton
{
defaultSrc = “buttonBuy.png”,
defaultX = 80,
defaultY = 30,
overSrc = “buttonBuyDown.png”,
onRelease = buySounds,
overX = 80,
overY = 30,
text = “”,
font = “Helvetica”,
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
buyButton.xOrigin = 240; buyButton.yOrigin = 275
function buySounds(event)
print(“working”)
local buyThis = function ( product )
if store.canMakePurchases then
store.purchase( {product} )
else
native.showAlert(“Store purchases are not available, please try again later”, { “OK” } )
end
end
– Enter your product id here
buyThis (“com.apphappystudios.glowtunes.soundpack1”)
end
function restoreSounds(event)
local restoreThis = function ( product )
if store.canMakePurchases then
store.restore( {product} )
else
native.showAlert(“Store purchases are not available, please try again later”, { “OK” } )
end
end
– Enter your product id here
restoreThis (“com.apphappystudios.glowtunes.soundpack1”)
end
function unpackValidProducts()
print (“Loading product list”)
if not validProducts then
native.showAlert( “In-App features not available”, “initStore() failed”, { “OK” } )
else
for i=1, #invalidProducts do
native.showAlert( “Item " … invalidProducts[i] … " is invalid.”,{ “OK” } )
end
end
end
function loadProductsCallback( event )
validProducts = event.products
invalidProducts = event.invalidProducts
unpackValidProducts ()
end
function savePurchase(extraSounds)
– Here is where I unlock the things purchased
end
function transactionCallback( event )
if event.transaction.state == “purchased” then
savePurchase(“com.apphappystudios.glowtunes.soundpack1”)
elseif event.transcation.state == “restored” then
savePurchase(“com.apphappystudios.glowtunes.soundpack1”)
elseif event.transaction.state == “cancelled” then
elseif event.transaction.state == “failed” then
infoString = "Transaction failed, type: ", event.transaction.errorType, event.transaction.errorString
local alert = native.showAlert("Failed ", infoString,{ “OK” })
else
infoString = “Unknown event”
local alert = native.showAlert("Unknown ", infoString,{ “OK” })
end
store.finishTransaction( event.transaction )
end
function setupMyStore (event)
store.loadProducts( listOfProducts, loadProductsCallback )
end
store.init ( transactionCallback )
print (“After init”)
I used the code from this thread:
http://developer.anscamobile.com/forum/2011/10/13/app-purchases-help-needed
Problem #1- When I press the buy button in the simulator, it prints “working” which suggests that the function is getting called. But when I press the buy button on device, nothing happens.
Problem #2- When I press the restore button on device, it prompts me for my username and password(which makes it wierd that the buy button doesn’t do that since it is pretty much the same code) When I enter my test user account name and password, it shows a popup:
“This Apple ID has not yet ben used before in the iTunes Store. Tap Review to sign in, then review your account information. [Cancel] [Rewiew]”
Which leads down a long road going nowhere. i am pretty sure that it shouldn’t appear.
Notes: - These are some common solutions/pitfalls I tried with no luck.
- I created a completely arbitrary test user using nonsense name, email, and password. (multiple time)
- I signed out of my iTunes account in my phone’s settings before launching the app
- I tried restarting my phone, no luck.
- I completely deleted the app from my phone before re-installing it, no luck.
- I added the in-app purchase to the application in iTunes connect, and submitted the new binary, then rejected the binary (as I have read you are suppose to do)
I am at my witt’s end here. Please someone help me. Any assistance will do. As of recent someone tried to create a copycat version of my app, and I got it pulled from the App Store. But this has me wanting to get the best version possible on the app store before more imitations pop up. This app had a coupe glaring issues I fixed with this update, and I added tons of cool stuff. I need to get this in-app purchase working. Post here, call me (305-484-8311), email me: chris.r.martone@gmail.com, I am desperate.
P.S. I am sorry I dont know how to add my code in that special way people do.
[import]uid: 46742 topic_id: 16405 reply_id: 316405[/import]