Reputation: 4022
I would like to **allow my users using my app across multiple devices **. Users have to log into my app through firebase auth.
Problem is that payments are assigned to account that is signed on the device (google play), not with account signed into the app.** From firebase auth I can get an email address of the user of my app - this could be used as some unique identifier.
Problem visualized:
I noticed that in Billing flow there is .setAccountId("some id") I think I could use this to fill in a unique identifier of a user. But how can use it querying purchases?
BillingFlowParams.Builder builder = new BillingFlowParams.Builder()
.setAccountId("some id")
.setSku(PREMIUM_YEAR_SUBS).setType(BillingClient.SkuType.SUBS);
TLDR: All I want to do is to retrieve purchases that are connected to my APP user account, not device account (google play currently logged in user).
Upvotes: 3
Views: 3737
Reputation: 1
You can check the AccountId
attached to each Purchase
using
Purchase.getAccountIdentifiers
It'll return AccountIdentifiers
object that has
AccountId
& ProfileId
that were set previously in BillingFlowParams
when you launched billing flow
After that you can compare the current user account id with the account id attached to each purchase to detect the purchases that are connected to the current user account
Upvotes: 0
Reputation: 1
It seems that we can't get the accountId, the accountId just used by google play. I guess that you use the accountId to instead of the payload, but after my try, I think that it is not successful. In the Google Billing Library, the develop payload is removed for the same experience between the in-app-purchase and the out-app-purchase. Though we can add payload in the period of consume or acknowledge, but it useless. And the payload should be set on the period of purchase, but google delete it, and will not be add back. The payload issues.
Upvotes: 0
Reputation: 8092
To implement billing using accountId
, try using the getBuyIntentExtraParams()
method which provides additional functionality as compared with getBuyIntent()
method.
With this method, you may use accountId
with the following description:
Optional obfuscated string that is uniquely associated with the user's account in your app. If you pass this value, Google Play can use it to detect irregular activity, such as many devices making purchases on the same account in a short period of time.
Additionally, you may want to also check the typical purchase flow with the In-app Billing API discussed here.
Upvotes: 2