IAP Woes (iOS)

Hey… After a whole day working with IAP, I’m going to have to throw in the towel. 

There’s 3 resources I’ve been working from; The official Corona tutorial, some old stuff from Github and a stripped down approach that someone posted on here a while back.

This is what I’ve done so far

Created products in iTunes connect (to the point where it’s asking for an image - as advised by Apple), I have not submitted them for review, in fact, I don’t think it works like that anymore, Apple state that you only add images after “you’re done testing”.

Created all certs and profiles (associated with the correct ID)

Created a test user account (in fact, a couple now)

I’ve absolutely scoured at the various code snippets, trying to make head or tail of it, and the existing resources are too complex. The sample code in Corona is way OTT, the official tutorial is great, but makes calls to external modules using JSON, and basically just clouds over the basic requirement (for me anyway)… The other one I found uses an external UI module which populates dynamic buttons with a product list.

In order for me to learn about what’s actually going, it’s difficult to strip out all of the ‘flowery stuff’. I appreciate that the guys who wrote it are smart. I think sometimes they forget that some of us aren’t quite at their standard.

Anyway, I found a snippet on a forum post, that I liked the look of, as it seemed to just deal with initialising the store and purchasing a product.

All I’ve done to it, is strip it back a little more, and include in a storyboard scene.

Currently there are two widgets and that’s it, one for purchase and one for restore… I’ve tested it on my device and the restore button prompts a log in. So I log in (with my test account), then it continuously keeps asking me to log in even though if I check iPhone settings, it already has me as ‘logged in’.

The purchase button does nothing at all.

I’ve literally spent 18 hours trying to get something to work before coming here, I’m a big believer in trying to figure it out yourself, but I’m totally stumped.

I’ve included the code below, to see if one of you (smarter) guys can tell me where I’m going wrong.

Thanks

local storyboard = require( "storyboard" ) local store = require("store") local widget = require("widget") local scene = storyboard.newScene() local btnPurchase local btnRestore local transactionCallback = function (event) --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 productID = event.transaction.productIdentifier; if event.transaction.state == "purchased" then print("Product Purchased: ", productID) local alert = native.showAlert( "Purchased",{ "OK" }) elseif event.transaction.state == "restored" then print("Product Restored", productID) local alert = native.showAlert( "Restored",{ "OK" }) elseif event.transaction.state == "refunded" then print("Product Refunded") local alert = native.showAlert( "Refunded",{ "OK" }) elseif event.transaction.state == "cancelled" then print("Transaction cancelled") local alert = native.showAlert( "Cancelled",{ "OK" }) elseif event.transaction.state == "failed" then print("Transaction Failed") local alert = native.showAlert( "Failed",{ "OK" }) else print("Some unknown event occured.") local alert = native.showAlert( "Gone tits up",{ "OK" }) end store.finishTransaction( event.transaction ) end store.init("apple", transactionCallback) local purchaseItem = function (event) store.purchase( {"com.appey.geekgamesounds.100coins"}) end local restorePurchases = function (event) store.restore() end function scene:createScene( event ) local group = self.view btnPurchase = widget.newButton{ defaultFile = "bbar.png", overFile = "bbar.png", label = "Purchase", width=346, height=107, onRelease = purchaseItem } btnPurchase.x = 320 btnPurchase.y = 650 btnRestore = widget.newButton{ defaultFile = "bbar.png", overFile = "bbar.png", label = "Restore", width=346, height=107, onRelease = restorePurchases } btnRestore.x = 320 btnRestore.y = 950 group:insert( btnPurchase ) group:insert( btnRestore ) end function scene:enterScene( event ) local group = self.view end function scene:exitScene( event ) local group = self.view end function scene:destroyScene( event ) local group = self.view end ----------------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION ----------------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) ----------------------------------------------------------------------------------------- return scene

Hmm i didn’t think starter’s had access to IAP it’s basic up - or is your “starter” moniker wrong?

if it’s not wrong then that could be the issue?

T.

