Android - OnPurchaseFailed is not called

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

We will need to test this behavior.

@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?

The next version of IAP should be out later this week or early next week

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) Sample IAP Project

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.

@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

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.

1 Like

@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

Thank you, we already have a repro.

1 Like

Hi @JeffDUnity3D ,

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

1 Like

We are working on this.

1 Like

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:

  • Using Google Play Billing Library v3.0.1

  • Launch app and initialize, connecting to Google Play billing

  • Initiate a purchase

  • See a Google Play Billing purchasing dialog

  • Navigate away from the app

  • Use the Android Launcher’s app-icon to resume the app (not the Task Switcher)

  • 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

2 Likes

Still occurs on plugin version 2.2.7 :frowning:

Yes, as we’ve noted in this thread. The latest IAP is 3.0.1

@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?

1 Like

We will be including v 3.0.3 in the next IAP release which is currently in review

2 Likes

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?

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!

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)