Fireship · @fireship
Stripe Billing - Get Paid for your SaaS
Uploaded July 16, 2018 · Length 13:00
Summary
Implementing Stripe Billing for a SaaS application with Firebase Functions and Angular, including user authentication, payment source collection, and subscription plan setup.
- stripe billing
- saas application
- firebase functions
- angular
- user authentication
- payment source collection
- subscription plan setup
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:06
back in April straight payments released
- 0:08
a new billing platform that makes
- 0:10
complex subscription payments easier
- 0:12
than ever to demonstrate this tool we're
- 0:14
going to build a pretty ambitious
- 0:15
feature a subscription plan that doesn't
- 0:17
get billed on a fixed rate but rather
- 0:19
based on the user's volume of usage
- 0:21
within the app the goal is to give you a
- 0:23
foundation for building your own
- 0:24
software as a service type application
- 0:26
that has a pay-as-you-go payment plan if
- 0:29
you're new here make sure to LIKE and
- 0:30
subscribe and also a little later today
- 0:32
at 1:00 p.m. Pacific Time or 7:00 p.m.
- 0:35
GMT I will be appearing on the angular
- 0:37
Academy show so make sure to register so
- 0:39
you can live chat with myself and the
- 0:41
world-famous David East to get started
- 0:44
with this project you'll need to have a
- 0:45
stripe account and we'll be making heavy
- 0:46
use of firebase functions there's a new
- 0:49
tool in firebase that makes a feature
- 0:50
like this much easier to build than it
- 0:52
was a few months ago and that's thanks
- 0:54
to callable functions basically a
- 0:56
callable function is just like an HTTP
- 0:59
function except that it sends the
- 1:00
context for the authenticated user this
- 1:03
is extremely powerful because it means
- 1:05
you don't have to set your own
- 1:06
authorization headers in the front end
- 1:08
or have to decode them on the back end
- 1:09
which means a lot less code to write and
- 1:12
test will be writing three different
- 1:14
cloud functions so let's walk through
- 1:15
this step-by-step the first one is an
- 1:17
auth function that happens after the
- 1:19
user logs in and sets up their account
- 1:21
with a stripe customer ID after we have
- 1:24
the customer ID set up the next major
- 1:26
milestone is to collect a payment source
- 1:28
and sign up a user for the subscription
- 1:30
plan will implement stripe elements to
- 1:33
collect and validate the credit card
- 1:35
from the user then when they click the
- 1:38
submit payment button it will trigger
- 1:39
our callable function with the auth
- 1:41
context so we can securely attach that
- 1:44
credit card to the user in our back-end
- 1:45
that signs the user up for the plan and
- 1:48
writes a bunch of information to their
- 1:49
fire store user document but at this
- 1:51
point their estimated bill is zero
- 1:53
because they haven't actually done
- 1:54
anything in the app in this particular
- 1:57
app we will charge the user one dollar
- 1:59
per month for every project that they


