#bobo00011

1 messages · Page 1 of 1 (latest)

hidden remnantBOT
#

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.

unkempt elk
#

Let's chat here

#

@plucky robin are you around? what's your question?

plucky robin
#
import stripe from "./payments";
import prisma from "./db";
import bodyParser from "body-parser";

console.log(bodyParser);

const router_webhooks = Router();

/**
 * Webhook Stripe payment
 */
router_webhooks.post("/payments", bodyParser.raw({type: "application/json"}), (req, res, next) => {
    const payload = req.body;
    const sig = req.headers["stripe-signature"];
    let event = null;

    console.log(payload);

    try {
        event = stripe.webhooks.constructEvent(payload, sig, process.env.STRIPE_WEBHOOK_SECRET);
    } catch (err) {
        console.log("Webhook signature verification failed.")
        return res.status(400).send(`Webhook Error: ${err.message}`);```
#

error:

#

Webhook signature verification failed.

unkempt elk
#

What does the complete error say?

plucky robin
#

i have to pass string or buffer

#

not object

#

but I did it as

#

you have in docs

#

and it doesnt work

unkempt elk
#

What did you try? because your code is just parsing the request as json

router_webhooks.post("/payments", bodyParser.raw({type: "application/json"}), (req, res, next) => {

plucky robin
#

i made it as in docs

unkempt elk
#

instead of application/json try setting */*

hidden remnantBOT