Fireship · @fireship

The Future of Checkout Forms - Payment Request API

Uploaded January 17, 2018 · Length 8:18

The Future of Checkout Forms - Payment Request API

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.

  1. 0:00

    [Music]

  2. 0:02

    today I want to show you the future of

  3. 0:03

    checkout forms in progressive web apps

  4. 0:06

    using that browser payments API instead

  5. 0:09

    of giving users a long tedious checkout

  6. 0:11

    form that they're likely not to finish

  7. 0:12

    we give them a simple Buy Now button

  8. 0:14

    that uses a credit card saved on their

  9. 0:16

    browser so it behaves a lot more like

  10. 0:19

    in-app payments do on native mobile

  11. 0:21

    devices this is very recent technology

  12. 0:23

    and it's only available in Chrome and

  13. 0:25

    Microsoft edge to facilitate this

  14. 0:28

    feature in angular we'll be using

  15. 0:30

    stripe elements which has the added

  16. 0:31

    benefit of supporting Apple pay on

  17. 0:34

    safari browsers if you're new to the

  18. 0:36

    channel make sure to subscribe and if

  19. 0:37

    you're serious about payments check out

  20. 0:39

    my full stack stripe payments course

  21. 0:41

    which you can find on angular firebase

  22. 0:42

    comm and is free to all pro members to

  23. 0:46

    build this payment request button the

  24. 0:48

    first thing I'm going to do is start

  25. 0:49

    with a fresh angular 5 app at this point

  26. 0:52

    you'll also need a stripe account and

  27. 0:53

    you'll want to reference the payment

  28. 0:55

    request button in the stripe

  29. 0:56

    documentation what we're building is

  30. 0:59

    just a simple component that has a

  31. 1:00

    random product I found on Amazon and

  32. 1:02

    then when the Buy Now button is clicked

  33. 1:04

    it will bring up the browser payments

  34. 1:06

    API when the user clicks pay it's going

  35. 1:09

    to send the payment information off to

  36. 1:11

    stripe and stripe will respond with that

  37. 1:13

    payment source you can see we have a

  38. 1:15

    source ID here in the console as well as

  39. 1:18

    information about the users credit card

  40. 1:19

    but no information that would actually

  41. 1:21

    be a client-side security risk now

  42. 1:25

    jumping into our angular code the first

  43. 1:27

    thing we'll have to do is add the stripe

  44. 1:29

    j/s version 3 tag to index.html stripe

  45. 1:33

    j/s has its own stripe class so we need

  46. 1:35

    to register it with typescript and

  47. 1:37

    typings DTS from there we need to

  48. 1:41

    instantiate stripe somewhere in our

  49. 1:42

    project to do that I'm going to use an

  50. 1:44

    angular service which I'm calling the

  51. 1:46

    payment service after we generate it

  52. 1:49

    with the CLI we can go in there and

  53. 1:50

    instantiate it with our stripe

  54. 1:52

    publishable key for the sake of

  55. 1:54

    simplicity I'm using the key directly in

  56. 1:56

    the angular service but a better

  57. 1:58

    approach would be to manage your keys in