sampl / firefly

Web app boilerplate for beginners based on Firebase and React 🔥
http://getfirefly.org/
234 stars 42 forks source link

Add stripe subscription demo #116

Closed sampl closed 6 years ago

sampl commented 6 years ago

Users can create subscriptions with stripe checkout. Only cloud functions can mark them as active. DataProvider shows subscription status on the user page.

sampl commented 6 years ago

Stripe subscriptions require stripe customers. Ensure stripe customers exist and are saved to a User on auth login so there’s one for every customer. Get the stripe customer id from the User model when creating a subscription on the backend.

sampl commented 6 years ago

Might have been cool if you could get customer if from stripe API with email, but as expected it looks like you must get with id: https://stripe.com/docs/api/node#delete_customer

On second thought this would break if there’s an email change, so maintaining a map from stripe customers to Firefly users on our side might be unavoidable

sampl commented 6 years ago

Question: how much loading state do we need to add to the subscriptions model to make the UI clear?

sampl commented 6 years ago

done d815a3051e9fbd70ee790f8eedd40b49a6189e2e

sampl commented 6 years ago

had to create stripe users on user create since there's no auth login trigger

there's a stripe_error attr of subscriptions that can be shown to users, should be all the state we need