In-App Purchase implementation and testing

Hi All,

Please can anyone help with this problem I’m currently having with regards to testing new items purchases, when testing my app i get the iTunes Store login popup, but after entering my tester user ID and its password, I get a second login prompt (coming from the iTunes Store) and after entering both again the transaction fails and my error event callback event returns  " Cannot connect to iTunes Store" error. My testing account is included in my sandbox testing list of my iTunes Connect account and as far as I can tell I’ve think everything has been set up fine.

Here what is requested and then the returned information when a failed transaction happens:

Requested when transaction.state == “failed”:

print( event.transaction.errorType );        print( event.transaction.errorString );

Print out via Xcode:

Aug 19 02:19:53 Pythagoras-2 Water Jetters[370] \<Warning\>: unknown Aug 19 02:19:53 Pythagoras-2 Water Jetters[370] \<Warning\>: Cannot connect to iTunes Store

Here the transaction process in it entire:

function attributes.appleTransactionListener( event )&nbsp; &nbsp; local transaction = event.transaction &nbsp; &nbsp; if ( transaction.state == "purchased" ) then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--handle a successful transaction here &nbsp; &nbsp; &nbsp; &nbsp; print( "productIdentifier", transaction.productIdentifier ) &nbsp; &nbsp; &nbsp; &nbsp; print( "receipt", transaction.receipt ) &nbsp; &nbsp; &nbsp; &nbsp; print( "signature:", transaction.signature ) &nbsp; &nbsp; &nbsp; &nbsp; print( "transactionIdentifier", transaction.identifier ) &nbsp; &nbsp; &nbsp; &nbsp; print( "date", transaction.date ); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(attributes.index == 1)then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local gold tonumber(\_G.uiStats.gold); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gold = gold + 20000; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \_G.uiStats.gold = gold; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ragdogLib.setSaveValue("gold", \_G.uiStats.gold, true); &nbsp; &nbsp; &nbsp; &nbsp; elseif(attributes.index == 2)then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local gold tonumber(\_G.uiStats.gold); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gold = gold + 40000; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \_G.uiStats.gold = gold; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ragdogLib.setSaveValue("gold", \_G.uiStats.gold, true); &nbsp; &nbsp; &nbsp; &nbsp; elseif(attributes.index == 3)then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local gold tonumber(\_G.uiStats.gold); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gold = gold + 100000; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \_G.uiStats.gold = gold; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ragdogLib.setSaveValue("gold", \_G.uiStats.gold, true); &nbsp; &nbsp; &nbsp; &nbsp; elseif(attributes.index == 4)then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local gems tonumber(\_G.uiStats.Gems); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gems = gems + 25; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \_G.uiStats.Gems = gems; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ragdogLib.setSaveValue("gems", \_G.uiStats.Gems, true); &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; &nbsp; &nbsp; -- need to update on the screen gold in store afterexiting transactions &nbsp; &nbsp; &nbsp; &nbsp; native.showAlert( "Purchase", "Purchase was a success.", { "OK" } ); &nbsp; &nbsp; elseif ( transaction.state == "cancelled" ) then &nbsp; &nbsp; &nbsp; &nbsp; --handle a cancelled transaction here &nbsp; &nbsp; &nbsp; &nbsp; native.showAlert( "Purchase", "Purchase was canceled.", { "OK" } ); &nbsp; &nbsp; elseif ( transaction.state == "failed" ) then &nbsp; &nbsp; &nbsp; &nbsp; --handle a failed transaction here &nbsp; &nbsp; &nbsp; &nbsp; print( event.transaction.errorType ); &nbsp; &nbsp; &nbsp; &nbsp; print( event.transaction.errorString );&nbsp; &nbsp; &nbsp; &nbsp; native.showAlert( "Purchase", "Purchase failed.", { "OK" } ); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; store.finishTransaction( event.transaction ); &nbsp; &nbsp; &nbsp; &nbsp; end

attributes.purchaseRequest = function(itemNum) &nbsp; &nbsp; attributes.index = itemNum; &nbsp; &nbsp; if(attributes.devicePlatform == "Android")then &nbsp; &nbsp; &nbsp; &nbsp; store.purchase(attributes.productList[attributes.index]) -- item to purchase &nbsp; &nbsp; elseif(attributes.devicePlatform == "iPhone OS")then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; store.purchase({attributes.productList[attributes.index]}); --array of items &nbsp; &nbsp; end end

I’m at a complete loss with this and could do with any ones help thats been through this or has an idea as to what might be happening?

Please don’t hesitate to ask if you need more info.

Many thanks

Kind Regards

Liam

Do a Google search for “corona itunes Cannot connect to iTunes Store” (without the quotes). It will bring up several forum threads about this which may have solutions in addition it will bring up some Apple and Stack Overflow sites where others are experiencing this outside of Corona and you can see the solutions they have come up with.

This isn’t likely a Corona issue but more of a store setup/sandboxing issue. These should guide you through solving this.

Rob

Hi Rob,

Thank you for your email.

Rob I had a look and I think I may have located the problem or at least the current problem.

