Search Unity

Bug ProcessPurchase called again after restore and restart on iOS

Discussion in 'Unity IAP' started by junkie88, Jan 31, 2024.

  1. junkie88

    junkie88

    Joined:
    May 28, 2019
    Posts:
    1
    Hi!

    I made a test purchase of a non-consumable product. After that, I reinstalled the application and performed a purchase restoration. The purchase was successfully restored, and the ProcessPurchase method returned PurchaseProcessingResult.Complete. You can review the logs in the attached file UnityIAP_1.log.

    Then, I restarted the application, and ProcessPurchase was called again for the same purchase. You can find the logs in the attached file UnityIAP_2.log.

    In the UnityIAP_1.log, you can notice that during the purchase restoration, the purchaseEvent.purchasedProduct.transactionID differs from the transactionID in the receipt. However, in the second set of logs (after restarting the game), you can see the line "UnityIAP: Transaction 2000000512646607 not pending, nothing to finish here."

    Why is ProcessPurchase called a second time for an already completed purchase? This happens every time I reinstall the application and attempt to restore purchases.

    I make the purchase through the Sandbox environment.

    Unity version 2021.3.31f
    UnityIAP version 4.10.0

    Thank you in advance for your assistance!
     

    Attached Files:

    Last edited: Jan 31, 2024
  2. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    It's common for Unity IAP to call ProcessPurchase multiple times for the same non-consumable purchase. You just have to handle it and not award that thing a second time. I've been using Unity IAP on Android for years and just now trying to get it working on iOS in the StoreKit Test environment. I'm getting weird things there like when I call InitiatePurchase and complete it successfully, Unity IAP won't call ProcessPurchase until I restart the app, even though it does add the receipt to the Product, I can see it if I run through the products and log the receipts.