WebhookEndpoint
Source:
src/Stripe/WebhookEndpoint.ts
A Stripe webhook endpoint — the HTTPS destination Stripe POSTs
event payloads to. URL, enabled events, description, disabled, and
metadata update in place. The signing secret is returned only on
create and is stored as Redacted. Deleting the resource deletes
the endpoint.
Creating an endpoint
Section titled “Creating an endpoint”Charge events
const webhook = yield* Stripe.WebhookEndpoint("Charges", { url: "https://example.com/alchemy-stripe-webhook", enabledEvents: ["charge.succeeded", "charge.failed"],});Event classes, for a Worker URL you already have
const webhook = yield* Stripe.WebhookEndpoint("Events", { url: Output.interpolate`${api.url}/webhooks/stripe`, enabledEvents: [Stripe.CustomerCreated, Stripe.InvoicePaid],});yield* Stripe.bindWebhookSecret(api, webhook.secret);On a Worker, prefer consumeEvents — it provisions this endpoint and
binds the secret for you.
Description, metadata, and all events
const webhook = yield* Stripe.WebhookEndpoint("AllEvents", { url: "https://example.com/alchemy-stripe-webhook", enabledEvents: ["*"], description: "Alchemy test webhook", metadata: { purpose: "billing" },});Disabling an endpoint
Section titled “Disabling an endpoint”const webhook = yield* Stripe.WebhookEndpoint("Charges", { url: "https://example.com/alchemy-stripe-webhook", enabledEvents: ["charge.succeeded"], disabled: true,});