Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Trouble with purchasing consumables on Android devices

Discussion in 'Unity IAP' started by KonstantinShkulev, Dec 25, 2019.

  1. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    If user initiates purchase and goes to home screen before purchasing promt appear, then after returning to game the purchase process won't be proceeded. Neither ProcessPurchase nor OnPurchaseFailed wouldn't be called.

    Logs from device:

    12-25 12:34:24.784 17248 17317 I UnityIAP: isUnityVrEnabled = false
    12-25 12:34:24.785 17248 17490 I UnityIAP: invoking callback
    12-25 12:34:24.785 17248 17317 I Unity : purchase({0}): com.***.***.***.gems1
    12-25 12:34:24.785 17248 17317 I Unity : [IAP] - Set HasActivePurchase to True
    12-25 12:34:24.785 17248 17490 I UnityIAP: Querying owned items, item type: inapp
    12-25 12:34:24.785 17248 17490 I UnityIAP: Package name: com.***.***
    12-25 12:34:24.785 17248 17490 I UnityIAP: Calling getPurchases with continuation token: null
    12-25 12:34:24.789 17248 17490 I UnityIAP: Owned items response: 0
    12-25 12:34:24.789 17248 17490 I UnityIAP: Continuation token: null
    12-25 12:34:24.789 17248 17490 I UnityIAP: Querying owned items, item type: subs
    12-25 12:34:24.789 17248 17490 I UnityIAP: Package name: com.***.***
    12-25 12:34:24.789 17248 17490 I UnityIAP: Calling getPurchases with continuation token: null
    12-25 12:34:24.794 17248 17490 I UnityIAP: Owned items response: 0
    12-25 12:34:24.794 17248 17490 I UnityIAP: Continuation token: null
    12-25 12:34:24.794 17248 17490 I UnityIAP: Querying owned items' purchase history, item type: subs
    12-25 12:34:24.794 17248 17490 I UnityIAP: Package name: com.***.***
    12-25 12:34:24.794 17248 17490 I UnityIAP: Calling getPurchaseHistory with continuation token: null
    12-25 12:34:25.021 17248 17490 I UnityIAP: Purchase history response: 0
    12-25 12:34:25.021 17248 17490 I UnityIAP: Continuation token: null
    12-25 12:34:25.021 17248 17490 I UnityIAP: Querying owned items' purchase history, item type: inapp
    12-25 12:34:25.021 17248 17490 I UnityIAP: Package name: com.***.***
    12-25 12:34:25.021 17248 17490 I UnityIAP: Calling getPurchaseHistory with continuation token: null
    12-25 12:34:25.348 17248 17490 I UnityIAP: Purchase history response: 0
    12-25 12:34:25.349 17248 17490 I UnityIAP: Continuation token: null
    12-25 12:34:25.349 17248 17490 I UnityIAP: invoking callback
    12-25 12:34:25.744 17248 17490 I UnityIAP: onPurchaseProduct: com.***.***.***.gems1
    12-25 12:34:25.744 17248 17490 I UnityIAP: ITEM TYPE:inapp

    Plugin version: 1.22.0
    Unity version: 2019.2.8f1
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Did you pay before returning to the home screen? Can you purchase this product again after returning to the game?
     
  3. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    Update: some devices, like Sony Xperia XZ3, behave differently.

    Steps to reproduce:

    1. Initiate purchase
    2. Press home button before purchase confirmation window appears
    3. Wait a little
    4. Purchase confirmation window will appear surrounded by black screen
    5. Press buy
    6. Watch successful purchase message appear

    After step 6 OnPurchaseFailed will be called with Unknown failure reason. ITransactionHistoryExtensions will inform about IABHELPER_BAD_RESPONSE and GOOGLEPLAY_Null data in IAB result (response: -1002:Bad response received).
     
  4. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    Nope, I didn't. The main step is going to home screen before paying and even pressing pay button. We are blocking UI before starting purchase and because neither ProcessPurchase nor OnPurchaseFailed doesn't get triggered we doesn't unblocking it. But after restarting the game, we can purchase the same product again.
     
    Last edited: Dec 26, 2019
  5. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    After restarting game the ProcessPurchase is getting triggered and user receives his reward. But if user try to buy the same product again after step 6, after game restarting the ProcessPurchase doesn't fire.
     
  6. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    I think this is expected behavior.
     
  7. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Do you mean ProcessPurchase has never been called after the second purchase? Generally speaking, if ProcessPurchase is called after the product is purchased, then ProcessPurchase will not be called again after the next application restart.
     
  8. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    I doubt. Why doesn't google store purchase confirmation window appear? I think that OnPurchaseFailed should be called with UserCancelled reason at least.
     
  9. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    Case 1. User restart the game after step 6. On next launch ProcessPurchase is called and he receives reward.
    Case 2. User make second purchase of the same product after step 6 WITHOUT exiting the game. ProcessPurchase is called and he receives his reward. But on next launch he won't receive reward from first purchase. But he pays money for both purchases and consume only the second purchase, not the first.
     
  10. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    In general, the problem is that user wouldn't see native purchase confirmation window at all and our game wouldn't receive any message about it.
     
  11. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Sorry I did not reproduce this issue on my device (Samsung Galaxy S8), does this issue only appear on Sony devices? Can you reproduce this issue on other devices?
     
  12. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    If you return to PurchaseProcessingResult.Complete when IAP calls ProcessPurchase to process consumable product, then the next time you start the application, the purchase will not be processed in ProcessPurchase. You should save the consumable purchases yourself in the ProcessPurchase process.
     
  13. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    It partially reproduced on our side. Unlike on Sony device, the steps are:

    1. Initiate purchase
    2. Press home button before purchase confirmation window appears
    3. Wait as mush as you like because...
    4. ...purchase confirmation window will never appear
    6. OnPurchaseFailed gets called with IABHELPER_BAD_RESPONSE and GOOGLEPLAY_Null data in IAB result (response: -1002:Bad response received) errors but atleast user won't lose his money

    Game doesn't get broken, user doesn't lose his money. But on other devices we can reproduce these bugs.
     
  14. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    Update: we can reproduce it by hitting Overview button (recent apps button). But there is a low chance to reproduce it.
     
  15. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    But it does in "Case 1. User restart the game after step 6. On next launch ProcessPurchase is called and he receives reward."
     
  16. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    It seems that the behavior of other devices is different from that of Sony devices in step 4. After step 3, the purchase confirmation window will appear on the Sony device but other devices will not, right?
     
  17. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    31
    Yup, thats right
     
  18. ausiasZitro

    ausiasZitro

    Joined:
    Mar 5, 2018
    Posts:
    2
    Hi!

    We found the same error. Going to share what we found in case it's of any help to fix the issue. We found it both on android and ios. It doesn't happen on all devices.

    Steps to reproduce ios:
    1 - Complete a normal purchase saving the password for later.
    2 - Initiate a second purchase
    3 - When the store purchase popup prompts, press the HOME button.
    4 - Go back to the app, UNKNOWN failure reason appears.

    Steps to reproduce Android:
    1 - Initiate a purchase
    2 - When the store purchase popup prompts, press the HOME button.
    3 - Go back to the app, UNKNOWN failure reason appears.

    Devices where we found it happen:
    HTC One M8
    OnePlus 6 (Android10)
    iPad Pro 10"
    Samsung Galaxy S4 (Android 5.0.1)
    iPad Pro 12"
    Huawei P20 lite
    Moto E5
    Samsung Galaxy S9
    Samsung Galaxy Tab SM-T510

    Devices where it doesn't happen (When coming back to the app the purchase popup remains there):
    Iphone X
    BQ Aquaris m10
    iPad Pro 2
    Wiko View XL
    Huawei Mediapad T3 10
    Xiaomi Mi A3
    Samsung note 10+

    Using Unity 2018.4.19f1.
    Using IAP version 1.23.3.

    Hope it helps to resolve the issue.
     
    KonstantinShkulev likes this.
  19. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are checking.
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you try with IAP 1.23.4 ?
     
  21. ausiasZitro

    ausiasZitro

    Joined:
    Mar 5, 2018
    Posts:
    2
    Hello Jeff,

    Thanks for your short reply.

    We tested the same bug with the new version of the IAP and we found some stuff.

    With same steps to reproduce depending on how the user decides to come back to the app, the behaviour is different.

    Steps to reproduce Android:
    1 - Initiate a second purchase
    2 - When the store purchase popup prompts, press the HOME button.
    3 - Go back to the app pressing the app icon on the apps menu, UNKNOWN failure reason appears.


    Steps to reproduce Android:
    1 - Initiate a second purchase
    2 - When the store purchase popup prompts, press the HOME button.
    3 - Go back to the app using the opened apps shortcut, behaves as expected(When coming back to the app the purchase popup remains there)

    Devices where we found it happen:
    Samsung Galaxy Tab SM-T510
    BQ Aquaris m10
    Xiaomi Mi A3
    Wiko View XL
    Samsung Galaxy S4
    Huawei Mediapad T3 10
    Alcatel 3c

    In iOS we tested on iphoneX and iphone 7 and on both when trying to press home it doesn't go to the HOME it directly shows the UNKNOWN error.
     
    KonstantinShkulev likes this.
  22. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    I've confirmed this issue and will report it to our dev team. I Will post here if there has any progress.