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

Поділитися
Вставка
  • Опубліковано 15 жов 2024

КОМЕНТАРІ • 70

  • @teetanrobotics5363
    @teetanrobotics5363 2 роки тому +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.

  • @JulioSCayo
    @JulioSCayo 9 місяців тому

    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 :)

  • @supravatsarkar5866
    @supravatsarkar5866 Рік тому +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 2 роки тому +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.

  • @developedbynick
    @developedbynick 2 роки тому +16

    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.

    • @jacerchetoui709
      @jacerchetoui709 Рік тому

      Thank you so much, you saved me!

    • @bilalahmed4455
      @bilalahmed4455 Рік тому

      @@jacerchetoui709 where? tell me

    • @jeremyacton6378
      @jeremyacton6378 4 місяці тому

      you hero. I've been stuck for hours on this issue. you saved me!

  • @chrisqiuu
    @chrisqiuu Рік тому +1

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

  • @SurajSingh-lu8ei
    @SurajSingh-lu8ei Рік тому +1

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

  • @abrehamtilahun4820
    @abrehamtilahun4820 7 місяців тому +1

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

  • @UddhikaIshara
    @UddhikaIshara Рік тому

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

  • @katrinarossi1381
    @katrinarossi1381 Рік тому

    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 11 місяців тому

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

  • @birdboy4774
    @birdboy4774 2 роки тому +1

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

  • @vishwachandral5576
    @vishwachandral5576 Рік тому +1

    could you please implement a frontend for the user order details

  • @michaelrose1761
    @michaelrose1761 2 місяці тому

    You are good bro. It is helpful thanks.

  • @Kris-to7vh
    @Kris-to7vh Рік тому +2

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

  • @neeraj_minhas
    @neeraj_minhas Рік тому

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

  • @סטיבברוסילובסקי

    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: '*/*' })

  • @umairyatoo8490
    @umairyatoo8490 2 роки тому

    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.

  • @Manuevaral
    @Manuevaral Рік тому +1

    Exactly that's what i wantedddddddd....

  • @vishalsolanki9234
    @vishalsolanki9234 2 роки тому

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

  • @Dhanushsaji
    @Dhanushsaji Рік тому +1

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

    • @devcaand
      @devcaand Рік тому +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.

  • @tutoring-academy
    @tutoring-academy Рік тому

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

  • @lennoxcharles6092
    @lennoxcharles6092 6 місяців тому

    Thanks for the Tutorial Charles

  • @barackouma2552
    @barackouma2552 11 місяців тому

    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

  • @feevah-fvwrldprod8792
    @feevah-fvwrldprod8792 Рік тому

    You are a really good teacher. Thank you❤

  • @josephuzuegbu7431
    @josephuzuegbu7431 Рік тому

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

  • @KristijanStosic
    @KristijanStosic 2 роки тому +1

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

  • @harshiilllll
    @harshiilllll Рік тому +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  Рік тому

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

    • @ChaooCharles
      @ChaooCharles  Рік тому

      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 Рік тому

      @@ChaooCharles cool! i'll check that video

  • @informationhub7199
    @informationhub7199 8 місяців тому

    thanks for your content bro..iam happy and subscribed

  • @ankitanand3324
    @ankitanand3324 Рік тому

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

  • @toothless.tarantula
    @toothless.tarantula Рік тому

    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.

  • @engineermaxwel6732
    @engineermaxwel6732 2 роки тому

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

    • @devcaand
      @devcaand Рік тому

      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

  • @devsuthar6795
    @devsuthar6795 7 місяців тому

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

  • @dharmeshgohil9375
    @dharmeshgohil9375 2 роки тому

    Expecting login using gmail, facebook, Instagram using react

  • @narayanthapa6609
    @narayanthapa6609 2 роки тому

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

    • @ChaooCharles
      @ChaooCharles  2 роки тому

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

  • @Seedley
    @Seedley Рік тому +1

    Can you post the source code?

  • @spacehuru1023
    @spacehuru1023 Рік тому

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

  • @LordR123
    @LordR123 Рік тому

    Someone have idea how to show customers orders?

  • @harshitpahuja7186
    @harshitpahuja7186 Рік тому

    i am getting paymentIntentId null

  • @SonThai-cx6jt
    @SonThai-cx6jt 6 місяців тому

    Thank you so much

  • @alanye7542
    @alanye7542 2 роки тому

    Thank you so much!!!

  • @funnysphere4669
    @funnysphere4669 Рік тому

    Thanks

  • @joeyywill1234
    @joeyywill1234 2 роки тому

    greate video again!

  • @natnael-oqp5082
    @natnael-oqp5082 2 роки тому

    mern stack app with typeScript nextjs graphql

  • @cowboyuniverse7258
    @cowboyuniverse7258 Рік тому

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

  • @big-jo89
    @big-jo89 2 роки тому +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 ....

    • @ChaooCharles
      @ChaooCharles  2 роки тому +1

      Hey, thank you for sharing

    • @big-jo89
      @big-jo89 2 роки тому

      @@ChaooCharles keep up the good work, you're doing great man

    • @DividendCompass
      @DividendCompass Рік тому

      Nice one! This solved it for me, thank you

    • @yaaaayeet745
      @yaaaayeet745 10 місяців тому

      thanks mate!

  • @lucavera4737
    @lucavera4737 Рік тому

    TE AMO

  • @NCS8331
    @NCS8331 8 місяців тому

    Do you all hear any sound?

  • @simmypayyappillyvarghese4801
    @simmypayyappillyvarghese4801 2 роки тому

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