为什么我会发现这个错误?
我在这里看到过类似的问题,但它们似乎没有解决我的问题。
错误:未找到与负载的预期签名匹配的签名。您是否正在传递从 Stripe 收到的原始请求正文?https://github.com/stripe/stripe-node#webhook-signing
这是我的 index.ts 删除了键。
import * as functions from 'firebase-functions';
import * as Stripe from 'stripe';
const stripe = new Stripe('sk_test_*****************************');
const endpointSecret = 'whsec_******************************';
import * as express from 'express';
import * as cors from 'cors';
const bodyParser = require('body-parser')
const app = express();
app.use(cors({origin: true}));
app.post('/webhook', bodyParser.raw({type: 'application/json'}), async(req, res) => {
const sig = req.headers['stripe-signature'] as string;
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, endpointSecret);
} catch (err) {
console.log("ERROR!!!1");
console.log(err); …Run Code Online (Sandbox Code Playgroud)