Deferred purchases issues with IAP 4.5.0 in Android

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

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.

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/com.unity.purchasing@4.5/api/UnityEngine.Purchasing.IGooglePlayConfiguration.html?q=deferred

My code worked fine with the previous IAP purchase version 4.4.1 and in [version 4.5.0 ]( https://discussions.unity.com/t/632966 page-2#post-8485985)I didn’t see any change about that

8488778--1129289--1664893265601.jpg

Where are you seeing “transaction success = false”. Do you receive ProcessPurchase or OnPurchaseFailed?

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?

Interesting, yes I will check. You are correct, the listener should be called first.

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://discussions.unity.com/t/699654 and https://discussions.unity.com/t/700293/6

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

Understood and I believe you, but this is different behavior from what I am seeing. We will dig deeper into this.

2 Likes

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.

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?

This is required by Google and there’s no way to disable it.

Is there any reason you wanted to disable this?

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!

This thread is now closed. Feel free to reach out via a new thread if you encounter further issue.
Thanks!