I posted a question relating to that yesterday. Apparently, I should still be able to test in sandbox environment (have access to the “store library”), it’s just uploading to the app-store that I’m unable to do. Please someone correct me if I’m wrong, it would explain a lot.

In fact, I’d like to bump my own thread, I’ve been enjoying getting my hands dirty with Corona, over the last few weeks, and getting this working is the only thing standing between me and a Pro subscription.

Are you using a test account you created in itunes connect to make the purchase attempt?  Also make sure you created the product with the correct settings in itunes.  The Product ID field has to match what you are purchasing (not the reference name which was a problem I had)

Hi yes, I’ve used a couple of test accounts and configured the products properly (I think)… My reference name and product ID are the same anyway, ie: ‘100coins’, so my product call looks like ‘com.company.appname.100coins’.

If you’ve got a really simple script that is definitely working in your app, I’d sure like to have a peak. The problem I’ve got, is not knowing which part of my setup needs looking at. All of the available sample codes/tutorials are too overcrowded with other functions, for me to be able to properly absorb how it all works… I’ve not been able to get any of them to work with my bundle ID’s, and they all need a small degree of tweaking to run… I’ve even tried just running the Corona sample code on my device and it just shows the ‘In app purchasing not supported’ message… I have a feeling this should be really easy, but for some reason, it’s causing me all sorts of problems.

The only inconsistency, I can find in the tutorials, is one that states… You must have ‘submitted’ your products before you can test them (I think it was Rob Miracle’s tutorial)… But this is a bit of a catch 22, as you need to upload images to submit them for review/approval, and Apple says your product-status needs to be ‘awaiting screenshot’ in order or you to test purchases. Total nightmare…

I wish there was a simple fully tested and proved IAP sample, so I could start to eliminate the issues.

I’m using an ad-hoc distribution profile (not development)… I can’t help but think there might be something wrong with my certificates, as Apple is insistent on having it’s Developers running around in circles, just to fart.

The reference id setup in itunesconnect is 100coins or com.company.appname.100coins? You should also ensure your app is setup to allow iap in your ios appid (in developer.apple.com)

Yep, well, my bundle with IAP looks like this; ‘com.appey.geekgamesounds.100coins’. Yes, my app ID has the green light next to In App Purchasing, under ‘Application Services’.

I’ve not uploaded a binary yet, I’m not sure if that’s important, but obviously my binary isn’t ready, so it would seem a bit stupid if that was the rule.

I also haven’t ticked the IAP boxes that associate the IAP’s with the app under the app summary page, but those ‘tick boxes’ don’t appear until you’ve uploaded screenshots for IAP, so again, it’s hard to see how that would be a problem.

As a matter of interest, my app status, is ‘Prepare for upload’… I’ve read on a few other threads that this might be an issue, but again, it seems crazy, surely I should only need to create products for my bundle and that should be it, right?

Don’t know why this text has a grey background, sorry.

You definitely don’t have to have a binary uploaded, I don’t have one uploaded yet.  The issues I had were that my Product ID in itunes didn’t match what was being purchased in the app.  I did go through the process of getting setup with bank account information, etc.  Not sure if you did those steps or not.  The IAP does not have a screenshot so that’s not necessary to get going (and I was using corona starter when I worked on iap).

Code wise this is all I have:

local store=require(“store”)

local function storeTransaction( event )

    print("!!!")

    print(“STORE TRANSACTION”)

    local transaction = event.transaction

    print(transaction.state)

    print(event.name)

    print(tostring(event.errorType))

    print(tostring(event.errorString))

end

function makePurchase()

   store.purchase({“com.company.upgrade”})

end

store.init( “apple”, storeTransaction )

Thank you very much, I’ll give that a try, with a new ID. No doubt I’ll be back :slight_smile:

Still no joy unfortunately.

I’ve looked at console logs, and it seems I’m just jot connecting to the app store… I ran the Corona sample code too (just with different ID’s).

I’m going to try on another couple of devices to see how I get on, including doing a full factory reset on my main testing iPhone.

