Creating an order in the database with Stripe webhooks - React and Node.js E-Commerce

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • Watch Part 1 - Stripe Payment: • Stripe Payment Integra...
    Full Course: • Complete Shopping Cart...
    Sections:
    00:00 - intro
    01:08 - install stripe CLI
    05:07 - create webhook endpoint
    15:50 - handling checkout success event
    25:45 - create order model
    31:26 - save order to database
    ✨ Join My Discord Server
    / discord
    Donate 🤑
    📍Donate with PayPal: www.paypal.com/cgi-bin/webscr...
    SUPPORT MY CHANNEL
    📍SUBSCRIBE: / @chaoocharles
    📍Become a Channel Member: / @chaoocharles
    📍Join My Fun Channel: / @chaaoo
    GET IN TOUCH:
    📍 Twitter: / chaoocharles
    Disclaimer: This video is not sponsored
  • Věda a technologie

Komentáře • 70

  • @JulioSCayo
    @JulioSCayo Před 6 měsíci

    Thank you very much bro, I had a lot of questions about how to handle the customers and orders data after the payment but didn't find out anywhere with an explanation of that process, you left it very clear for me :)

  • @chrisqiuu
    @chrisqiuu Před rokem +1

    Thank you again sir! very helpful tutorial, it's a miracle I came right into your videos. You are a great teacher!

  • @teetanrobotics5363
    @teetanrobotics5363 Před 2 lety +7

    bro i see the effort you put in with the terminal, powershell, scoop, etc. I used to do this a long time back. Then I switched to Ubuntu (Linux distro). Trust me life is so much easier and would recommend you too. You won't regret it.

  • @UddhikaIshara
    @UddhikaIshara Před 9 měsíci

    Thank you very much! This was so helpful! Easy to understand! Thank you very much again! ❣

  • @supravatsarkar5866
    @supravatsarkar5866 Před rokem +1

    Thank you so much bro for your effort. I am trying implement stripe payment with webhooks through stripe doc but I not properly understand that in last two day. Now your video clear my concept. ❤from India.

  • @toshitsingh7270
    @toshitsingh7270 Před rokem +1

    Thank you soo much the videos, I was looking for integrating stripe to a website, it helped a lot. Quick tip for viewers it's ok for the tution purpose but in production check the product price in server side.

  • @ankitanand3324
    @ankitanand3324 Před rokem

    Thank you for the content. I hope to see more amazing contents like this.

  • @abrehamtilahun4820
    @abrehamtilahun4820 Před 4 měsíci +1

    Thank you, you help me a lot. please keep going.

  • @feevah-fvwrldprod8792

    You are a really good teacher. Thank you❤

  • @SurajSingh-lu8ei
    @SurajSingh-lu8ei Před rokem +1

    for an entire video I thought my right earphone is gone, then suddenly music played, LOL :)

  • @lennoxcharles6092
    @lennoxcharles6092 Před 4 měsíci

    Thanks for the Tutorial Charles

  • @informationhub7199
    @informationhub7199 Před 6 měsíci

    thanks for your content bro..iam happy and subscribed

  • @michaelrose1761
    @michaelrose1761 Před 9 dny

    You are good bro. It is helpful thanks.

  • @alanye7542
    @alanye7542 Před rokem

    Thank you so much!!!

  • @Manuevaral
    @Manuevaral Před 10 měsíci +1

    Exactly that's what i wantedddddddd....

  • @developedbynick
    @developedbynick Před 2 lety +14

    The error occurred because you placed the route handler after calling a body parsing middleware. So to fix that, just cut it and paste it before calling a body parser.

  • @user-ex8tg3ii5l
    @user-ex8tg3ii5l Před rokem

    Help please I have a problem with constructEvent it shows me an error No signatures found that match the expected signature for the payload. Are you forwarding the raw request body you received from Stripe? And I collected express.raw({ type: '*/*' })

  • @SonThai-cx6jt
    @SonThai-cx6jt Před 3 měsíci

    Thank you so much

  • @joeyywill1234
    @joeyywill1234 Před 2 lety

    greate video again!

  • @vishalsolanki9234
    @vishalsolanki9234 Před rokem

    if my stripe listener not in running mode at the the web hook endpoint run automatically by stripe?

  • @umairyatoo8490
    @umairyatoo8490 Před rokem

    I have to integrate stripe in my application. Apart from the "checkout.session.completed" event, is there any other key event that I must need to handle and could you please elaborate the events a bit more, like which one is a must to handle.

  • @funnysphere4669
    @funnysphere4669 Před 10 měsíci

    Thanks

  • @lucavera4737
    @lucavera4737 Před rokem

    TE AMO

  • @josephuzuegbu7431
    @josephuzuegbu7431 Před rokem

    This is the best tutorial. Can i build a fintech app using stripe apis?

  • @birdboy4774
    @birdboy4774 Před 2 lety +1

    Quick tip you should make your microphone on both left and right channels instead of just the left

  • @neeraj_minhas
    @neeraj_minhas Před 10 měsíci

    Thank you for new earphones , After listening to your video i found one side of it not working , purchased new ❤ thanks

  • @vishwachandral5576
    @vishwachandral5576 Před rokem +1

    could you please implement a frontend for the user order details

  • @barackouma2552
    @barackouma2552 Před 8 měsíci

    you can try modifying this const body = request.rawBody.toString(); instead of parsing the whole request body then call the body in the event function instaed of req.body

  • @toothless.tarantula
    @toothless.tarantula Před rokem

    Nice video, be aware that stripe metadata key value object has per key size limit, could be an issue for large amount of cart items use case.

  • @tutoring-academy
    @tutoring-academy Před rokem

    Hello, Thanks for amazing tutorial. Do you have github link for this project.?

  • @katrinarossi1381
    @katrinarossi1381 Před 9 měsíci

    Thank you for this video! I do have a question- how do we create orders from customers who are not logged in? Then we won't have a userId to pass to create a customer through Stripe. Thanks!

    • @listingmaster15
      @listingmaster15 Před 8 měsíci

      So before checkout redirect user to login page so then you will always have user I'd

  • @dharmeshgohil9375
    @dharmeshgohil9375 Před 2 lety

    Expecting login using gmail, facebook, Instagram using react

  • @harshiilllll
    @harshiilllll Před rokem +1

    i get error if i add multiple products in my cart, error is that we can not add more than 500 characters in metadata, how do i handle that?

    • @ChaooCharles
      @ChaooCharles  Před rokem

      Hey, proceed with the course the solutions to metadata I included in the React Dashboard video..

    • @ChaooCharles
      @ChaooCharles  Před rokem

      Currently you can set the cart to be an empty array and order model at products you set it to just array without specifying the properties..

    • @harshiilllll
      @harshiilllll Před rokem

      @@ChaooCharles cool! i'll check that video

  • @LordR123
    @LordR123 Před rokem

    Someone have idea how to show customers orders?

  • @Dhanushsaji
    @Dhanushsaji Před rokem +1

    The size of the metadata is a problem..do you have any alternatives?

    • @devcaand
      @devcaand Před rokem +1

      You can create a pending transaction on your backend, you need to specify transaction 'id' it could be uuid() and pass as many items as you want in there, really the limit at this point is your db. Then, you pass that 'transaction id' into your payment intent as metadata. When you receive your webhook with "checkout.session.completed", you parse that metadata and grab your transaction id from it. Then, run a function to update that transaction on your backend from pending to success. Likewise in case of error, you can delete that transaction or write a script which will be deleting all pending transactions once they are 1day old or something.
      That way you can avoid transferring cart items back and forth and dealing with 500 character limit.

  • @Seedley
    @Seedley Před rokem +1

    Can you post the source code?

  • @natnael-oqp5082
    @natnael-oqp5082 Před 2 lety

    mern stack app with typeScript nextjs graphql

  • @narayanthapa6609
    @narayanthapa6609 Před rokem

    it throws error when i pass cartItems inside metadata while creating a customer.

    • @ChaooCharles
      @ChaooCharles  Před rokem

      Yeah, pass an empty array.. in the next videos we are using an alternative

  • @engineermaxwel6732
    @engineermaxwel6732 Před 2 lety

    I have question this endpoint secret in webhook should be inside .env or its okay

    • @devcaand
      @devcaand Před rokem

      if you deploying it live then better to keep it in the env. If you just playing around in your sandbox, do whatever you want

  • @harshitpahuja7186
    @harshitpahuja7186 Před rokem

    i am getting paymentIntentId null

  • @spacehuru1023
    @spacehuru1023 Před rokem

    is there a way to collect global payments from Kenya as we cannot access stripe here?

  • @cowboyuniverse7258
    @cowboyuniverse7258 Před rokem

    Do you not see? Read it “For local dev” …

  • @NCS8331
    @NCS8331 Před 5 měsíci

    Do you all hear any sound?

  • @Kris-to7vh
    @Kris-to7vh Před 11 měsíci +2

    15:20 I was able to verify the endpoint by adding these lines:
    app.use('/api/stripe/webhook', express.raw({ type: 'application/json' })); //

  • @devsuthar6795
    @devsuthar6795 Před 4 měsíci

    bro Thank you so much... Very good Detailed video and Easy To Understand 🫡

  • @KristijanStosic
    @KristijanStosic Před 2 lety

    Hi, I need some help with stripe payment, can I contact you privately somehow?

  • @big-jo89
    @big-jo89 Před 2 lety +9

    about the Webhook error i found this to be working for me :
    const payload = req.body;
    const payloadString = JSON.stringify(payload, null, 2);
    const header = stripe.webhooks.generateTestHeaderString({
    payload: payloadString,
    secret: ENDPOINT_SECRET as string,
    });
    let event;
    try {
    event = stripe.webhooks.constructEvent(payloadString, header, ENDPOINT_SECRET as string);
    console.log(`Webhook Verified: `, event);
    } catch (err) {
    console.log(`Webhook Error: ${(err as Error).message}`);
    res.status(400).send(`Webhook Error: ${(err as Error).message}`);
    return;
    }
    // Handle event types ....

  • @simmypayyappillyvarghese4801

    I got the issue resolved by using the middleware app.use('/webhook', express.raw({type: '*/*'})) and removed the middleware from the post router