Search Unity

[Android] Clarification on non-consumable purchase flow with specific network failure

Discussion in 'Unity IAP' started by Remstam, Sep 24, 2021.

  1. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    23
    Preface: the whole scenario is reproducible on Android only. iOS platform behaves fine.

    Environments the scenario tested on:
    - Unity 2018LTS & Unity IAP 2.2.7 (asset) + com.unity.purchasing 2.2.2
    - Unity 2019LTS & com.unity.purchasing 3.2.3
    - Unity 2019LTS & com.unity.purchasing 4.0.3

    And the Sample IAP test project v2 was used for both 3.2.3 and 4.0.3 versions.

    We see potential bad user experience during non-consumable purchase flow with specific emulated (but it also can be real, of course) network failure. The steps are down below:

    Session 1:
    - user purchases non-consumable item
    - native pop-up invites user to purchase
    - native pop-up clicked
    - turn off network connection as fast as possible (actually we are using Charles with throttling enabled and with 0% "Reliability" setting set - that might be important!)
    - native pop-up with network failure description appears
    - user presses OK button, quits the app
    - Google Play order history contains info with a new unfinished transaction

    Everything goes fine for now, despite no ProcessPurchase call for obvious reason
    A guess: as non-consumable purchase was not acknowledged from app side after session 1, google launches it's refund timer, which is 5 minutes/3 days for test/release purchases

    Session 2:
    - app is initialized
    - a guess: ProcessPurchase has to be called for unfinished purchase from session 1, but it doesn't happen
    - all the other attempts to purchase the same item results in DuplicateTransaction error
    - user is upset and quits the app

    Still seems that IAP is doing fine, the only disappointing thing is that the user cannot purchase
    A guess: refund timer is over between session 2 and 3, so it is free to purchase again

    Session 3:
    - refund has taken place; Google Play has that info in history
    - app is initialized and the item can be successfully purchased

    If we turn off the network connection in session 1 by waiting 1-2 seconds (not as that fast as possible), app receives ProcessPurchase on session 2 and thus reward is given and user is happy.

    So ok, the final result is somewhat acceptable:
    - either the user in fact doesn't spend money because of refund and doesn't take reward because of ProcessPurchase is not called, or
    - the user spends money and receives reward as usual.

    The question is: is this described IAP behaviour intentional and happens by design? Or there should be a fix for that?

    Thank you.
     
    Yuliya_Miheeva likes this.
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We have heard similar reports. The user never receives a ProcessPurchase during a network disconnect event on Google, even when restarting the game. We will check.
     
    Remstam likes this.
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So far I am not able to reproduce. I am testing IAP 4.0.3 on my Android phone. Right after I select the 1-Tap Buy button, I immediately pull the power cable on my router. I get an immediate "Error - You have no Internet connection" system popup, and then I receive an OnPurchaseFailed/UserCancelled callback. I'm able to purchase the product after the network is restored.
     
  4. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    23
    So we have tested a little bit more and have the following results:

    We didin't have on option to break the internet connection by pulling the power cable on router for some particular reasons, but we replaced that part of scenario with turning off the hotspot the test device is connected to. So, if we try that scenario in a single session (as described in your previous message): try purchase -> break connection -> OnPurchaseFailed -> restore connection -> repeat purchase - then we get "You have already owned that item" and DuplicateTransaction response code.

    ProcessPurchase is called at the next session anyway, so it is somewhat OK to live with.

    Also we were able to reproduce once again the original scenario with 3 sessions where no ProcessPurchase is called and Google Play makes it's refund action which results in bad user experience.

    We have video, app logs and native logs for all those 3 sessions on Sample IAP project if you'd like to investigate, but I'd like to send them via private messages, if possible.

    If it's not, I'll try to get the permission to post materials publicly here in this thread.

    Thank you.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Thanks for the report, just specific steps to reproduce is sufficient. Please be quite specific when you mention "try purchase", at which time exactly do you break the connection? And this is with IAP 4.0.3? And also provide the steps that lead to a refund. Feel free to send additional information in a private message on here, just click on my picture to reply.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @Remstam I received your message, I will continue to try to reproduce here.
     
    Remstam likes this.
  7. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    23
    Are there any updates on that issue so far?
    Thank you.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are still looking into this. We've reproduced by backgrounding the app and then foregrounding by touching the app icon which results in similar behavior, hopefully that fix will apply here too.
     
    Remstam likes this.