Please keep following, I’ll write a comprehensive post-mortem, when I’ve finally got it sorted, so nobody else has to endure this nightmare.

Hmm i didn’t think starter’s had access to IAP it’s basic up - or is your “starter” moniker wrong?

if it’s not wrong then that could be the issue?

T.

I posted a question relating to that yesterday. Apparently, I should still be able to test in sandbox environment (have access to the “store library”), it’s just uploading to the app-store that I’m unable to do. Please someone correct me if I’m wrong, it would explain a lot.

In fact, I’d like to bump my own thread, I’ve been enjoying getting my hands dirty with Corona, over the last few weeks, and getting this working is the only thing standing between me and a Pro subscription.

Are you using a test account you created in itunes connect to make the purchase attempt?  Also make sure you created the product with the correct settings in itunes.  The Product ID field has to match what you are purchasing (not the reference name which was a problem I had)

Hi yes, I’ve used a couple of test accounts and configured the products properly (I think)… My reference name and product ID are the same anyway, ie: ‘100coins’, so my product call looks like ‘com.company.appname.100coins’.

If you’ve got a really simple script that is definitely working in your app, I’d sure like to have a peak. The problem I’ve got, is not knowing which part of my setup needs looking at. All of the available sample codes/tutorials are too overcrowded with other functions, for me to be able to properly absorb how it all works… I’ve not been able to get any of them to work with my bundle ID’s, and they all need a small degree of tweaking to run… I’ve even tried just running the Corona sample code on my device and it just shows the ‘In app purchasing not supported’ message… I have a feeling this should be really easy, but for some reason, it’s causing me all sorts of problems.

The only inconsistency, I can find in the tutorials, is one that states… You must have ‘submitted’ your products before you can test them (I think it was Rob Miracle’s tutorial)… But this is a bit of a catch 22, as you need to upload images to submit them for review/approval, and Apple says your product-status needs to be ‘awaiting screenshot’ in order or you to test purchases. Total nightmare…

I wish there was a simple fully tested and proved IAP sample, so I could start to eliminate the issues.

I’m using an ad-hoc distribution profile (not development)… I can’t help but think there might be something wrong with my certificates, as Apple is insistent on having it’s Developers running around in circles, just to fart.

The reference id setup in itunesconnect is 100coins or com.company.appname.100coins? You should also ensure your app is setup to allow iap in your ios appid (in developer.apple.com)

Yep, well, my bundle with IAP looks like this; ‘com.appey.geekgamesounds.100coins’. Yes, my app ID has the green light next to In App Purchasing, under ‘Application Services’.

I’ve not uploaded a binary yet, I’m not sure if that’s important, but obviously my binary isn’t ready, so it would seem a bit stupid if that was the rule.

I also haven’t ticked the IAP boxes that associate the IAP’s with the app under the app summary page, but those ‘tick boxes’ don’t appear until you’ve uploaded screenshots for IAP, so again, it’s hard to see how that would be a problem.

As a matter of interest, my app status, is ‘Prepare for upload’… I’ve read on a few other threads that this might be an issue, but again, it seems crazy, surely I should only need to create products for my bundle and that should be it, right?

Don’t know why this text has a grey background, sorry.

You definitely don’t have to have a binary uploaded, I don’t have one uploaded yet.  The issues I had were that my Product ID in itunes didn’t match what was being purchased in the app.  I did go through the process of getting setup with bank account information, etc.  Not sure if you did those steps or not.  The IAP does not have a screenshot so that’s not necessary to get going (and I was using corona starter when I worked on iap).

Code wise this is all I have:

local store=require(“store”)

local function storeTransaction( event )

    print("!!!")

    print(“STORE TRANSACTION”)

    local transaction = event.transaction

    print(transaction.state)

    print(event.name)

    print(tostring(event.errorType))

    print(tostring(event.errorString))

end

function makePurchase()

   store.purchase({“com.company.upgrade”})

end

store.init( “apple”, storeTransaction )

Thank you very much, I’ll give that a try, with a new ID. No doubt I’ll be back :slight_smile: