In-app purchases (IAP) in android with BOTH Google and Facebook authentication?

In my android application I want to let users to authenticate with google or facebook account.

I've implemented sign-in with google already. I'll try to implement sign-in with facebook soon.

I've read about IAP in android:



at least what I understand it is about google account authentication.

So I wonder is it possible to make IAP in android application if the user is authenticated with facebook account ?

I cant find examples or explanations by now. Any good examples/explanations about IAP with google is also very appreciated because I still don't have a clear vision on IAP.

fyi: In my app user will be able to buy "virtual tickets pack" (e.g.: 10, 15, 20 tickets) and to add them to their profile. and later they will "consume" tickets one by one.

Best Regards

- - Source


answered 1 week ago ak93 #1

IAP can only be done through the user's google account, as that is what one needs to use any part of the Play Store. The user's google account is also where the credit card/other payment methods are stored for each user.

In spite of the above, the way users log into your app has nothing to do with them using the IAP system. When a user will choose to use an IAP, the google account data will be provided by the android device/Play Store, not by your app (Off subject:the process is similar on iOS if you ever get to try there).

What your app needs to do, is receive the confirmation of purchase from the IAP sdk and then mark on your server that this particular user has purchased this item. Basically for any purchases (no matter the payment provider) you would usually mark in your DB the following:

  • what the user has purchased
  • how much did he pay
  • when did he pay
  • provider's id of the purchase, so you can later match the accounting reports with the payment provider's report
  • where he payed from (IP can be a good indicator, although in the age of VPNs not necessarily 100% acurate)(this can be useful for your marketing decisions)
  • mark that this user now has access to the item he purchased and if it is a time limited item, mark when it expires, so you are able to later check if he still has the right to access it.

Disclaimer: I have not used the android IAP system directly before. I have implemented mobile app payment systems before using iOS IAP and on android Braintree payments. But the process is most likely very similar with android IAPs as well.

answered 1 week ago Cesar #2

My understanding is that you already have a user system that you are using to provide a Google login to your customers. When you add Facebook login, you'll probably want to match both Google and Facebook logins with your own custom user ID. It's always a good idea to have a custom ID of your own so that you can map it to different types of logins.

When purchasing through Google Play Billing, the purchase gets associated with the user's phone Google account and you can also provide an optional way of associating a purchase with your own user account system. In order to do that, when building the BillingFlowParams, call setAccountId and pass your account's system custom ID.

To provide the best experience persisting purchases during installs or across devices you should also be saving the purchases on your server's database. In order to do that in a secure manner, you will also have to implement server-side receipt validation. If you want to avoid most of these headaches, I recommend you to use a service like RevenueCat.

comments powered by Disqus