Fireship · @fireship

Stripe Billing - Get Paid for your SaaS

Uploaded July 16, 2018 · Length 13:00

Stripe Billing - Get Paid for your SaaS

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.

  1. 0:00

    [Music]

  2. 0:06

    back in April straight payments released

  3. 0:08

    a new billing platform that makes

  4. 0:10

    complex subscription payments easier

  5. 0:12

    than ever to demonstrate this tool we're

  6. 0:14

    going to build a pretty ambitious

  7. 0:15

    feature a subscription plan that doesn't

  8. 0:17

    get billed on a fixed rate but rather

  9. 0:19

    based on the user's volume of usage

  10. 0:21

    within the app the goal is to give you a

  11. 0:23

    foundation for building your own

  12. 0:24

    software as a service type application

  13. 0:26

    that has a pay-as-you-go payment plan if

  14. 0:29

    you're new here make sure to LIKE and

  15. 0:30

    subscribe and also a little later today

  16. 0:32

    at 1:00 p.m. Pacific Time or 7:00 p.m.

  17. 0:35

    GMT I will be appearing on the angular

  18. 0:37

    Academy show so make sure to register so

  19. 0:39

    you can live chat with myself and the

  20. 0:41

    world-famous David East to get started

  21. 0:44

    with this project you'll need to have a

  22. 0:45

    stripe account and we'll be making heavy

  23. 0:46

    use of firebase functions there's a new

  24. 0:49

    tool in firebase that makes a feature

  25. 0:50

    like this much easier to build than it

  26. 0:52

    was a few months ago and that's thanks

  27. 0:54

    to callable functions basically a

  28. 0:56

    callable function is just like an HTTP

  29. 0:59

    function except that it sends the

  30. 1:00

    context for the authenticated user this

  31. 1:03

    is extremely powerful because it means

  32. 1:05

    you don't have to set your own

  33. 1:06

    authorization headers in the front end

  34. 1:08

    or have to decode them on the back end

  35. 1:09

    which means a lot less code to write and

  36. 1:12

    test will be writing three different

  37. 1:14

    cloud functions so let's walk through

  38. 1:15

    this step-by-step the first one is an

  39. 1:17

    auth function that happens after the

  40. 1:19

    user logs in and sets up their account

  41. 1:21

    with a stripe customer ID after we have

  42. 1:24

    the customer ID set up the next major

  43. 1:26

    milestone is to collect a payment source

  44. 1:28

    and sign up a user for the subscription

  45. 1:30

    plan will implement stripe elements to

  46. 1:33

    collect and validate the credit card

  47. 1:35

    from the user then when they click the

  48. 1:38

    submit payment button it will trigger

  49. 1:39

    our callable function with the auth

  50. 1:41

    context so we can securely attach that

  51. 1:44

    credit card to the user in our back-end

  52. 1:45

    that signs the user up for the plan and

  53. 1:48

    writes a bunch of information to their

  54. 1:49

    fire store user document but at this

  55. 1:51

    point their estimated bill is zero

  56. 1:53

    because they haven't actually done

  57. 1:54

    anything in the app in this particular

  58. 1:57

    app we will charge the user one dollar

  59. 1:59

    per month for every project that they