The code example does not work when trying to implement with hono and cloudflare workers.
Simulating a checkout session with the stripe cli returns an error:
[wrangler:inf] POST /api/stripe/signature-success 400 Bad Request
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
in index.ts instantiate stripe for all routes and make a stripe success route
app.use("*", async (context, next) => {
// Load the Stripe API key from context.
const { STRIPE_API_KEY: stripeKey } = env(context);
// Instantiate the Stripe client object
const stripe = new Stripe(stripeKey, {
appInfo: {
// For sample support and debugging, not required for production:
name: "stripe-samples/stripe-node-cloudflare-worker-template",
version: "0.0.1",
url: "https://github.com/stripe-samples",
},
maxNetworkRetries: 3,
timeout: 30 * 1000,
});
// Set the Stripe client to the Variable context object
context.set("stripe", stripe);
await next();
});
// The route for the stripe webhook
app.route("/api/stripe/signature-success", stripe_success);
Bug report
Describe the bug
The code example does not work when trying to implement with hono and cloudflare workers. Simulating a checkout session with the
stripe cli
returns an error:To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
index.ts
instantiate stripe for all routes and make a stripe success routestripe/success.ts
Expected behavior
The webhook request verification should verify and return a 200 response when coming from stripe.
Screenshots
System information