#diwakarkashyap

1 messages · Page 1 of 1 (latest)

clear lanceBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

nova belfry
#

hello! how can I help?

agile current
#

i got this error ```Webhook Error: Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the raw request body.Payload was provided as a parsed JavaScript object instead.
Signature verification is impossible without access to the original signed material.
Learn more about webhook signing and explore webhook integration examples for various frameworks at https://github.com/stripe/stripe-node#webhook-signing

nova belfry
#

the error mentions that Webhook payload must be provided as a string or a Buffer....Payload was provided as a parsed JavaScript object instead.

#

that error is because your implementation is providing the webhook payload as a parsed Javascript object in constructEvent

agile current
#
app.post(
    "/webhooks",
    express.raw({ type: "application/json" }),
    (request, response) => {
        const sig = request.headers["stripe-signature"];

        let event;

        try {
            event = stripe.webhooks.constructEvent(
                request.body,
                sig,
                my-key
            );
        } catch (err) {
            response.status(400).send(`Webhook Error: ${err.message}`);
            return;
        }

        // Handle the event
        switch (event.type) {
            case "payment_intent.succeeded":
                const paymentIntentSucceeded = event.data.object;
                // Then define and call a function to handle the event payment_intent.succeeded

                break;
            // ... handle other event types
            default:
                console.log(`Unhandled event type ${event.type}`);
        }

        // Return a 200 response to acknowledge receipt of the event
        response.send();
    }
);
#

i dont get , is anything is wrong in this code ?

nova belfry
#

are you using any other middleware prior to this code snippet? Or parsing the request prior to this route?