Search Unity

[Solved] 1.20.1 Android Google Play: can not restore non-consumable product

Discussion in 'Unity IAP' started by Lesha-VH, Dec 4, 2018.

Thread Status:
Not open for further replies.
  1. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    96
    Install application
    made test purchase of non-cosumable item
    remove and re-install application

    Call UnityPurchasing.Initialize, got callback OnInitialized().

    In log:
    "Already recorded transaction GPA.3394-...
    UnityIAP: Promo interface is available for 40 items"


    But (as said in Manual), I did not receive any call of
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) {}

    so I can not restore non-consumable product on Android..

    When I try to buy this non-consumable again I got
    "onPurchaseFailEvent" with reason DuplicateTransaction

    Could someone help me and point my mistake?
    Thanks!
     
    Last edited: Dec 4, 2018
  2. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi,
    Could you please post a full log?
    Thank you.
     
  3. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    96
    here is the Unity log - taken from actual device

    consumable items and subscriptions works as expected.
     

    Attached Files:

  4. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi,
    Purchasing records are saved in 'Application.persistentDataPath/files/Unity/UnityPurchasing'. Deleting this folder can make 'ProcessPurchase' invoked again for Non-Consumable and Subscription products at next launch.
    Could you please give it a try?
     
  5. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    96
    Yes, I will try!

    What about another solution - is it correct?
    This solutions works, even after we remove and install application. All receipts are available on device.

    Just check the receipt for specific non-consumable product:

    Code (CSharp):
    1. public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    2. {
    3.  
    4. ....
    5.  
    6. foreach (Product item in _Controller.products.all)
    7. {
    8. if (item.definition.type == UnityEngine.Purchasing.ProductType.NonConsumable &&
    9.                 item.hasReceipt)
    10.  
    11.             {
    12. GiveItem(item.definition.id);
    13. }
    14. }
    15.  
    16. }
     
    Last edited: Dec 5, 2018
  6. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi,
    Deleting the 'UnityPurchasing' folder is only for testing IAP. Please do not use this way in production.
    Checking the receipt for Non-Consumable/Subscription products in 'OnInitialized' callback is the right method.
    Let's get back to your original issue, did 'ProcessPurchase' get invoked after you delete the 'UnityPurchasing' folder?
     
  7. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    96
    I did not check delete folder "UnityPurchasing", because I need only production solution.
    Checking receipts is right method - so I use only it)
    Thanks!
     
Thread Status:
Not open for further replies.