Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug iOS IAP receipt with two purchases

Discussion in 'Unity IAP' started by Volcore, Mar 1, 2022.

  1. Volcore

    Volcore

    Joined:
    Jan 14, 2020
    Posts:
    24
    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)

    Code (csharp):
    1.  
    2.     if len(response.Receipt.InApp) != 1 {
    3.         log.WithField("response", response).
    4.             WithField("bundleId", bundleId).
    5.             WithField("productId", productId).
    6.             WithField("plainReceipt", plainReceipt).
    7.             WithField("receipt", receipt).
    8.             Errorf("IAP receipt with multiple products!")
    9.     }
    10.  
    - 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
     

    Attached Files:

  2. Volcore

    Volcore

    Joined:
    Jan 14, 2020
    Posts:
    24
    Some more details from the server logs:
    - The error:
    upload_2022-3-1_12-59-23.png

    upload_2022-3-1_13-0-0.png

    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.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446