Fireship · @fireship

Subscription Payments with Stripe, Angular, and Firebase

Uploaded September 27, 2017 · Length 13:53

Subscription Payments with Stripe, Angular, and Firebase

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.

  1. 0:00

    subscription payments are one of the

  2. 0:01

    most effective ways to monetize your

  3. 0:03

    software in this episode we're going to

  4. 0:05

    use the stripe payments API along with

  5. 0:07

    angular firebase and cloud functions to

  6. 0:10

    build a subscription model into an app

  7. 0:12

    by the end of this video you'll be able

  8. 0:13

    to accept credit cards through your

  9. 0:15

    front-end angular app and then save

  10. 0:16

    information about the subscription in

  11. 0:18

    the firebase database and handle

  12. 0:20

    recurring payments with stripe web hooks

  13. 0:22

    I have to warn you that this video

  14. 0:24

    covers a lot of code in a very short

  15. 0:26

    amount of time so I recommend going to

  16. 0:27

    angular firebase comm to follow along

  17. 0:29

    with the source code and get additional

  18. 0:31

    content related to stripe payments so

  19. 0:33

    first things first you'll need to have a

  20. 0:35

    stripe account which you can get at

  21. 0:36

    stripe com then retrieve your test API

  22. 0:40

    key and add it to your environment TS

  23. 0:42

    file and angular then we're going to add

  24. 0:45

    the stripe Checkout j/s library to the

  25. 0:48

    index.html file it goes in the head tag

  26. 0:50

    and it allows us to collect credit card

  27. 0:52

    details then send them back to stripe

  28. 0:54

    then the last thing we need to do is

  29. 0:56

    tell typescript about stripe so we go to

  30. 0:58

    the Taipings DTS file and then just

  31. 1:01

    declare a variable called striped

  32. 1:03

    checkout from here we'll initialize

  33. 1:05

    cloud functions in our project using the

  34. 1:07

    firebase CLI so we ran firebase and knit

  35. 1:10

    functions from there we also need to set

  36. 1:12

    our stripe test key in the functions

  37. 1:14

    environment so we can do that by running

  38. 1:16

    firebase functions config set stripe

  39. 1:19

    test key with your test key in there

  40. 1:21

    then we'll CD into the functions

  41. 1:24

    directory and install the stripe NPM

  42. 1:26

    package we do that with NPM installs

  43. 1:29

    stripe save and this allows us to

  44. 1:31

    communicate with the stripe API from our

  45. 1:34

    node.js cloud functions environment ok

  46. 1:36

    so that wraps up the initial setup now

  47. 1:38

    we can actually start building this

  48. 1:39

    subscription model before we can create

  49. 1:42

    a subscription we need to create a

  50. 1:43

    customer and stripe it's easiest if you

  51. 1:46

    create that customer as soon as your

  52. 1:47

    user signs up for your app so we're

  53. 1:49

    going to create a cloud function that

  54. 1:51

    runs as soon as a user signs up for the

  55. 1:53

    first time and it's going to save the

  56. 1:55

    stripe customer ID in this customers

  57. 1:58

    node on the database the stripe customer