Set Up Subscription Payments with Stripe, Next.JS & Firebase! 🔥

Поделиться
HTML-код
  • Опубликовано: 27 июн 2024
  • In this video, we'll set up subscription payments using Next.JS, Firebase, and Stripe. Using Firebase's "Run Subscription Payments with Stripe" Firebase extension to easily integrate all the tools together.
    With this extensive guide, we'll set up the following:
    - Create a new Next.JS project
    - Set up Authentication in Firebase
    - Created a Firestore Database in Firebase
    - Created a Stripe Account, and a subscription product to go with it.
    - Synchronise products with Stripe and our Firestore Database
    - Set up a way of accepting subscription payments with Stripe
    - Synchronised customer and subscription data between Stripe and Firebase
    - Added custom claims to Firebase users to determine whether they are free or premium customers.
    - Exclusively shown premium content to paying customers
    Timestamps:
    0:00 - Introduction
    1:23 - Create Next.JS Project
    1:40 - Adding TypeScript
    2:22 - Creating Firebase Project
    2:45 - Firebase Authentication
    3:45 - Firebase Web Application Setup
    4:21 - Cloud Firestore Setup
    4:35 - Firebase Client Code
    5:12 - Authentication Frontend
    6:13 - Firestore Users Collection
    7:00 - Stripe Firebase Extension
    12:54 - Stripe Frontend Code
    15:28 - usePremiumStatus Hook
    16:04 - Displaying Premium Content
    16:50 - Testing Stripe Transactions
    Check out my other content:
    / jarrodwattsdev
    jarrodwatts.com
    github.com/jarrodwatts
    blog.jarrodwatts.com
    www.buymeacoffee.com/jarrodwatts
  • НаукаНаука

