IAP not working correctly with Corona-2019.3528 and IOS 13

We managed to get through the review of apple with the game Draw Rider. For this, we used the stable version of CoronaSDK 2018.3326 and the latest xcode 11.2.1. The game does not pass the apple review if you build the game in Corona 2019.3559. It is necessary to solve this problem, in the stable version everything is fine. Thanks!

Same issue:

Build with corona 3562 and iOS SDK 13.3, 

Success to buy items but failed to verify the IAP when Run on a iOS 13.3 device.

My old version built with Corona 3468 and iOS SDK 12.1 works fine. But I can’t go back…

What should I do now? :frowning:

iOS 13 changed the IAP receipt format. We have a plugin in the Marketplace called Apple IAP or something similar that does proper receipt validation. 

Rob

So use require( “plugin.apple.iap” ) instead of require(“store”) would fix the issue?

Although it is not mentioned in the documentation, vlads mentions about a quarter of the way down this thread that you need to include the following in your build.settings file:

settings = { plugins = { ["plugin.apple.iap"] = { publisherId = "com.coronalabs" }, ["plugin.apple.iap.helper"] = { publisherId = "com.coronalabs" }, } }

Then, in your main code, the store call looks like this:

local store = require "plugin.apple.iap"

Also, if you’re using IAP Badger, you can download the library from github, modify line 1666 to require “plugin.apple.iap” instead of “store”, include it with the rest of your project files and then call your modified version of IAP Badger instead of the IAP Badger plugin.

 

In the Corona assembly 2019.3476 everything works and passes the review of the Apple. Why can’t you do the same in the new version? Why do I need some kind of plugins, etc.

The reason 3476 works is that it’s based on iOS 12. In iOS 12, the receipt format still worked with the older store.* When Apple moved to iOS 13, they changed the receipt format and the old store.* no longer works with it. store.* works with everything else. We produced a plugin that works with iOS 13. store.* should be a plugin and for Android and Amazon, IAP is a plugin.

The Apple IAP plugin was designed to be a plugin so we can updated it and manage it without having to update the core. Now all of the various provider’s store IAP’s are on the same method (plugins).

Rob

use the IAP plugin, but crash happened:

“attempt to index filed transaction (a nil value)”

@mlhdyx, we need more information than that to help.

Are you putting in any print statements? 

Do you know where that error is coming from (which API call)?

Can you share the code for your IAP listener function? Where you’re making your various API calls?

Rob

"

function transactionCallback( event )

    if ( event.name == “init” ) then

        if not ( event.transaction.isError ) then   – crash happened here

"

"function MobileStore:InitStore()

     if ( system.getInfo( “platformName” ) == “iPhone OS” ) then

        self.store = require( “plugin.apple.iap” )

        currentProductList = appleProductList

        LOG(“init for apple store”)

        self.store.init(transactionCallback)   – here set the callback

"

You should use a table printing function like print(json.prettify(event)) to dump the event table and see what’s being returned.

Rob

guys, the new plugin-iap-apple is NOT a drop-in replacement for old store library. Thats why your old store transaction callback functions fail.

if event.name == “init”, there is no event.transaction. Because of this your event.transaction.isError fails.

Also event.transaction.receipt does not contain full receipt. You should call store.receiptBase64Data() to get the receipt. Then use something like https://www.revenuecat.com/apple-receipt-checker to check the validity of it if you care.

Corona’s documentation about apple IAPs is seriously broken now. 

Thank you for your tips, Deniz.

Never Mind, we’ve rolled back the system to iOS 12.1 to build the APP, the old APIs works well.

Hope Corona Team would fix this issue in the future release.

Like  :slight_smile:

I recommend everyone who is using new apple-iap plugin to test their transactionCallback functions extensively for all possible event.name, event.transaction.state combinations. This function does not behave like good old store callback function we used to trust. For example; there is a new event.transaction.state: “restoreCompleted”. In this case you have a transaction object, which is not a user-data?!. It’s a regular lua table. So if you are finishing transactions by calling store.finishTransaction(event.transaction), your code going to fail. This is just one case showing inconsistent callback interface design. 

Either those new interfaces should be changed to match old practices or documented thoroughly. 

@Rob,

This problem seems to be the one I’ve been trying to solve for the past month. A growing number of my users have reported failed purchase and the only thing I could find is this truncated receipt that apparently started showing with iOS13.

I’ve tried working with the new plugin for apple store but there is no documentation on how to use it. specifically how to use the new methods around receipt validation. There should be some best practice on how to use it.

In addition, how should we tackle users with iOS12 and older when using the new plug-in 

We are looking into the issues.

Rob

Hey guys. Next daily build should not have receipts truncated, both in new plugin and core. New plugin is up now, but it would take couple hours for a new build to build. Also, added empty “transaction” table to IAP plugin.

Btw, about receipt validation. You can validate receipts locally without any 3rd party services using new plugin. Check decrypted receipt. It is checked locally on the device, and contains list of all purchases and subscriptions on the device, signed by Apple and verified with public key cryptography. I would suggest experimenting a little with it, and if you could share your experience, it would be great. Like, try to make some purchases and do

require("json").prettify(store.receiptDecrypted())

Cheers!

Vlad.

Vlad,

Great news- thank you.

Do I understand you correctly that it’s most likely safe to just continue using the built-in Apple IAP?

Thanks again!

OK. Here is the differene:

  1. Plugin: can be updated separately from the core. So plugin would have proper receipts with any version of Core. Also, plugin has some additional functionality, like using modern API to read receipt, as well as decode it, so you can locally verify purchase using public key cryptography, as well as read contents of receipts, which contains information about subscriptions and all purchases client made. Very useful.

  2. Core: apps are slightly smaller, because you don’t link the plugin. Also, what you get depends on version of the Corona you are using. Like, to get proper receipts in iOS13 SDK you would have to use 2019.3564+ or something.

They have pretty much identical code. Except that Core doesn’t have empty init event… It is really added only for compatibility with Android.