anjlab / android-inapp-billing-v3

A lightweight implementation of Android In-app Billing Version 3
Other
2.19k stars 532 forks source link

No purchased information updated after change user account #260

Open AGO68 opened 7 years ago

AGO68 commented 7 years ago

Hi the behaviour is the same in lollipop, M and Nougat I'm using an Activity The way to instantiate is using bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() { The main problem is that I'm always receving the same information even changing the user (Google Account)

I have an App where the user is able to use different Google Accounts and when the user change the account, the app get the google information and also the information kept in the servers.

Each time that the user change the account the App creates a new instace of BillingProcessor as below and just only when I have received the new credentials from google never before. The problem is that I'm always getting the same information from the same user, independently of what google account is active.

Even I did a small trick in your code on BillingBase creating a different preferences file per googgle account, with this, each account has his own preference file and his own data, but comparing both files the information is the same.

private SharedPreferences getPreferences() {return context.getSharedPreferences(Complements.getUserID(context) + "_preferences", Context.MODE_PRIVATE); }

to SignIn - SignOut I'm using

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

Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(

This is the way that I'm using in the App

bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() { @Override public void onProductPurchased(String productId, TransactionDetails details) { } @Override public void onBillingError(int errorCode, Throwable error) { } @Override public void onBillingInitialized() { } @Override public void onPurchaseHistoryRestored() { } });

Thanks in advance.

serggl commented 7 years ago

Does your code also changes active account in Play Market app? I think this is the one actually used by IAB API

AGO68 commented 7 years ago

Ok thanks, then seeing your response there is no way to get purchased information of several google accounts configured in the device, just for the activated one in Google Play.

Sure that this place is not the right one to launch this question, but how can I activate/deactivate Google Play Accounts programmatically? I did an initial search but I didn't find nothing clear.

Thanks in advance, Best regards,

tdtran commented 6 years ago

IAP purchases are tied to the Google account which is current when the app is installed. Switching the current account in Google Play after that has no effect. Google Play remembers under which account the app was installed and uses it for IAP.

AGO68 commented 6 years ago

Thanks, the problem is that even changing the user from Google Play, still continue using previous user credentials.

Best regards

El 22 nov. 2017 13:18, "Trung Duc Tran" notifications@github.com escribió:

IAP purchases are tied to the Google account which is current when the app is installed. Switching the current account in Google Play after that has no effect. Google Play remembers under which account the app was installed and uses it for IAP.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anjlab/android-inapp-billing-v3/issues/260#issuecomment-346334252, or mute the thread https://github.com/notifications/unsubscribe-auth/AIZiJnu0D2RdUJP20ps8C8SuN4a6k3_Uks5s5BEmgaJpZM4M_Qkm .

tdtran commented 6 years ago

@AGO68 what I just said. That account is the account user used to install the app. The only way to change the account is: (1) uninstall the app, (2) switch the account in Google Play Store app, (3) install the app again.

Switching the account in Google Play Store app without reinstalling the app has no effect. And I think that's the correct and desired behavior.

mazhenlei commented 5 years ago

@tdtran 你说的是真的吗 这么麻烦还要去重装app 谷歌这操作,,,,我现在就遇到这个切换账号无法仍然是上个app账号的情况