Please help! Totally stuck with IAP

Hello,

I am trying to get my IAPs working, but can’t figure it out for the life of me.

I press my button to buy, I get the product name, description and price.  When I hit buy it doesn’t add the coins purchased.

When I go to buy again it says I’ve bought the item but haven’t downloaded it.

Here is the code:

local function transactionCallback( event ) 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 transaction = event.transaction myDebugLabel.text="Transaction State: "..transaction.state print("This is the transaction State:"..transaction.state) if (transaction.state == "purchased") or (transaction.state == "restored") then if (transaction.productIdentifier == "android.test.purchased") then -- Transaction was successful; unlock/download content now print("I purchased!") storyboard.gameVars.totalCoins = storyboard.gameVars.totalCoins + 15000 myCoinsLabel.text= storyboard.gameVars.totalCoins print("Total Coins: "..storyboard.gameVars.totalCoins) loadsave.saveTable(storyboard.gameVars, "gameVars.json") myDebugLabel.text=transaction.state store.finishTransaction( transaction ) storyboard.hideOverlay() end if (transaction.productIdentifier == "30kcoins") then -- Transaction was successful; unlock/download content now print("I purchased!") storyboard.gameVars.totalCoins = storyboard.gameVars.totalCoins + 30000 myCoinsLabel.text= storyboard.gameVars.totalCoins print("Total Coins: "..storyboard.gameVars.totalCoins) loadsave.saveTable(storyboard.gameVars, "gameVars.json") myDebugLabel.text=transaction.state store.finishTransaction( transaction ) storyboard.hideOverlay() end elseif transaction.state == "restored" then -- Youll never reach this transaction state on Android. myDebugLabel.text=transaction.state elseif transaction.state == "refunded" then -- Android-only; user refunded their purchase local productId = transaction.productIdentifier myDebugLabel.text=transaction.state -- Restrict/remove content associated with above productId now elseif transaction.state == "cancelled" then -- Transaction was cancelled; tell you app to react accordingly here myDebugLabel.text=transaction.state elseif transaction.state == "failed" then -- Transaction failed; tell you app to react accordingly here myDebugLabel.text=transaction.state end -- The following must be called after transaction is complete. -- If your In-app product needs to download, do not call the following -- function until AFTER the download is complete: store.finishTransaction( transaction ) end

What are you getting in your logs?  Is “30kcoins” a valid product ID or is it more like “com.yourname.30kcoins”?

Rob,

Thanks for the reply.  It is in fact com.mydomain.30kcoins, I just shortened it for the post.  I am having a couple of problems.

My device (and xcode simulator) are stuck with the wrong apple id (It was a test account I created with a misspelled email address), now it continues to ask for the password to that account.  I’ve deleted the app from my phone, I have created a new build, I have restarted my phone, but I can’t clear that incomplete transaction out…

Until I can sort this out I wont be able to continue testing the original troublesome transaction.

On your device go to Settings, then App Store, and there you can sign out of that account.

What are you getting in your logs?  Is “30kcoins” a valid product ID or is it more like “com.yourname.30kcoins”?

Rob,

Thanks for the reply.  It is in fact com.mydomain.30kcoins, I just shortened it for the post.  I am having a couple of problems.

My device (and xcode simulator) are stuck with the wrong apple id (It was a test account I created with a misspelled email address), now it continues to ask for the password to that account.  I’ve deleted the app from my phone, I have created a new build, I have restarted my phone, but I can’t clear that incomplete transaction out…

Until I can sort this out I wont be able to continue testing the original troublesome transaction.

On your device go to Settings, then App Store, and there you can sign out of that account.