your code works for me! we will be able to figure it out:)
first make sure you have this in the top line of your code
io.output():setvbuf('no')
then view all your output in xcode/organizer/console
then make sure the store is unpacking properly
local unpackValidProducts = function()
for i=1, #validProducts do
print("validProducts = "..i..": ".. tostring(validProducts))
print("validProducts"..i..".title = " .. tostring(validProducts[i].title))
print("validProducts"..i..".description = " .. tostring(validProducts[i].description))
print("validProducts"..i..".price = " .. tostring(validProducts[i].price))
print("validProducts"..i..".productIdentifier = " .. tostring(validProducts[i].productIdentifier))
print("---------------------------")
end
end
then fix this code to match the listproducts
if (transaction.productIdentifier == "product1") then
beware if you test bought something 50 times, on store.restore the transaction callback will fire 50 times, which might crash your app
here is the buy button code
local function iap\_buyItem( item )
if store.canMakePurchases then
store.purchase( {item} )
else
native.showAlert("Store purchases are not available, please try again later", { "OK" } )
--F.func\_msg(" @ Store purchases are not available, please try again later", { "OK" } )
end
end--end function
--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
--testBuy // button
local function touch\_buy (event)
if event.phase=="ended" then
print('buy item')
iap\_buyItem (listOfProducts[1])
end--end phase
end
--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
--button for test buy
local btnRelease = display.newRect( 0, 0, 320, 90 )
btnRelease:setReferencePoint(display.TopLeftReferencePoint)
btnRelease.x = 0
btnRelease.y = 100
btnRelease:setFillColor(255,0,0)
btnRelease.alpha = 0.4
btnRelease.isVisible = true
btnRelease:addEventListener( "touch", touch\_buy )
and i start the store every time when the app loads with this
timer.performWithDelay(1000, startStore)
timer.performWithDelay(2000, setupMyStore)
timer.performWithDelay(3000, restorePurchases)
[import]uid: 89663 topic_id: 16336 reply_id: 109769[/import]