IAP 5.0.0pre3 BUG: Cancelling an IAP dialog resulted in no OnPurchaseFailed callback

My code presents a full screen cover when starting IAP and dismisses it at the end of the process. Not having this callback will cause the user’s screen and the underlying Async/Await I wrapped around the callbacks to lock up indefinitely.

It seems that in the Swift code of the IAP package, nothing is sent back to the C# side indicate that the purchase was cancelled.

    /**
     Purchase the `Product`. Once the StoreKit returns result of the purchase, the function checks whether the transaction is verified.
     If it is verified, this function returns the content to the user using transactionObserver and finish a transaction.
     If it isn't verified, this function rethrows the verification error.
     */
#if !os(visionOS)
    private func purchase(_ product: Product, options: Set<Product.PurchaseOption>) async throws -> PurchaseDetails? {
        let result = try await product.purchase(options: options)
        switch result {
        case .success(let verification):
            _ = try transactionObserver.checkVerified(verification)
            return verification.purchaseDetails()
        case .userCancelled:
            return nil
        case .pending:
            let jsonString = encodeToJSON( ["products": [product]])
            await storeKitCallback.callback(subject: "OnPurchaseDeferred", payload: jsonString, entitlementStatus: 0)
            return nil
        default:
            return nil
        }
    }
#endif

Another bug in 5.0.0pre1: In App Store Sandbox environment where the App Receipt is not immediately available without a manual refresh, FetchPurchases would not call either success callback with empty results or failure callback with an error, causing async process waiting on the callbacks to stall forever again.

I have reverted my integration back to using version 4.12 package.

Thank you for the reports!

For the missing callbacks, I have confirmed the issue and we will rapidly fix these and release a 5.0.0-pre.4 with them.
We will also review all the calls to make sure that there’s always a callback when expected.

For the App Receipt issue, StoreKit2 no longer uses the receipt. I have confirmed that this problem no longer exists in IAP 5.0.0-pre.3.

1 Like

Regarding App Receipts, certain Game Services like PlayFab still expects the unified App Receipt to redeem items. So please also consider providing reading Bundle.appStoreReceiptURL as before to maintain some compatibility, or that you guys should maintain v4 package for much longer.

We still return the unified app receipt via IOrderInfo.Receipt.

For Apple, this uses the Bundle.appStoreReceiptURL which should produce the same unified receipt as on v4.

We’re being careful to maintain all compatibility we previously had. If anything doesn’t work like it previously did, we will fix it.

1 Like