Fireship · @fireship
The Future of Checkout Forms - Payment Request API
Uploaded January 17, 2018 · Length 8:18
Summary
Implementing browser payments API in Angular using Stripe Elements for progressive web apps
- angular payments api
- stripe elements
- browser payments
- progressive web apps
- stripe payments
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:02
today I want to show you the future of
- 0:03
checkout forms in progressive web apps
- 0:06
using that browser payments API instead
- 0:09
of giving users a long tedious checkout
- 0:11
form that they're likely not to finish
- 0:12
we give them a simple Buy Now button
- 0:14
that uses a credit card saved on their
- 0:16
browser so it behaves a lot more like
- 0:19
in-app payments do on native mobile
- 0:21
devices this is very recent technology
- 0:23
and it's only available in Chrome and
- 0:25
Microsoft edge to facilitate this
- 0:28
feature in angular we'll be using
- 0:30
stripe elements which has the added
- 0:31
benefit of supporting Apple pay on
- 0:34
safari browsers if you're new to the
- 0:36
channel make sure to subscribe and if
- 0:37
you're serious about payments check out
- 0:39
my full stack stripe payments course
- 0:41
which you can find on angular firebase
- 0:42
comm and is free to all pro members to
- 0:46
build this payment request button the
- 0:48
first thing I'm going to do is start
- 0:49
with a fresh angular 5 app at this point
- 0:52
you'll also need a stripe account and
- 0:53
you'll want to reference the payment
- 0:55
request button in the stripe
- 0:56
documentation what we're building is
- 0:59
just a simple component that has a
- 1:00
random product I found on Amazon and
- 1:02
then when the Buy Now button is clicked
- 1:04
it will bring up the browser payments
- 1:06
API when the user clicks pay it's going
- 1:09
to send the payment information off to
- 1:11
stripe and stripe will respond with that
- 1:13
payment source you can see we have a
- 1:15
source ID here in the console as well as
- 1:18
information about the users credit card
- 1:19
but no information that would actually
- 1:21
be a client-side security risk now
- 1:25
jumping into our angular code the first
- 1:27
thing we'll have to do is add the stripe
- 1:29
j/s version 3 tag to index.html stripe
- 1:33
j/s has its own stripe class so we need
- 1:35
to register it with typescript and
- 1:37
typings DTS from there we need to
- 1:41
instantiate stripe somewhere in our
- 1:42
project to do that I'm going to use an
- 1:44
angular service which I'm calling the
- 1:46
payment service after we generate it
- 1:49
with the CLI we can go in there and
- 1:50
instantiate it with our stripe
- 1:52
publishable key for the sake of
- 1:54
simplicity I'm using the key directly in
- 1:56
the angular service but a better
- 1:58
approach would be to manage your keys in