Комментарии • 91

  • @gilbertwalker9862
    @gilbertwalker9862 2 года назад +22

    is this using the old firebase v8 code? I would absolutely love to see this with the new v9 code

    • @JarrodWatts
      @JarrodWatts  2 года назад +4

      Hey Gilbert! This is unfortunately using v8 code :(
      Hopefully most of the process is the same, but there will be a number of code differences on the Firebase side of things.
      Thanks for pointing it out - I'll pin your comment too.

    • @gilbertwalker9862
      @gilbertwalker9862 2 года назад +2

      @@JarrodWatts ah no worries... yea unfortunately a lot of resources atm are using the old code ... so hard for a n00b like me to figure out how to transform into v9... love the vid though

    • @muhammedrashid1244
      @muhammedrashid1244 2 года назад +2

      Any updates, I have a problem with it, when sessions document is created, I can't getting back the same doc. I tired giving Id for the doc, and when I get it back the session is is not there,

    • @shannoncole6425
      @shannoncole6425 2 года назад +1

      I would love to see the updated code for this too! I'm a noob too and had to force in the same versions of firebase and hooks in order to continue with the video. I'm planning on, hopefully, doing a full membership site that provides access to another service and this firebase/stripe tutorial seems right up my ally on what I need to do.

    • @nowaccki
      @nowaccki 2 года назад +3

      @@JarrodWatts seconding this, would also love to see a new video with v9 :)

  • @hesamalavi9
    @hesamalavi9 3 года назад +1

    I have been going nuts to find a resource like this, just as I thought I should give up this video showed up, you are in my good books for ever :D

  • @Myerzman
    @Myerzman 2 года назад +1

    Super fast but worked like a charm! THANK YOU. Fantastic walkthrough

  • @JoshuaTMagee
    @JoshuaTMagee 2 года назад +9

    Fantastic video, Jarrod! Would love to see more long-form video series from you on building complex web apps that leverage Next.js, Firebase and Stripe. Awesome content!

    • @JarrodWatts
      @JarrodWatts  2 года назад

      Thanks a lot Josh! Really appreciate it. Hopefully more coming like this in the near future!

  • @migom6
    @migom6 3 года назад +6

    your content is so perfect, it's a hybrid between fireship and traversy

    • @JarrodWatts
      @JarrodWatts  3 года назад +2

      That is the best compliment I can get! Thanks Madhurjya 😍

  • @minashawkylvlup
    @minashawkylvlup 3 года назад +1

    About time, I was just setting it up yesterday 🙌

  • @mstibbard
    @mstibbard 2 года назад +1

    This is a fantastic guide, thank you!

    • @JarrodWatts
      @JarrodWatts  2 года назад +1

      Thanks again Matthew! Appreciate your support mate! 🇦🇺

  • @waifufx
    @waifufx Год назад

    Well done Sir, No Cap The video is great you are the future fireship around here, lol

  • @JamesQQuick
    @JamesQQuick 2 года назад

    Love this!!

    • @JarrodWatts
      @JarrodWatts  2 года назад

      Wow thank you James!
      I am a big fan of your content so that means a lot 😍

  • @vineetharvind7718
    @vineetharvind7718 2 года назад

    Thanks, it helped me speed up a lot of development effort

  • @foreach1
    @foreach1 2 года назад

    Amazing!

  • @nettion
    @nettion 2 года назад

    Amazing tutorial mate. Keep it up

    • @JarrodWatts
      @JarrodWatts  2 года назад

      Thanks Marcos! Really appreciate that

  • @onerandomscene
    @onerandomscene 2 года назад

    Good Job and Thank you

  • @anandbhandari
    @anandbhandari 2 года назад

    Good video, thanks

  • @afrosoul4eva
    @afrosoul4eva Год назад

    Great content

  • @azizanbouri4101
    @azizanbouri4101 Год назад

    i really need the v9 firebase version, your content is fabulous

  • @vanshshah7781
    @vanshshah7781 Год назад

    Thank you.

  • @hansajalisan6643
    @hansajalisan6643 2 года назад

    Great video Jarrod!!
    If You know would love to see this same Subscription payment with stripe and firebase setup in Flutter also.

  • @kvetoslavnovak423
    @kvetoslavnovak423 2 года назад

    This is amazing and very helpful video. The best Firebase & Stripe tutorial.
    Would you be so kind to explain how to set up Stripe SaaS per-seat (per-user) subscriptions ? When the app is used by organizations with admins who create their other basic users?

  • @AdamSmaka
    @AdamSmaka 2 года назад

    an instant subscribe button press after watching video like this!

  • @flash_gif
    @flash_gif 2 года назад

    Was wondering if you'd make a video on stripe and amplify?
    Anyway awesome video. Thanks!

    • @JarrodWatts
      @JarrodWatts  2 года назад +1

      Hopefully at some point in the future I will be able to! I've personally not done it in the past but would be keen to try it out. Thanks for the awesome suggestion and feedback!

  • @Guru-zi8hr
    @Guru-zi8hr 2 года назад +1

    thanks for the video! this one was really point to point...
    Quick question - what do you use to edit/ make your videos?
    Quick suggestion - it would be awesome if you can make a video on how to fetch details from a form and save it to a user's document. There are very less quality videos on user management with firebase.

    • @JarrodWatts
      @JarrodWatts  2 года назад

      Thank you, appreciate it!
      I use OBS to record the footage and Adobe Premiere Pro to put my videos together.
      Thanks for the suggestion 🙏 hopefully more Firebase videos on the way soon.

  • @shannoncole4379
    @shannoncole4379 2 года назад +1

    How do you add email/password and google logins to this after finishing this tutorial? Great video by the way. Everything worked wonderfully.

  • @PaoloTshiyole
    @PaoloTshiyole 4 месяца назад

    I discover this video today and it's amazing, good video
    I've just a question
    It's possible to make the same video but with flutter web? A firebase subscription extension with flutter web and stripe

  • @Smartercow
    @Smartercow Год назад +1

    Man!!! We need an updated version with Firebase V9. There's only one video like this that exist on RUclips and it uses Firebase V8..... :((((((

  • @BadMike47
    @BadMike47 9 месяцев назад

    Does this work with one time payment products? i tried this but the stripeRole field isnt getting added to my user after he completes payment

  • @vasubansal3468
    @vasubansal3468 2 года назад

    Perfect timing

    • @JarrodWatts
      @JarrodWatts  2 года назад

      Haha awesome to hear Vasu! What are you working on yourself?

    • @vasubansal3468
      @vasubansal3468 2 года назад

      @@JarrodWatts I was working on a SAAS project (not gonna reveal the name of it just yet)

  • @LowrollerWTF
    @LowrollerWTF 2 года назад

    Very interesting video. BTW I've heard the stripe functions can take forever to be invoked because of the cold start but the demo project you put together seems to go fairly fast: Was it edited or this is the actual speed of your app?

    • @JarrodWatts
      @JarrodWatts  2 года назад +2

      Sometimes they are a little slow, I edited the loading time out of this video like you said! In the real world we'd probably need a loading state to show while it opens up

    • @LowrollerWTF
      @LowrollerWTF 2 года назад

      @@JarrodWatts thanks for the answer

  • @hiphopheaven
    @hiphopheaven 2 года назад

    I have multiple products created before I installed the extension.Is there a way to import all those products to firestore?

  • @shannoncole6425
    @shannoncole6425 2 года назад

    How do you setup the the customer portal with this code? I’ve been struggling to find out how to get this working. Thanks

  • @jayanthl7000
    @jayanthl7000 2 года назад

    Wow! Such a quality video!
    How much time does it take to make a video of this quality ?

    • @JarrodWatts
      @JarrodWatts  2 года назад

      Thank you! Typically it takes around 1 week to put something like this together!

  • @noobCoder26
    @noobCoder26 2 года назад

    great

  • @iankitverma
    @iankitverma 2 года назад

    Can you please do it with firebase 9, would there be any major changes

  • @ferruchododdoli3300
    @ferruchododdoli3300 Год назад

    Awesome video. Why did you save the user's checkout sessions in firestore?

  • @teetanrobotics5363
    @teetanrobotics5363 Год назад

    Amazing tutorial !! However, I would request you to slow down a bit for the newbies

  • @CodeNight-dm2hv
    @CodeNight-dm2hv 2 года назад

    Great video. But I'm having a lot of trouble migrating to v9.

  • @FragmentAudio
    @FragmentAudio 2 года назад

    Do you think is possible to create an account ONLY once a succesful charge or users should be logged-in first before doing the purchase?
    I saw there is a way to do this (without using this extension) but I don't want to run Next JS using SSR as I would have to give up using serverless functions etc...

  • @michael_ibeh
    @michael_ibeh 2 года назад

    can stripe be replaced with paystack?, please if it can't can you do REACT, FIREBASE AND PAYSTACK 🙏

  • @ElbinBinil
    @ElbinBinil 2 года назад

    Hey how are you making the graphics for your video
    By the way I like your videos

  • @karimsensei
    @karimsensei Год назад +1

    the same tutorial updated would be soooo great ! but at the same time its easy to follow and adapt the new code, so many thanks for this

    • @karimsensei
      @karimsensei Год назад +1

      it wasn't easy at all to adapt to the new code, but totally worth it!

    • @maxshapovalov7010
      @maxshapovalov7010 Год назад

      @@karimsensei were you able to make the code work? I got everything figured out except for loading the cookie if the user is premium

    • @karimsensei
      @karimsensei Год назад

      @@maxshapovalov7010 yes, was hard but everything is working, if the checkout session is working for you and you can makw the fake payment then the user premium would be easy, be sure that when u make the price u write in the metadata firebaseRole and premium and then console.log the premium hook

    • @TheAppliancePlug
      @TheAppliancePlug Год назад

      @@karimsensei is there anyway I can see your code? I am currently trying to figure this out as well

    • @karimsensei
      @karimsensei Год назад +1

      i'm creating a Saas so my code is private, but if you want something explained in this video version v9 you tell me which file and i can help you :)

  • @slashbrackets3397
    @slashbrackets3397 11 месяцев назад

    Everything works, I get payment information attached to the user in firestore. The only thing i'm missing is Stripe doesn't create the products collection in Firestore. Not sure what i'm missing, everything else works. What am I missing?

  • @UsfCodes
    @UsfCodes 2 месяца назад

    "Error creating checkout session: FirebaseError: Missing or insufficient permissions." i get that when i use createChekoutSession

  • @shannoncole6425
    @shannoncole6425 2 года назад +3

    After a few days I have 99% of the script updated to support v9 but I'm struggling on changing the Firebase.User to a v9 compatible format in the userPremiumStatus file. Any suggestions? Also I am interested in offering 4 tiers of access (free-metered, tier 1 price $x.xx, tier 2 price $x.xx, and tier 3 price $x.xx). Any thoughts on changing the code to support multiple pricing plans? Thanks!

    • @amorenva
      @amorenva 2 года назад

      hey Shannon, did u managed to solve this? thanks! same situation here.

  • @AMigosJJM
    @AMigosJJM 2 года назад

    Hey man, good video. Thanks for uploading! Just wondering where you've disapeared to, you all good?

    • @JarrodWatts
      @JarrodWatts  2 года назад +1

      Hey mate, thanks! Yeah, all good - just working on a few important things outside of this content at the moment!
      Hopefully I'll be able to do more weekly videos in September, but thanks for checking in, appreciate it!

    • @AMigosJJM
      @AMigosJJM 2 года назад

      @@JarrodWatts that’s all good man, you been working on that saas project? I love the idea of it so so much, I’m working on my own “saas” website too. It’s not explicitly saas but nevertheless it’s a lot of fun haha. But yea your videos are super helpful, if you have a discord idm connecting/ sharing ideas etc :)

  • @thecurious926
    @thecurious926 Год назад

    is there any examples for one-time payment through the extension?

    • @Mr.chandan
      @Mr.chandan 9 месяцев назад

      Did u get it ? Pls share it it will be helpful

  • @ZaarmTech
    @ZaarmTech 2 года назад +1

    Will it work if .env file is not prefixed with NEXT_PUBLIC?

    • @zinx6809
      @zinx6809 2 года назад

      It will work as long as you make some settings in next js folder or something which is complicated. So using it this was is easier.

  • @hesamalavi9
    @hesamalavi9 2 года назад

    A question, how would you create a customer portal using the implementations in your video?

    • @JarrodWatts
      @JarrodWatts  2 года назад +2

      Hey Hesam - currently I'm working on doing the same thing in my project - hopefully I will be able to get back to you with how I implemented it soon!

    • @hesamalavi9
      @hesamalavi9 2 года назад

      @@JarrodWatts That would be amazing. Right now I have implemented it, but the customer portal link is only accessible when the user first signs up and makes a purchase, and in session. As soon as they Log out, then sign back in again, I get an error saying customer param missing.

    • @JarrodWatts
      @JarrodWatts  2 года назад +1

      @@hesamalavi9 Hey Hesam! Sorry it took me a while, I've just implemented this myself. I didn't encounter the problem that you're describing - I used Lee Robinsons documentation about implementing the customer portal found here, docs.react2025.com/payments/customer-portal let me know if that helps you out at all.

    • @hesamalavi9
      @hesamalavi9 2 года назад

      @@JarrodWatts Thanks for letting me know, very much appreciate it. I used his as well, however I have also used others along the way, so something is not right, too many chefs as they say, haha. I decided to go with a one off payment for now which works. I had to create custom claims for it to work as the extension does not add StripeRole for the one off payments.

  • @CodeNight-dm2hv
    @CodeNight-dm2hv 2 года назад

    Hi. I'm having some trouble making the createCheckoutSession.js is giving me a error on this:
    const checkoutSessionRef = await setDoc(collection(db, "users", uid, "checkout_sessions"), docData);
    The error is:
    Unhandled Runtime Error
    FirebaseError: Expected type 'mc', but it was: a custom yc object

  • @rahulkishan1934
    @rahulkishan1934 2 года назад

    paypal is more promising for clients

  • @HKRazieL
    @HKRazieL 8 месяцев назад

    this all fine and dandy, thanks for the tutorial but it doesn't work with the newest version of firebase... might have added that somewhere just to save the trouble of researching that this is outdated...

    • @zachrussell6791
      @zachrussell6791 6 месяцев назад

      With very little adjustments it works. Is there any particular issue you're having?

  • @user-vf5bm6vr8e
    @user-vf5bm6vr8e Год назад

    What is the point of using `@stripe/stripe-js` ? When we add a document in user's checkout_sessions collection, the Stripe API returns a `url`. Can't we just use `window.location.href` with this url information ?