React Stripe Elements Package (NEW 2020) + Charging Stripe in Node: Full stack tutorial

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

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

  • @Skia_
    @Skia_ 4 года назад +16

    Your channel is one of those that deserve way more exposure - the fact that you don't have at least half a million sub is beyond me
    Greetings from Lebanon!

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

      Hey Skia! Greetings from Canada. We'll make it happen :) Just give it some time!

    • @abhishekpatel1535
      @abhishekpatel1535 4 года назад +1

      Eactly

  • @MONTUSKER
    @MONTUSKER 4 года назад +1

    Thank You! Thank You! Thank You! I've been slamming my head against the wall trying to figure this stuff out and hear you are the only tutorial that actually bothers to explain anything completely and fully. This is a lifesaver.

    • @leighhalliday
      @leighhalliday  4 года назад

      Thanks, Joe :) Glad I was able to help! I hope whatever you are doing is able to charge a lot of money!!! :D

    • @MONTUSKER
      @MONTUSKER 4 года назад

      @@leighhalliday I'm making my first real project after doing a Udemy course! It's an art site for my sister so she'll be the one making the money :P I'll just be taking that experience. Maybe I'll charge her 😆

  • @subodhjaguri4274
    @subodhjaguri4274 3 года назад

    great video sir , you explained very well, may you reach 100k soon

  • @rkcoder
    @rkcoder 4 года назад

    First time coming across this channel and I'm surprised it isn't bigger. Great explanation and video, hope you grow fast.

    • @leighhalliday
      @leighhalliday  4 года назад

      Thanks Arima!! We're growing, just takes time :D

  • @kabulzhan
    @kabulzhan 3 года назад

    Cool tutorial! Thank you very much! From Kazakhstan with love!

    • @leighhalliday
      @leighhalliday  3 года назад

      Thanks surfer!! Glad you enjoyed it! Lots of love right back at you from Canada :)

  • @ffrows
    @ffrows 4 года назад

    Great tutorial, i got how the front-end library worked from stripe's docs but i couldn't figure out the backend. It was easier than i thought, thanks. I managed my checkout by simply getting the paymentMethod object into my api so that i could look up the database for the user cart, get the total and charge the total directly from the backend, not a fan of having the amount sent from the client because i feel like it's not that safe and something i would never do, the less i trust the information from the client the better it is, unless obviously, it's signed or hashed for backend verification.

    • @leighhalliday
      @leighhalliday  4 года назад

      Hey Riva! What about a donation or something like that where it the amount is user entered? If it were a store, I would probably not be sending dollar amounts anyway, but some reference to a shopping card which contains products and quantities, where the amount is calculated based on the cart contents.

    • @ffrows
      @ffrows 4 года назад

      @@leighhalliday That would make sense, if you suppose the amount to be paid is a choice made by the user then it becomes a normal input, what i was saying is, in a real scenario where you have a ecommerce website or something based on listing->products->prices it's not the best idea to recive the amout of the cart from the client, it should always be read server-side, pretty much that!

  • @krckyboy
    @krckyboy 4 года назад

    Excellent tutorial. Straight to the point. One thing I would personally change is simply not use Next.js as it doesn't really have any purpose for this, and some viewers would skip the video as soon as they hear that you're using Next.js, not wanting to deal with it simply because they don't know what it's about. Anyway, excellent tutorial, once again!

    • @leighhalliday
      @leighhalliday  4 года назад +3

      Hey kcrckyboy! Thanks :) The reason I used Next.js is because I love it haha! Plus, to process a Stripe charge you need both a frontend and a backend... so I could either do it in 2 separate apps, or I could do it all within a single Next.js app.

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

      you are right
      people will prefer react because most of the people dont really know nextjs.
      they will think they have to learn nextjs in order to follow your tutorial.
      excelent anyway

  • @maxime_spinard
    @maxime_spinard 4 года назад

    Awesome tutorial man ! I was struggling for the past 3 hours to make it work, I can now finish my project :)

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Nice! I hope you are able to charge many credit cards!

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

    Love your videos always so useful

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

    nice! dude, your eyebrows are flying!

  • @noodletrooper
    @noodletrooper 4 года назад

    Thanks for the video, was getting caught up on the structure of the API but this helped a ton

    • @leighhalliday
      @leighhalliday  4 года назад +1

      I hope you're able to charge many many credit cards!

  • @mohammedsaad0761
    @mohammedsaad0761 4 года назад +1

    Hey man literally deserve more view and likes

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Thank you Saad! Soon :) I just have to continue producing content that people enjoy!

    • @mohammedsaad0761
      @mohammedsaad0761 4 года назад

      @@leighhalliday all the very best ...! leigh

  • @skilleate
    @skilleate 4 года назад

    Excellent tutorial ... very well explained everything ... I had an implementation with the previous library ... that did not work at all well ... with this I have solved my problem ... greetings from México...

    • @leighhalliday
      @leighhalliday  4 года назад

      Nice! Thank you :D Greetings from Toronto!!

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

    Amazing tutorial with thorough and detailed explanation. Is it possible to use create-react-app instead of next.js in your tutorial?

  • @aristotleanderson930
    @aristotleanderson930 4 года назад

    So far, so good man! Ty for doin this.

    • @leighhalliday
      @leighhalliday  4 года назад

      Pleasure is mine, thanks for watching!

    • @aristotleanderson930
      @aristotleanderson930 4 года назад

      @@leighhalliday is axios the server you used? How did you run as a backend server?

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

    thanks a lot
    this gave me a great start

  • @taylord4906
    @taylord4906 4 года назад

    Excellent walk through. Thank you!

    • @leighhalliday
      @leighhalliday  4 года назад

      Thanks Taylor! Glad you enjoyed it :)

  • @prasathsoosaithasan1281
    @prasathsoosaithasan1281 4 года назад

    Thank you sir!! Your content is helping me out so much :) Greetings from Germany!

    • @leighhalliday
      @leighhalliday  4 года назад

      Niiice! Greetings from Canada :) Thanks for saying hi!

  • @mockingdev
    @mockingdev 4 года назад

    you are a life saver.... thanks for this vedio on stripe

  • @alexyep1883
    @alexyep1883 4 года назад

    Excellent, thanks a lot. Pretty straight forward

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Thanks for saying hi, Alex! Yea, not so bad eh?

  • @rileydavidjesus
    @rileydavidjesus 4 года назад

    Pure gold 🪙

  • @jasonma1904
    @jasonma1904 4 года назад

    I learnt a lot from your channel, thank you.

  • @zgheibali
    @zgheibali 3 года назад

    exactly what I wanted, Thank you alottt :D

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

      Nice! You're very welcome!

    • @zgheibali
      @zgheibali 3 года назад

      ​@@leighhalliday i had a challenge to solve, and it required stripe integration :D. it was my first time doing it and you helped me. I received a job offer few days after that and really happy about it and thank you alot again

  • @hadrienjaubert6273
    @hadrienjaubert6273 3 года назад

    Thank you very much for this amazing tutorial ! I was just wandering if you could make some kind of tutorial on Stripe Connect (for instance if we do not want the money to go to a single institution but users paying between themselves) ?

  • @rofazayn
    @rofazayn 4 года назад +1

    Thanks Leigh :D

  • @ivanabregu1
    @ivanabregu1 4 года назад

    Those empanadas look delicious!

  • @robertp3596
    @robertp3596 4 года назад

    The empanadas made me subscribe, oh yeah the good content too!

  • @jairzhino86
    @jairzhino86 4 года назад

    thank you so much for this video, so good.

    • @leighhalliday
      @leighhalliday  4 года назад

      Thanks for saying hi, Gerson! Glad you enjoyed the vid!

  • @carlosjosemoncada9639
    @carlosjosemoncada9639 4 года назад

    Ppl who make stuff like this shouldn't pay taxes. You already contributed enough to society thanks man. Have you used the premade checkout element provided by stripe itself? Is it even easier than this method?

    • @leighhalliday
      @leighhalliday  4 года назад

      Haha... I'll tell the CRA (canada revenue agency) that I didn't pay my taxes because Carlos said it was ok. Hmm... not entirely sure what the premade checkout element is... isn't that what this is?

  • @okanyldrmop
    @okanyldrmop 3 года назад

    Thank you very much!

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

      You're very welcome, Okan! Glad you enjoyed it :)

  • @joshuatuscan
    @joshuatuscan 4 года назад +1

    This was really great and made it pretty straightforward to get a payment form going. My question is, do you have any recommendations for integrating the PaymentRequestButtonElement for Apple Pay into this setup? Getting the element to show up is easy enough, but what to do with the payment Request afterwards in the setup where we have our API for the payment intent has me stumped a bit.

    • @leighhalliday
      @leighhalliday  4 года назад

      Sorry Joshua, this isn't something I've done before... don't have knowledge about it.

  • @gurpreetsaroe5700
    @gurpreetsaroe5700 4 года назад

    Awesome.. Love from India

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Nice! It's cool to have people from all over the world watching these vids!

  • @nlburnr1
    @nlburnr1 4 года назад

    Thank you very much sir

  • @averagetekkenplayer8376
    @averagetekkenplayer8376 4 года назад

    Very good tutorial, do you have or know one for payment subscription as well?

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hey Hassan, thank you! No sorry, I haven't seen/done one yet on subscriptions.

  • @denshou6604
    @denshou6604 3 года назад

    great tutorial thanks you

  • @shh90
    @shh90 4 года назад

    thank you sir

    • @leighhalliday
      @leighhalliday  4 года назад

      Happy to help, Sean! Thanks for saying hi.

  • @mikemarquez2116
    @mikemarquez2116 4 года назад

    stripe terminal js sdk tutorial requested**

    • @leighhalliday
      @leighhalliday  4 года назад

      Hey Mike! I think that's a little too specialized for me right now... unless I had an actual use-case, it's probably not the sort of tech I'd dive into.

  • @Davidgetz1
    @Davidgetz1 4 года назад

    Nice Work =)

  • @amitchauhan3938
    @amitchauhan3938 4 года назад

    Thanks for the wonderful explanation :) but there is one question at 2:15 you told that stripe publishable key should not be on environmental variables like you directly used it but what about us , where we will passing publishable key to get it into react component any help would be greatly appreciated

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hey Amit! Stripe always has 2 keys... the public key, and the secret key. Publish key can be exposed in the client (react), and secret should only ever be on the server. For both keys, it's ideal to avoid committing them into your repository, but instead storing them in environment variables. Next.js just revamped how they do env variables.. check that out here: nextjs.org/docs/basic-features/environment-variables

    • @amitchauhan3938
      @amitchauhan3938 4 года назад

      @@leighhalliday ok I will try to do it in react only and will check .env file explanation in more detail thanks 🥰

  • @harrybanda
    @harrybanda 4 года назад

    Thanks

  • @Sahee122
    @Sahee122 4 года назад

    hey, great turtorial. I see you are using next.js pages/api folder to load backend. Do you know how load backend to gatsby.js?

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hey Marek! I don't believe gatsby has any form of runtime server side code... you'd probably want to take a look into hosting serverless functions somewhere to execute your backend code... if deploying to Netlify, they have: docs.netlify.com/functions/overview/

    • @Sahee122
      @Sahee122 4 года назад

      @@leighhalliday that's what i thought. I didn't try with serverless functions though, thank you :)

  • @jennlagarde
    @jennlagarde 3 года назад

    hello Leigh, your videos are amazing! thank you very much. Do you have any tutorial about "Enable other businesses to accept payments directly" cause I have created an app like Amazon. But I really don't know how to use Stripe with this. My app was created with Symfony5/ApiPlatform/Reactjs. Thanks for you help!

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

      Thank you Jenn!! Sorry, this is actually my only video on Stripe... I should do more in the future!!

    • @jennlagarde
      @jennlagarde 3 года назад

      @@leighhalliday ok thank you for your answer.

  • @RandomRanter
    @RandomRanter 4 года назад

    CardElement isn't working for me :( I wrap it up in Elements with promise. It loads but the style shows the width of 1px and 19px for height...no idea where it's wrong.

    • @RandomRanter
      @RandomRanter 4 года назад

      nevermind. It just doesn't accept styled.div elements probably. I removed that and now it does work.

    • @leighhalliday
      @leighhalliday  4 года назад

      Nice! Glad you were able to figure that out... I don't think I would have guessed that!

  • @mortezatourani7772
    @mortezatourani7772 4 года назад

    handleSubmitCapture takes care of prevent default

  • @malikbrahimi7504
    @malikbrahimi7504 4 года назад

    I'm just kinda confused as to where everything should go. As per the docs, it seems like they're creating payments right in React which I would assume is a bad idea because your build will have a secret key in it. I've seen others do a separate Express/CRA setup and others do SSR with Next.js. Can you clarify and please cite the docs if you can?

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hey Malik! Stripe always has 2 parts: Client side + Server side. On the client side it sends the credit card data to Stripe and they return with a token. On the server side is where you can actually charge money to that token... so you could do the server side part either in a separate express app, or within an API route / page within Next.js since that runs entirely on the server. I wouldn't think about SSR which is all about rendering react server side, but more about the API routes which is what we did in this video.

    • @malikbrahimi7504
      @malikbrahimi7504 4 года назад

      @@leighhalliday Hey Leigh, can you do a fullstack tutorial on concurrency. I've seen multiple resources on Redis or Websockets but the use cases have been really limited to user chat rooms.
      If there are users A and B and A is viewing a detail page while B deletes it, how should your frontend handle that stale page on every client that accesses it. If multiple users edit a resource in close succession how should that be resolved? I'd really appreciate the explanation, especially with deeply relational data.

  • @drumil_patel
    @drumil_patel 4 года назад

    Could you make a tutorial with Stripe 3D Secure?

    • @leighhalliday
      @leighhalliday  4 года назад

      Not immediately, but I'll add it to my list :)

  • @andreisucaciu5485
    @andreisucaciu5485 4 года назад

    If I want to add custom fields like the customer's name and email, will need to change some code in the back-end?

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hey Andrei! Yes, you'll need to send both the stripe token plus any additional data you want to store to the backend.

  • @panoskaf1655
    @panoskaf1655 4 года назад

    what if we want to save customers credentials so he can use them later on and pay without refilling the form again? does this mean that he must have a unique publishable key and if thats the case, how can we produce it?

    • @leighhalliday
      @leighhalliday  4 года назад

      I think if you want to do this you would create a "customer" in Slack... but it's a bit more involved because you would need to store it in a database, and associate it to a user, meaning you'd need authentication too.

    • @panoskaf1655
      @panoskaf1655 4 года назад

      @@leighhalliday yeah i use react native expo and firebase as aunthetication, my question is, what i need to store in database in order to make payments without refilling forms? do i need a unique token or every credential? and one last thing, what should i change in the form in order to run the programm for android emulators

  • @mohammedg485
    @mohammedg485 4 года назад

    thats awesome
    can i do the same with react native ?

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hey Mohammed! I'm sure stripe has a package specific to React Native, but I haven't used it yet... go take a look!

  • @vjp2866
    @vjp2866 3 года назад

    Hey bro, can you do stripe with react-js and django tutorial ?

    • @leighhalliday
      @leighhalliday  3 года назад

      Hey!! I'd love to, but I've never used Django before :D

    • @vjp2866
      @vjp2866 3 года назад

      @@leighhalliday No problem !

  • @Ebizzill
    @Ebizzill 3 года назад

    how do we pass customer information in the api ?

    • @leighhalliday
      @leighhalliday  3 года назад

      Hey Ebizzill! I'm not sure to be honest... you'd have to dig into the docs.

  • @_.sunnyraj._
    @_.sunnyraj._ 4 года назад

    hey how is the charge.js connected to main file mine is not working pllzz help

    • @leighhalliday
      @leighhalliday  4 года назад

      This is an API route in Next.js... you'd connect to it via an HTTP request. More details here: nextjs.org/docs/api-routes/introduction

    • @_.sunnyraj._
      @_.sunnyraj._ 4 года назад

      @@leighhalliday hey that is solved but got
      400 badrequest after clicking on pay

    • @_.sunnyraj._
      @_.sunnyraj._ 4 года назад

      plzzzzzzzz help

  • @joelferrales
    @joelferrales 4 года назад

    Can these same steps be used for Node.js in the back end?

    • @leighhalliday
      @leighhalliday  4 года назад

      The backend I used here was node.js :)

  • @damonwu9658
    @damonwu9658 4 года назад

    Hi Leigh, if possible, would you mind doing a video shot on deploying a stripe + nextjs app (eg: donation page) host on AWS? I am sorry to ask, but if possible, I really wish to learn that part. If not worth, just ignore me. Thank you. BTW, I am your big fan, I watched every single episode. I really love your videos. Great stuff.

    • @leighhalliday
      @leighhalliday  4 года назад +1

      Hey Damon! Sorry, being honest I probably won't tackle how to deploy a nextjs app to AWS... I find AWS the most confusing stuff in the world... am I going straight EC2, am I going on a lightsail server... having to worry about hosting an app is one of my least favourite things of being a developer, which is why I love services like Vercel, Heroku, etc...

    • @damonwu9658
      @damonwu9658 4 года назад

      @@leighhalliday no problem Leigh, and thank you for making these great videos I learnt something new from your videos. Thank you

  • @vjp2866
    @vjp2866 3 года назад

    getting 404 error in axios.post("/api/charge")..... help ?

    • @leighhalliday
      @leighhalliday  3 года назад

      Hey! Double check the naming on the api route file located at `pages/api/charge.js`?

    • @vjp2866
      @vjp2866 3 года назад

      @@leighhalliday This is my working directory,
      frontend---->src--->components----->api--------------------->charge.js

  • @JudeCornish
    @JudeCornish 4 года назад

    Hi Leigh, hate to be picky, but as far as I can see there is no 3D authentication here? Would that be something you would consider covering in the future please? I've been struggling with this for 4 days now and I'm just trying to create a variable amount donation page for a charity im doing front-end web development work for :( Otherwise great video

    • @leighhalliday
      @leighhalliday  4 года назад

      Hey! Ah interesting... I've never worked with this before actually. Didn't realize it was regulation in the EU. stripe.com/docs/payments/3d-secure
      I'll keep it in mind... but I'm not sure when I'll get around to it. I'll do my best!

    • @JudeCornish
      @JudeCornish 4 года назад

      @@leighhalliday Thank you so much! Banging my head against a wall, I'm much more comfortable with react and node js, but can only find solutions in other languages and just losing hope to be honest. I know you can do it with the Stripe Checkout (it comes with that) but Im struggling with implementing that either. Really bummed out. Whenever u get a chance it would be massively appreciated

  • @hayanaaz5061
    @hayanaaz5061 3 года назад

    Getting error !!!!
    Failed to load resource: the server responded with a status of 404 (not found)
    Error: request failed with status code 404
    At createError
    At settle
    At XMLHttpRequest.handleLoad
    I have created src in which I have created 2 files charge.js and payment.js?

    • @hayanaaz5061
      @hayanaaz5061 3 года назад

      Please please suggest solution for this!

    • @leighhalliday
      @leighhalliday  3 года назад

      Hey Haya! Sorry... from the info above I am not actually sure what the problem is!

  • @desarrollomercasy9302
    @desarrollomercasy9302 4 года назад

    In the amount we need to convert? amount * 100 ??? to do the exactly amount?

    • @leighhalliday
      @leighhalliday  4 года назад

      Often to avoid floating point math errors, financial services deal with the lowest common denominator, which in this case is cents. So instead of passing $1, you pass 100 cents.

  • @SoFreshBlaze
    @SoFreshBlaze 4 года назад

    Hey Leigh,
    I seem to be running into 404 error with the axios URL path (I've using direct path such as localhost, just putting /charge but does not work at all). I'm not sure what I need to exactly do to fix it. I pasted my GitHub link to the code below.
    github.com/adamdevelops/TrendyChic/blob/master/src/components/PriceArea.js
    github.com/adamdevelops/TrendyChic/tree/master/src/pages/api

    • @leighhalliday
      @leighhalliday  4 года назад

      Hey SoFreshBlaze! The path may be `/api/charge` since it's in the API folder.

    • @SoFreshBlaze
      @SoFreshBlaze 4 года назад

      @@leighhalliday that didn't seem to work even removing API portion in the link. Im not if this affects it but Ive intially built this in React/Redux and installed Express/Next JS/stripe to setup the API