Skip to content

Stripe.Webhook reference

Source: src/Stripe/ConsumeEvents.ts Kind: Layer · Provides: Stripe.EventSource

Cloudflare Worker implementation of consumeEvents.

Deploy-time: provisions a WebhookEndpoint pointing at this Worker (at the subscribed path) and binds its minted signing secret onto the Worker so deliveries can be verified. Runtime: registers a fetch listener that claims requests on that path, verifies Stripe-Signature, and runs the handler once per event.

Source: src/Stripe/RetrieveWebhookEndpoint.ts

Retrieve a bound Stripe Webhook Endpoint over HTTP.

RetrieveWebhookEndpoint: Reading a Webhook Endpoint

Section titled “RetrieveWebhookEndpoint: Reading a Webhook Endpoint”
const retrieve = yield* Stripe.RetrieveWebhookEndpoint(hook);
const live = yield* retrieve();

Source: src/Stripe/RetrieveWebhookEndpointHttp.ts Kind: Layer · Provides: Stripe.RetrieveWebhookEndpoint

HTTP implementation of RetrieveWebhookEndpoint. Provide it on the Function or Worker Effect.

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.

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" },
});
const webhook = yield* Stripe.WebhookEndpoint("Charges", {
url: "https://example.com/alchemy-stripe-webhook",
enabledEvents: ["charge.succeeded"],
disabled: true,
});