dooboolab-community / flutter_inapp_purchase

(Sun Rised!) Flutter plugin for In App Purchase.
MIT License
549 stars 236 forks source link

Unique id to identify each user unique purchase #478

Open shankarbhattarai123 opened 4 months ago

shankarbhattarai123 commented 4 months ago

I got a issue that when in my device i am logged in from one Gmail account called "abc@gmail.com" and in my app i am logged in from user 1. I purchased from user 1 and logged out from user 1. I signed in with different user in my app called user. Now when i try to restore purchase history i got user 1 purchase history. Now how can i track purchase history of each individual user although Gmail/playstore login is same for all user. Is there any way. Please give me some solution.

aCodeMechanic commented 2 months ago

Facing the same issue. Did you find any solution? @shankarbhattarai123

shankarbhattarai123 commented 2 months ago

@aCodeMechanic yes. When purchase success, you get a receipt in the response and you should pass that receipt to the backend where backend developer verify your receipt and if valid then subscription data will added in user response. You have to check user response from api response and if there is subscription data and end date is after the current date then it is ok means user has purchased a plan. Otherwise if end date is before current date then you have to check if receipt is coming or not from frontend and if receipt is coming then you should send it again in backend. Backend will update your user response with updated end date.if not plan is expired so that you can redirect to the subscription purchase screen. You can get receipt using this code : data = await FlutterInappPurchase.instance.getAvailablePurchases();