Whats the best way to check whether user paid the subscription or not?. I want to check whether the user paid for monthly subscription, if not, I'll redirect him to payment page.
My solutions :
Using JWT : whenever user login, I write next_payment_date
(checking from databse) to jwt and sign it. so every time users makes request to protected routes (routes which can be accessed only for paid users), i decode the token and check next_payment_date
and act accordingly
Problem with this method : Lets say user is using phone and computer.In computer he gets payment expired notification and he makes payment successfully. BUT later when he uses the phone his phone will not have updated **jsonwebtoken**
which will make him to redirect to payment page (which is not a good sign)
Solution 2:
Always check payment status from Database.
Problem with this : Every time request comes, database should be queried , which is the useless read operation.
If you know any better/efficient way to deal with this issue please suggest me