Fireship · @fireship
Subscription Payments with Stripe, Angular, and Firebase
Uploaded September 27, 2017 · Length 13:53
Summary
Build subscription payments with Stripe, Angular, and Firebase, including setting up Stripe Checkout and handling recurring payments with web hooks.
- stripe payments
- angular firebase
- subscription model
- stripe checkout
- recurring payments
- web hooks
- firebase database
- cloud functions
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
subscription payments are one of the
- 0:01
most effective ways to monetize your
- 0:03
software in this episode we're going to
- 0:05
use the stripe payments API along with
- 0:07
angular firebase and cloud functions to
- 0:10
build a subscription model into an app
- 0:12
by the end of this video you'll be able
- 0:13
to accept credit cards through your
- 0:15
front-end angular app and then save
- 0:16
information about the subscription in
- 0:18
the firebase database and handle
- 0:20
recurring payments with stripe web hooks
- 0:22
I have to warn you that this video
- 0:24
covers a lot of code in a very short
- 0:26
amount of time so I recommend going to
- 0:27
angular firebase comm to follow along
- 0:29
with the source code and get additional
- 0:31
content related to stripe payments so
- 0:33
first things first you'll need to have a
- 0:35
stripe account which you can get at
- 0:36
stripe com then retrieve your test API
- 0:40
key and add it to your environment TS
- 0:42
file and angular then we're going to add
- 0:45
the stripe Checkout j/s library to the
- 0:48
index.html file it goes in the head tag
- 0:50
and it allows us to collect credit card
- 0:52
details then send them back to stripe
- 0:54
then the last thing we need to do is
- 0:56
tell typescript about stripe so we go to
- 0:58
the Taipings DTS file and then just
- 1:01
declare a variable called striped
- 1:03
checkout from here we'll initialize
- 1:05
cloud functions in our project using the
- 1:07
firebase CLI so we ran firebase and knit
- 1:10
functions from there we also need to set
- 1:12
our stripe test key in the functions
- 1:14
environment so we can do that by running
- 1:16
firebase functions config set stripe
- 1:19
test key with your test key in there
- 1:21
then we'll CD into the functions
- 1:24
directory and install the stripe NPM
- 1:26
package we do that with NPM installs
- 1:29
stripe save and this allows us to
- 1:31
communicate with the stripe API from our
- 1:34
node.js cloud functions environment ok
- 1:36
so that wraps up the initial setup now
- 1:38
we can actually start building this
- 1:39
subscription model before we can create
- 1:42
a subscription we need to create a
- 1:43
customer and stripe it's easiest if you
- 1:46
create that customer as soon as your
- 1:47
user signs up for your app so we're
- 1:49
going to create a cloud function that
- 1:51
runs as soon as a user signs up for the
- 1:53
first time and it's going to save the
- 1:55
stripe customer ID in this customers
- 1:58
node on the database the stripe customer


