@redwoodjs-stripe/api
Version:
API-side code for RedwoodJS-Stripe projects
28 lines (27 loc) • 603 B
JavaScript
import { mockHttpEvent } from "@redwoodjs/testing/api";
import { stripe } from "./stripe";
const generateStripeMockEvent = () => {
const payload = JSON.stringify(
{
id: "evt_test_webhook",
object: "event"
},
null,
2
);
process.env.STRIPE_WEBHOOK_SK = "whsec_test_secret";
const header = stripe.webhooks.generateTestHeaderString({
payload,
secret: process.env.STRIPE_WEBHOOK_SK
});
const httpEvent = mockHttpEvent({
body: payload,
headers: {
"stripe-signature": header
}
});
return httpEvent;
};
export {
generateStripeMockEvent
};