#bobo00011

1 messages · Page 1 of 1 (latest)

fading shoreBOT
#

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.

empty bloom
#

Hi there see ^

#

Please summarize your issue so I can assist

whole thunder
empty bloom
#

Nope not how this works

#

See above message

whole thunder
#

all things

#

propose from you

#

dont work

#

??

empty bloom
#

Please ask a question

#

Otherwise I'll close the thread

whole thunder
#

why code from docs doesnt work

#

checkout

#

webhook

empty bloom
#

Link the doc you're referring to

#

What's the error you're getting

#

I need info to be able to help you

#

Right now you're just saying vague statements

whole thunder
#

look at link which I attached, I have written 2 times ...

#

error
event = stripe.webhooks.constructEvent(payload, sig, endpointSecret);

empty bloom
#

Still not enough info

#

What is the error you're getting

#

See the message at the top of the thread

#

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.

#

We don't have time to read through all old threads

#

This is a public server and we help many people

#

If you want 1:1 support, you can reach out to Stripe Support team

#

Otherwise, you'll need to play by the rules of this server

whole thunder
#

as

empty bloom
#

what?

whole thunder
#

wait

#

...

#

you have closed my topic every time

#
import { Router } from "express";
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}`);
empty bloom
#

We close threads when the user stops responding

whole thunder
#

error Webhook signature verification failed.

#

error is that I have to pass buffer, not object

#

but I parse

#

using body-parse, AS YOU HAVE IN DOC

empty bloom
#

Ok and what have you tried so far?

whole thunder
#

asf

#

man it doesnt work

#
  let event = request.body;
  // Only verify the event if you have an endpoint secret defined.
  // Otherwise use the basic event deserialized with JSON.parse
  if (endpointSecret) {
    // Get the signature sent by Stripe
    const signature = request.headers['stripe-signature'];
    try {
      event = stripe.webhooks.constructEvent(
        request.body,
        signature,
        endpointSecret
      );
    } catch (err) {
      console.log(`⚠️  Webhook signature verification failed.`, err.message);
      return response.sendStatus(400);
    }
  }```
#

i get error

#

webhook signature veritifaction

#

failed

#

test it and you will see

#

...

#

let event = request.body;
this is object

#

but it shouldnt be

empty bloom
#

you just downloaded the example and ran it directly or you copied code into your project? because it could be some package in your project that's causing the issue

#

I just ran the code and it worked completely fine

#

And use that app as your project base. It works fine for me

whole thunder
#

express.raw({type: 'application/json'})

#

i have still object

empty bloom
#

You'll obviously need to replace the endpointSecret variable though with your endpoint secret

#

Did you do as suggested?

#

Download the sample app rather than copy/paste into your project?

whole thunder
#
app.use(express.urlencoded({extended: true}));```
#

maybe it cause

#

problem

#

but how can I make it

#

?

empty bloom
#

Oh yeah those likely are. Try removing

#

The point of me having you try the quickstart example exactly was to get a version working

#

That's why I suggest using that as a base and running as-is so you know you have a minimal version working

#

Then you can add to that quickstart if need be