Please could you have a quick look at the code I’ve inputted for the product item list when you have a moment and tell me if it look like I’ve declared correctly, I can guarantee everything correct up to the actual item i.e. gem1234 or gold5678 etc, however do i need to add the Consumable and the pat tier on the end?

local appleProductList = {&nbsp; "com.zombieboffinstudioltd.gem1234.ConsumableTier1", &nbsp; "com.zombieboffinstudioltd.gold5678.ConsumableTier2", &nbsp; "com.zombieboffinstudioltd.gold1234.ConsumableTier3", &nbsp; "com.zombieboffinstudioltd.gold9101112.ConsumableTier1", }

I’ve used apple configurator 2 and was able to get the following from it that makes me think the way I’ve declared the above is slightly off.

"This item cannot be found." UserInfo={NSLocalizedDescription=This item cannot be found.} for payment: \<MicroPayment: \*\*\*\*\*\*\*\*\*\*\*\> (entity: MicroPayment; id: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\<x-coredata://\*\*\*\*\*\*\*\*-\*\*\*\*-\*\*\*\*-\*ECD-\*\*\*\*\*\*\*\*\*\*\*\*/MicroPayment/p81\> ; data: \<fault\>)Aug 20 02:23:34 Pythagoras-2 Water Jetters[232] \<Warning\>: unknown Aug 20 02:23:34 Pythagoras-2 Water Jetters[232] \<Warning\>: Cannot connect to iTunes Store

All in app items have been approved and there no error interns of the item name or path.

Many thanks

Kind Regards

Liam

On the iTunes Connect portal you would have typed in the ID’s of your items.

I guess I’ll have to answer the question with a question:  Did you physically type in: com.zombieboffinstudioltd.gem1234.ConsumableTier1 or did you physically type in: com.zombieboffinstudioltd.gem1234?

It seems unusual that you would have typed in ConsumableTier1 as part of creating the unique ID for the item. So when  you created the objects, you use the exact think you typed into the fields when setting up the ID’s. You don’t add or subtract any thing.

Rob

Hi Rob,

Thank you for your msg, sorry for the late reply. All sorted thank you Rob, your a star thank you. It was indeed me foolishly adding the consumable bit on the end that wasn’t needed just the items name as declared in itune connect. Thank you for your time and help with that Rob :+1:

Kind Regards

Liam

Do a Google search for “corona itunes Cannot connect to iTunes Store” (without the quotes). It will bring up several forum threads about this which may have solutions in addition it will bring up some Apple and Stack Overflow sites where others are experiencing this outside of Corona and you can see the solutions they have come up with.

This isn’t likely a Corona issue but more of a store setup/sandboxing issue. These should guide you through solving this.

Rob

Hi Rob,

Thank you for your email.

Rob I had a look and I think I may have located the problem or at least the current problem.

Please could you have a quick look at the code I’ve inputted for the product item list when you have a moment and tell me if it look like I’ve declared correctly, I can guarantee everything correct up to the actual item i.e. gem1234 or gold5678 etc, however do i need to add the Consumable and the pat tier on the end?

local appleProductList = {&nbsp; "com.zombieboffinstudioltd.gem1234.ConsumableTier1", &nbsp; "com.zombieboffinstudioltd.gold5678.ConsumableTier2", &nbsp; "com.zombieboffinstudioltd.gold1234.ConsumableTier3", &nbsp; "com.zombieboffinstudioltd.gold9101112.ConsumableTier1", }

I’ve used apple configurator 2 and was able to get the following from it that makes me think the way I’ve declared the above is slightly off.

"This item cannot be found." UserInfo={NSLocalizedDescription=This item cannot be found.} for payment: \<MicroPayment: \*\*\*\*\*\*\*\*\*\*\*\> (entity: MicroPayment; id: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\<x-coredata://\*\*\*\*\*\*\*\*-\*\*\*\*-\*\*\*\*-\*ECD-\*\*\*\*\*\*\*\*\*\*\*\*/MicroPayment/p81\> ; data: \<fault\>)Aug 20 02:23:34 Pythagoras-2 Water Jetters[232] \<Warning\>: unknown Aug 20 02:23:34 Pythagoras-2 Water Jetters[232] \<Warning\>: Cannot connect to iTunes Store

All in app items have been approved and there no error interns of the item name or path.

Many thanks

Kind Regards

Liam

On the iTunes Connect portal you would have typed in the ID’s of your items.

I guess I’ll have to answer the question with a question:  Did you physically type in: com.zombieboffinstudioltd.gem1234.ConsumableTier1 or did you physically type in: com.zombieboffinstudioltd.gem1234?

It seems unusual that you would have typed in ConsumableTier1 as part of creating the unique ID for the item. So when  you created the objects, you use the exact think you typed into the fields when setting up the ID’s. You don’t add or subtract any thing.

Rob

Hi Rob,

Thank you for your msg, sorry for the late reply. All sorted thank you Rob, your a star thank you. It was indeed me foolishly adding the consumable bit on the end that wasn’t needed just the items name as declared in itune connect. Thank you for your time and help with that Rob :+1:

Kind Regards

Liam