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

Resolved Deferred purchases issues with IAP 4.5.0 in Android

Discussion in 'Unity IAP' started by alexm_scp, Oct 4, 2022.

Thread Status:
Not open for further replies.
  1. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Hi,

    I tested the new version of the IAP package v. 4.5.0 (Unity 2020.3.38f1), and the system returned a failure when making a purchase using the Deferred options in Google Play.

    I don't have any error related to the IAP package, but the "transaction success" is false, and my server is complaining that it cannot verify the purchase receipt or signature. If I try to purchase in the usual way (not deferred), all works fine.

    Do you have the same behavior?

    Thanks
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you elaborate what deferred options you are referring to? Please show the code that you are using, specifically to wire up the deferred listener, the listener code, and ProcessPurchase.
     
  3. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    Deferred purchase = "Slow test card, approves after a few minutes" (see the image attached)

    I'm using the SetDeferredPurchaseListener to handle them:
    function https://docs.unity3d.com/Packages/c...sing.IGooglePlayConfiguration.html?q=deferred

    My code worked fine with the previous IAP purchase version 4.4.1 and in version 4.5.0 I didn't see any change about that
     

    Attached Files:

  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Where are you seeing "transaction success = false". Do you receive ProcessPurchase or OnPurchaseFailed?
     
  5. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    I receive first the ProcessPurchase, and after that is executed the callback defined in SetDeferredPurchaseListener.

    In the previous release, the order of execution was different.

    If I'm not wrong, the ProcessPurchase shouldn't be executed first. That's the reason the IAP flow is not working fine.

    Could you check these callbacks are called in the correct order?
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Interesting, yes I will check. You are correct, the listener should be called first.
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    In my testing with "Slow Credit Card - Always Approves" , the deferred listener is called immediately, then a few minutes later I receive ProcessPurchase. This is expected behavior. Again, where are you seeing "transaction success = false"? I might suggest to place appropriate Debug.Log statements in all your purchasing methods like in the Sample project. These will show in the device logs which would be very helpful https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/ and https://forum.unity.com/threads/sample-iap-project.529555/#post-8432501
     
  8. alexm_scp

    alexm_scp

    Joined:
    Nov 5, 2019
    Posts:
    24
    I found the issue: the problem is in the new package version 4.5.0. The ProcessPurchase is triggered more quickly than the previous versions, making our purchase flow fail.

    I mean, the flow is not the same as what I had:
    • First is executed the listener SetDeferredPurchaseListener
    • Few seconds after this is executed, the ProcessPurchase <-- this was making fail our purchases
    • After a few minutes, the ProcessPurchase is executed again.
    In previous versions, the flow was:
    • First is executed the listener SetDeferredPurchaseListener
    • After a few minutes, the ProcessPurchase is executed again.
    I have a fix from my side, but it seems something changed in the way to trigger those events
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood and I believe you, but this is different behavior from what I am seeing. We will dig deeper into this.
     
    LeeEonU and alexm_scp like this.
  10. Unity_3D_Alex

    Unity_3D_Alex

    Unity Technologies

    Joined:
    Nov 11, 2020
    Posts:
    10
    Version 4.5.1 is now available through the Package Manager. It looks like this is fixed. Please let us know if you experience any issues with the new version.
     
  11. IcyHammer

    IcyHammer

    Joined:
    Dec 2, 2013
    Posts:
    70
    Is there a way to disable deferred purchases? Documentation on developer.android.com says you need to explicitly call "
    enablePendingPurchases" in order to enable so called deferred purchases, otherwise they will fail. How can I disable this functionality?
     
  12. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    218
    This is required by Google and there's no way to disable it.

    Is there any reason you wanted to disable this?
     
  13. IcyHammer

    IcyHammer

    Joined:
    Dec 2, 2013
    Posts:
    70
    I wanted to disable it so I don't have to deal with those special cases right now, I guess I misunderstood this is an optional thing. Thanks for such a fast response!
     
  14. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    166
    This thread is now closed. Feel free to reach out via a new thread if you encounter further issue.
    Thanks!
     
Thread Status:
Not open for further replies.