I have been trying for almost 2 months to implement Inapp Purchase in my game. I still can’t get it to work. I try the corona labs sample code I couldn’t get it to work. It just seem very complex to me. I tried the code below, I prompted me to input my account and password. I created a test Sandbox account in itunesconnect and when I tried to signed in nothing happen. If anyone can help me I would really appreciate it. Better yet, does any one has a very simple Inapp purchase code that works that they can share with me. All I want to do is remove ads after purchase. Thanks you so much!!
function transactionCallback( event ) --- this is call after the purchase is made -- Log transaction info. print("transactionCallback: Received event " .. tostring(event.name)) print("state: " .. tostring(event.transaction.state)) print("errorType: " .. tostring(event.transaction.errorType)) print("errorString: " .. tostring(event.transaction.errorString)) local productID= event.transaction.productIdentifier; if event.transaction.state == "purchased" then print("Product Purchased: ", productID) mainscore=1 -- THIS CONTROL WHEN THE ADS SHOW saveFile("mainscore1.txt", mainscore) print ("mainscore from moregame", mainscore) btnPurchase.alpha=0 --make purchase button disappear elseif event.transaction.state == "restored" then print("Product Restored", productID) elseif event.transaction.state == "refunded" then print("Product Refunded") elseif event.transaction.state == "cancelled" then print("Transaction cancelled") elseif event.transaction.state == "failed" then print("Transaction Failed") else print("Some unknown event occured. This should never happen.") end -- Tell the store we are done with the transaction. -- If you are providing downloadable content, do not call this until -- the download has completed. store.finishTransaction( event.transaction ) end --initialize your tranaction callback with appropriate store(google or apple) if store.availableStores.apple then store.init("apple", transactionCallback) print("Using Apple's in-app purchase system.") elseif store.availableStores.google then store.init("google", transactionCallback) print("Using Google's Android In-App Billing system.") else end local function purchaseItem(event) --make sure you add { } around your product id as you need to send a table value... not a string! store.purchase( {"com.mmp.xxxx"}) end local function restorePurchases(event) --no need to sepcify a product store.restore() end --create a button that purchases an item local btnPurchase= widget.newButton { onRelease = purchaseItem, label = "Purchase" } ---Enos Code -- Make button disappear after purchase: if mainscore==1 then btnPurchase.alpha=0 --make purchase button disappear end