javascriptmeteormeteor-packages

How to handle users who have not paid?


I am looking for a secure way to intentionally disable my meteor app in order to ensure monthly client payments.


Solution

  • You need to think about what you're going to do with a user who hasn't paid. Logging them out isn't great because then they can't reactivate their subscription!

    Let's say you add a key to the user object such as validSubscriber. You can, for example, wire your publications and methods not to return data if the user is not a valid subscriber.

    Meteor.publish('foo',(param1,param2) => {
      const isValidSubscriber = Meteor.user(this.userId).validSubscriber;
      if (isValidSubscriber){
        return ...
      } else {
        this.ready();
      }
    });
    

    On the client, you can have your routes check to see if the user is a valid subscriber and if not direct them to the payments page.

    While a clever user might be able to get around your routes, the belt-and-suspenders approach with your methods and publications will prevent them from seeing any data or doing anything with it.

    You're unlikely to find a pre-made "snippet" for this because subscription management represents part of the "business rules" of your own application. Everyone's approach will be slightly different.

    One thing I recommend is using a recurring payment system (Stripe supports this) so that users don't need to manually resubscribe. Either their credit-card expires or is cancelled and/or you give them an unsubscribe feature in their account setup.