DuplicateTransaction when switch Google account

I have a NoAds button in my game which invokes a non-consumable purchase (Unity 2019.3.3f1, IAP 2.0.0).

It works fine - tested on mobile with Alpha version of the game. However I have problem when I switch to different Google account I can’t purchase again so the game does not show ads for that Google account. In the code I receive IStoreListener.OnPurchaseFailed with DuplicateTransaction.

My understanding was that the purchase is bound to a google player/account. However it looks like it is bound to a device…

The detailed step:

  • Start the game and login to a Google account (PlayGamesPlatform.Instance.Authenticate). I login as user “Joe” - I can see the Welcome Joe Google Play banner.
  • Click the NoAds button which performs the purchase (IStoreController.InitiatePurchase) - this works fine. I receive a confirmation e-mail from Google that I performed a testing purchase.
  • Logout from Google account (PlayGamesPlatform.Instance.SignOut) and login with different account e.g. as user “John” - I can see the Welcome John Google Play banner…
  • I restart my game (not important - I do silent login to Google as “John”) and I try to perform NoAds purchase.

This time however the IStoreListener.OnPurchaseFailed method is called with PurchaseFailureReason.DuplicateTransaction.

Any idea what is wrong?

Thanks for your help,
Abyss

How are you “switching users”? It’s the user on the device who is logged into Google Play, not Google Services within the app.

On the testing device I have multiple Google accounts… Now I’m confused what is the difference between Google Play and Google Services accounts?

Thinking about this… now if I understand correctly, the Google Play account is the account under which I installed my device/mobile and probably I can’t change. Google Services account can be the same as Google Play (same e-mail) but can be different.

When I start a game and I authenticate to Google I select one of the Google Services account. This is what I’m switching. I can change to different Google Service account. Correct me if I’m wrong…

So it means that all IAP goes to Google Play account. Even if I switch to different Google Service account, the IAP still goes to “original” Google Play account.

If this is the case I’m not sure I like this… I would expect that the active/current Google Service user is charged in the game. The only way how to workaround this is to not use non-consumable purchase at all. Use consumable purchase for my case (NoAds button) - what I can invoke more times, and using my game data control if the given account already purchased the NoAds item and do not allow to do it more times. This means that one Google Play user will be charged for all purchases of different Google Services users…

Please let me know what do you think. Maybe I’m wrong with my understanding of Google accounts - I did not differentiate Google Play vs Google Services. Is there a way to achieve what I want using Unity IAP?

Thanks, Abyss

The Google Billing Library (of which Unity IAP is a wrapper for) uses Google Play. Some android devices allow multiple accounts. Are you able to log into Google Play with your multiple accounts?