Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Android - OnPurchaseFailed is not called

Discussion in 'Unity IAP' started by alexm_scp, Jan 11, 2021.

  1. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Hi,

    I'm trying version 2.2.5 and I have an issue with this repro steps (Android):
    - Player clicks to buy a product
    - When the Android OS buy button appears go to pause (put the game in background)
    - Wait 2 or more secs
    - Come back to the game: the IStoreListener is not calling the OnPurchaseFailed function letting the purchase pending

    This issue doesn't occur in version 2.1.1. It worked fine calling the OnPurchaseFailed which I can handle the error.

    Do you have any ETA for a new version of the plugin?

    Thanks
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We will need to test this behavior.
     
  3. DavidGameDuell

    DavidGameDuell

    Joined:
    Apr 17, 2019
    Posts:
    3
    @JeffDUnity3D Any update on that?

    We experience the same issue currently on 2.2.5. Will there be a fix soon or do we have to downgrade to 2.1.1 for now?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    The next version of IAP should be out later this week or early next week
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I'm not seeing this behavior on Scripted or Codeless IAP. Once I click the background to dismiss the Google purchase dialog, I immediately receive OnPurchaseFailed with failure reason UserCancelled, as expected. I'm using the Sample IAP Project here with IAP 2.2.5 (Asset) and In App Purchasing library 2.2.1 (Package Manager) https://forum.unity.com/threads/sample-iap-project.529555/
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you elaborate "go to pause"? Once the Google purchase dialog appears, your game is already in the background. I also tried pressing the Home button and switching to another app with the purchase dialog up. Once I came back to my app, the dialog was gone and I had received OnPurchaseFailed.
     
  7. DavidGameDuell

    DavidGameDuell

    Joined:
    Apr 17, 2019
    Posts:
    3
    @JeffDUnity3D

    The issue only occurs for me if I go back to the app via app icon on homescreen or app list. If I go back to the app by switching tabs on android then I see a black screen with the android billing overlay on top still active and once I dismiss that one I get the expected OnPurchaseFailed event and can also see the game again.

    However, if I come back to the app by clicking on the app icon then the android billing overlay is gone and no OnPurchaseFailed event is triggered. For our internal purchase tracking the purchase is still in a pending state ...

    For now we switched back to IAP 2.1.1 where everything works fine so far
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, I have reproduced by going back to the app icon, thank you for the steps to reproduce. I will let the team know of the issue.
     
    DavidGameDuell likes this.
  9. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    @JeffDUnity3D

    For me these are the steps to repro the issue:

    - When the Google purchase dialog appears press the Android home button (exit game)
    - Wait 2 or more secs
    - Press the game icon to return
    - The OnPurchaseFailed is not triggered
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Thank you, we already have a repro.
     
    alexm_scp likes this.
  11. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Hi @JeffDUnity3D,

    I still have the same issue with plugin version 2.2.6, package v.2.2.2 (using Unity 2018.4.30)
     
    nicholasr likes this.
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are working on this.
     
    alexm_scp likes this.
  13. nicholasr

    nicholasr

    Unity Technologies

    Joined:
    Aug 15, 2015
    Posts:
    183
    Thanks for your patience @alexm_scp. We investigated this billing flow issue and unfortunately have no solution at this time.

    We could be overlooking an opportunity to fix this behavior. I'm sharing our findings to-date, here in hopes this helps fix the issue ultimately. We plan to open a ticket with Google Support, and are also discussing internally whether there is a way we could configure AndroidManifest.xml differently although I feel that major change is a risky way to accommodate the needs of purchasing.

    We reproduced the following behavior:
    1. Using Google Play Billing Library v3.0.1
    2. Launch app and initialize, connecting to Google Play billing
    3. Initiate a purchase
    4. See a Google Play Billing purchasing dialog
    5. Navigate away from the app
    6. Use the Android Launcher's app-icon to resume the app (not the Task Switcher)
    7. See no dialog, instead the original app. Receive no callback on the Google PurchasesUpdatedListener.
    We reproduced it outside of Unity:
    • On a non-Made With Unity project, using a small Kotlin class (download Project and see file Android-Project/app/src/main/java/com/example/testinggooglebillingv3/MainActivity.kt)
    • Experimented with AndroidManifest.xml attribute changes: to the com.unity3d.player.UnityPlayerActivity's android:alwaysRetainTaskState and android:allowTaskReparenting ... we still need to research further whether there is a solution to be won through those attributes.
    We explored a workaround hack, and rejected:
    • Detect a purchasing dialog being opened, and then handle the failure-state combination of:
      • app being resumed via Activity.onResume, presumably from the Android Launcher's app-icon
      • no prior signal from PurchasesUpdatedListner
    • Trigger: Unity IAP IStoreListener.OnPurchaseFailed
    • REJECTED: a trivial rotation of the device generates Activity.onResume callbacks, cannot differentiate between normal player device rotation and this scenario
     
    alexm_scp and JeffDUnity3D like this.
  14. KonstantinShkulev

    KonstantinShkulev

    Joined:
    Jan 24, 2019
    Posts:
    30
    Still occurs on plugin version 2.2.7 :(
     
  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, as we've noted in this thread. The latest IAP is 3.0.1
     
  16. DavidGameDuell

    DavidGameDuell

    Joined:
    Apr 17, 2019
    Posts:
    3
    @nicholasr

    It seems that Google fixed the issue in Google Billing 3.0.3 (at least the changelog mentions something like that along the lines).

    Will the Unity IAP package automatically get that version or do we have to wait for a new release?
     
    kinglinus likes this.
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We will be including v 3.0.3 in the next IAP release which is currently in review
     
    kinglinus and DavidGameDuell like this.
  18. kinglinus

    kinglinus

    Joined:
    Dec 9, 2019
    Posts:
    3
    There is the new 3.0.2 version from April 1st. Do you mean this one? Or will there be a new 2.x release?
     
  19. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Hi @JeffDUnity3D,

    IAP versions 3.0.x are not available in Unity 2018.4.x. Do you plan to have compatibility for these Unity versions?
    Or maybe we'll have a new IAP version 2.2.8 fixing these kinds of errors?

    Thanks!
     
  20. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry no, we won't be backporting to Unity 2018.4. We won't have a 2.2.8 version, we are at version 3 now and above. The 3.0.2 release was a documentation release only, any bug fixes will be in the next release. No ETA but hopefully soon (generally a week or two)
     
  21. markmozza

    markmozza

    Joined:
    Oct 16, 2015
    Posts:
    85
    Hi, Sorry to post to an old topic, but the latest version of IAP, im having this very issue. No matter what OnPurchaseFailed does NOT! trigger. We were on the verge of publishing a new version but this a huge setback.

    In App Purchasing 4.9.4
    Services Core 1.11.0
     
  22. bullettea

    bullettea

    Joined:
    Oct 24, 2019
    Posts:
    29
    The OnPurchaseFailed method isn't showing up as an option in the inspector on the IAP Button when the method is on a script. All other methods will show up though.