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

Consumable product receipt validation

Discussion in 'Unity IAP' started by andrew-alpha, Feb 22, 2021.

  1. andrew-alpha

    andrew-alpha

    Joined:
    Nov 13, 2019
    Posts:
    2
    I'm currently using Unity 2019.4.19f1, with Unity IAP package version 2.2.2 and service version 2.2.7.

    The documentation for the UnityEngine.Purchasing.Product states that "Consumable receipts are not saved between app restarts."
    I'm curious how this interacts with server-side receipt validation if the app crashes or the device dies during the process.

    To use server-side receipt validation, we need to return PurchaseProcessingResult.Pending from our IStoreListener implementing class' ProcessPurchase function. We then send the receipt data to our server, which then does validation and then returns. If everything went well, we end up calling ConfirmPendingPurchase on the product.

    If the app crashes or the phone dies before we can call ConfirmPendingPurchase though, it appears as though we no longer have access to the receipt data, so there would be no way to validate anything.

    Basically: if we have a pending purchase (so we haven't called ConfirmPendingPurchase with it yet) and the app is restarted, how can we ever confirm it? Am I understanding the documentation correctly that the transactionID and receipt are only available in that first session and are never available after, even if the purchase was not confirmed?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @andrew-alpha For all products still in Pending, then ProcessPurchase is called on app restart for each of these products. Use Debug.Log to confirm.
     
  3. andrew-alpha

    andrew-alpha

    Joined:
    Nov 13, 2019
    Posts:
    2
    Thanks Jeff.

    Will the receipt and transactionID fields of the consumable product be populated as long as it is still pending? Will hasReceipt still return true?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please confirm in your testing with Debug.Log or step debugging via Visual Studio attached to your device. I doubt it has a transactionID yet if it's still in Pending.