0

I'm building a flutter app that will allow users to subscribe. I'm using this plugin: in_app_purchase 0.5.2

So, my question is: I have to log my users in, and I do this using firebase Auth. But, how can I check which user is logged to deliver them the right purchase? I mean, using the firebase Auth, where or must I check if the current user has purchased something?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Daniel Dantas
  • 145
  • 3
  • 15

1 Answers1

2

You can use a database like firestore to store all the purchase information. Ex: Users/Auth-id

then retrieve it whenever needed. you can also get the previous purchases with the API

Ex:

final QueryPurchaseDetailsResponse response = await InAppPurchaseConnection.instance.queryPastPurchases(); //returns previous purchases 

Note that the App Store does not have any APIs for querying consumable products, and Google Play considers consumable products to no longer be owned once they're marked as consumed and fails to return them here. For restoring these across devices you'll need to persist them on your own server and query that as well.

Nishuthan S
  • 1,538
  • 3
  • 12
  • 30
  • Than you, @Nishutan i will definitely try this. – Daniel Dantas May 04 '21 at 11:24
  • So, i was investigating and came to the following conclusion, pls tell me if you agree with that: The plugin opens google play API, so the users account, credit card and informations will be already there. What will happen is that, the plugin will deliver us (programmers) the information if, for THAT google account, there is somethin purchased or not. Accordind to that response, it's up to us decide what to do. Am i right? Missing something? Thanks in advance (again) !! – Daniel Dantas May 04 '21 at 11:39
  • 1
    yes, @DanielDantas their job is to make sure the payment gets through and keep track of the purchase history (Not in case of consumables if it has been marked for delivery). The rest is up to us. – Nishuthan S May 04 '21 at 17:34
  • Thank you! @Nishutan – Daniel Dantas May 04 '21 at 19:49