Search Unity

iOS IAP RestoreTransactions not triggering ProcessPurchase

Discussion in 'Unity IAP' started by Jonsi, Jun 19, 2020.

  1. Jonsi

    Jonsi

    Joined:
    May 21, 2013
    Posts:
    45
    I've based my IAP code on the script here https://learn.unity.com/tutorial/unity-iap#5c7f8528edbc2a002053b46e

    Purchasing works perfectly. I connect, see the product price and can purchase using m_StoreController.InitiatePurchase(product)

    This triggers ProcessPurchase and I can manage the purchase in my app and call PurchaseProcessingResult.Complete;.

    However, when I test the restore process I get

    RestorePurchases started ...

    IAPManager:RestorePurchases()
    <DoRestore>d__41:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
    2020-06-19 14:08:29.095559+0100 puzzle[28391:8483297] UnityIAP: Restore transactions
    2020-06-19 14:08:29.095638+0100 puzzle[28391:8483297] UnityIAP: RestorePurchase
    2020-06-19 14:08:29.656695+0100 puzzle[28391:8483297] UnityIAP: PaymentQueueRestoreCompletedTransactionsFinished
    RestorePurchases continuing: True. If no further messages, no purchases available to restore.
    <>c:<RestorePurchases>b__43_0(Boolean)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()


    Which looks great. Restore completes without error but ProcessPurchase is not triggered.


    Why would ProcessPurchase not be triggered?

    The product has been purchased - if I go to try to purchase again Apple says that the item has already been purchased and the flow from here works correctly.

    I'm running :-

    Unity 2018.4.19f1
    IAP 1.23.1
    Xcode 9.4.1 (will try a later version on my build setup)
    And on an iPhoneX running an older iOS 11.4.1
     
  2. Jonsi

    Jonsi

    Joined:
    May 21, 2013
    Posts:
    45
    An update. It seems as though my original test user has got into a state that means it just won't restore. It seems specific to this test user.

    I've tried another couple of times with new test users and all works as expected. I can purchase and restore perfectly.

    My original test user still won't restore using the restore process. But if I try to purchase again I get the message "You've already purchased this. Would you like to get it again for free?" all runs through that process correctly.
    So it is just one particular test user that will not run through the restore process correctly.

    I'm not sure how to progress this any further.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please continue to test with a new user and/or a new product. We have a new version of IAP hopefully coming out this week that you will want to test with also.
     
  4. Grinchi

    Grinchi

    Joined:
    Apr 19, 2014
    Posts:
    130
    Same here 1.23.3 version. after restore on iOS ProcessPurchase is not triggered.
     
  5. Jonsi

    Jonsi

    Joined:
    May 21, 2013
    Posts:
    45
    Out of curiosity it may be worth repeating with another test user account.

    I somehow got into this state with one particular test user. This was the first account I used when testing Unity IAP. I repeated the tests with some other test user accounts and these worked fine. I've not managed to determine what was different about the test user or test case that resulted in ProcessPurchase not being triggered on restore.

    In your case, if you try and purchase again do you get the "You've already purchased this....etc" message?
     
  6. Grinchi

    Grinchi

    Joined:
    Apr 19, 2014
    Posts:
    130
    yes its says that message. its on testflight and i have around 5 users same for all. 1.23.1 same. now will try 1.19 lets see
     
    Last edited: Jul 13, 2020
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please show your code for Restore
     
  8. Grinchi

    Grinchi

    Joined:
    Apr 19, 2014
    Posts:
    130
    Code (CSharp):
    1. extensions.GetExtension<IAppleExtensions> ().RestoreTransactions (result => {
    2.         if (result) {
    3.             // This does not mean anything was restored,
    4.             // merely that the restoration process succeeded.
    5.         } else {
    6.             // Restoration failed.
    7.         }
    8.     });
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You might consider adding error handling and numerous Debug.Log statements in all your callbacks, they will show in XCode during testing https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/ Also, what type of product did you originally purchase and are expecting to restore? Only subscriptions and non-consumables would be expected to restore.
     
    Last edited: Jul 13, 2020
  10. Grinchi

    Grinchi

    Joined:
    Apr 19, 2014
    Posts:
    130
    its non-consumable and i have add all logs in every fucntion your plugin supports restore is logged with no problem but it never comes in ProcessPurchase. will try in clean project.
     
    tapizquent likes this.