iOS IAP receipt with two purchases

Hi,

After running our code for over two years in production, I’ve just encountered an issue where one of our safeguard tripwires triggered. A receipt contained not one but two (different) products.

This doesn’t seem to be supported or “make sense” with the Unity IAP system, as a transaction has a single product.

Some details:

  • We are using com.unity.purchasing 4.1.3
  • We are using Unity 2021.2.12f1
  • This happened on Apple Testflight sandbox
  • I have not seen this happen “in the wild” on production
  • The error was noticed in our server-side validation
  • We send the raw transaction details received from Unity IAP to the server (product is a
    UnityEngine.Purchasing.Product)
  • Our server uses the “https://buy.itunes.apple.com/verifyReceipt” endpoint to validate the purchase
  • Our code triggered on this (the count was 2)
    if len(response.Receipt.InApp) != 1 {
        log.WithField("response", response).
            WithField("bundleId", bundleId).
            WithField("productId", productId).
            WithField("plainReceipt", plainReceipt).
            WithField("receipt", receipt).
            Errorf("IAP receipt with multiple products!")
    }
  • The purchased product was a “com.arvogames.gs.chapter2pack”. The receipt contained both that and “com.arvogames.gs.dailypack1” (which I do not remember testing and not receiving, but which might have happened a while ago).
  • This kept happening as I purchased more IAPs, but it would always return just the most recent 2 (not all unacknowledged purchases)

Is this a known issue? Are we expected to handle multiple different products in a single transaction (even though Unity IAP system only communicates a single product)? This would provide several logistical challenges, as transaction metadata from Unity IAPs and our own system is missing on the secondary purchase.

Thanks for looking into this,
Volke


Some more details from the server logs:

It seems like the code is always including an older purchase (from 2/25) with a new purchase that I’m making. As we’re not modifying the receipt in anyway between receiving it from Unity and passing it to Apple, this is probably an issue in the Unity IAP system. Luckily, it hasn’t happened on production yet.

@Volcore Apple includes all purchased products in the receipt. We are just passing along the receipt as provided by Apple, we are a pass through service for the Apple StoreKit API. Multiple transaction in 1 receipt … | Apple Developer Forums