Android in-app purchases with multiple accounts

て烟熏妆下的殇ゞ 提交于 2019-12-11 02:30:25

问题


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

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.

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.


回答1:


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.



来源:https://stackoverflow.com/questions/36338950/android-in-app-purchases-with-multiple-accounts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!