|
|
|
|
|
by davismwfl
4201 days ago
|
|
We create a Stripe customer at the same time the customer registers. At that same time we assign them to a "free" plan at Stripe. Then once they decide on which plan and to stay on and be a subscriber we update their plan to the new plan. Stripe then charges them for it and sets the recurrence etc. You can also setup the plans to have a grace period before they are charged with Stripe. As for how we actually implement it, we create a small service around subscriptions and it is called by our create steps which then hides the calls to Stripe. This way if we ever went away from Stripe it would only require some small changes in the subscription service. Also, we store the Stripe customer id and card id in our subscription record, and we do it using a generic data structure where we list vendor, vendor customerId and vendor cardId etc. This way nothing is labeled Stripe, except the vendor value itself would be Stripe in our case. Lastly we also have a web hook active so we can get notifications from Stripe and update records appropriately. Again, a small separate service that handles only the web hooks. |
|
One thing I realized now, reading your answer, is that the customer's plans should be changed depending by the user's usage (think storage space). Should I be running a cron job once or twice a day to check the usage, compare it to their subscription plan and update it at Stripe? Of course notify them by email, and maybe give them a day to re-do and not give them unexpected charges.