2

I am adding in-app purchases to my app, which is working. I have a device that has two accounts on it. One is my primary account--which I use to publish apps--and the other is a dev account that I use to test purchases.

Before the user can purchase, they are required to sign in using their google credentials:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestEmail()
    .build();

mGoogleApiClient = new GoogleApiClient.Builder(mainActivity)
    .enableAutoManage(mainActivity, this)
    .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
    .build();

Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
mainActivity.startActivityForResult(signInIntent, RC_SIGN_IN);

At this point, I choose my dev account

enter image description here

Even though I choose my dev account, when I attempt to make a purchase, it appears to use my primary account and does not allow me to make a purchase.

enter image description here

I cannot determine a way to specify which Google account is to be used when making an in-app purchase.

My main concern is that if a user has multiple accounts on their device, will my app make a purchase on the wrong account?

Can anyone provide any insight on this?

Note: If I sign in to my device using the Dev account and I sign in to the app, I am only given the option to choose my Dev Google account. Doing this makes in-app purchases work perfectly.

tehscott
  • 101
  • 8

1 Answers1

3

The in-app purchases account is not related to the signed in account, it's related to the user that installed the app on the device. The best way to force a different user is by uninstalling the app from the device and then re-install it from the web version of google play on your PC. Make sure you're signed in with the correct account there and install the app. In-app purchases will be made with that account.

joaomgcd
  • 5,287
  • 4
  • 28
  • 39
  • Same dilemma and your solution did not work for me. If I try this, I get: "This Google account is not yet associated with a device. Please access the Play Store app on your device before installing apps." I have accessed it using that account on my device and can verify that by tapping the hamburger icon in the playstore and the account in question is selected. Do I need to make this the only account on my device? – maplemale Jan 02 '18 at 04:38
  • 1
    Recently this method has stopped working as well. It seems that there's some lag between when you install/uninstall apps and the web version of the play store acknowledges it. Maybe that's what you're seeing? – joaomgcd Jan 03 '18 at 11:33
  • That was exactly it! This actually took hours... Thank you for letting me know! – maplemale Jan 10 '18 at 02:40