#senakaRan

1 messages · Page 1 of 1 (latest)

soft hedgeBOT
glacial wing
#

You're specifically having an issue with signature verification?

short cobalt
#

that is the reason of "TypeError: express.raw is not a function
"?

glacial wing
#

Can you share your code and where this is failing?

#

Also that's a type error

short cobalt
#

const appWebHook = express();

#

/** Payment Webhooks **/
appWebHook.post('/webhook', express.raw({type: 'application/json'}), function(request, response) {
const sig = request.headers['stripe-signature'];

let event;

var secretKey = 'whsec_18522563a10053dfcfd03e9a50a691785629726b208a8320c37cfcb614eb2f99'
try {
console.log('hererererererere------>', request.body, endpointSecret);
event = stripe.webhooks.constructEvent(request.body, sig, secretKey);
} catch (err) {
response.status(400).send(Webhook Error: ${err.message});
return;
}

// Handle the event
switch (event.type) {
    case 'payment_intent.succeeded':
        const paymentIntent = event.data.object;
        console.log(paymentIntent,'paymentIntent');
        // Then define and call a function to handle the event payment_intent.succeeded
        break;
    // ... handle other event types
    case 'payment_intent.created':
        const paymentIntentCreated = event.data.object;
        console.log(paymentIntentCreated,'paymentIntentCreated');
    default:
        console.log(`Unhandled event type ${event.type}`);
}

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

});

#

just copy the script from guid

#

guide

glacial wing
#

You should obscure that webhook secret, and since you revealed it here you should expire it in the dashboard and get a new one

#

What version of express are you using?

short cobalt
#

"express": "~4.17.0",

#

use this

#

now

#

moment

#

let me check security again

#

D:\AAAAries>stripe listen --forward-to localhost:3490/webhook

Ready! You are using Stripe API Version [2020-08-27]. Your webhook signing secret is whsec_18522563a10053dfcfd03e9a50a691785629726b208a8320c37cfcb614eb2f99 (^C to quit)

#

I just got a new one from cmd

#

and tried it with this one

#

same issue

glacial wing
#

SUre, but the TypeError about express.raw is unrelated to your CLI, events, signing secrets etc

short cobalt
#

Thanks

#

I will try again