Rebasely Beta: data may be purged

examples/storefront Public

TypeScript · 23 lines · 916 B · at e83464e

import { WorkerEntrypoint } from "cloudflare:workers";import type { Charge, Intent, Payments } from "../../../src/payments.ts";import { stripePayments } from "./stripe.ts";import { handleWebhook, type Env } from "./webhook.ts";// What storefront-api calls through its PAYMENTS service binding (entrypoint PaymentsService).// The Stripe secret key never leaves this Worker.export class PaymentsService extends WorkerEntrypoint<Env> implements Payments {  createIntent(charge: Charge): Promise<Intent> {    return stripePayments(this.env.STRIPE_SECRET_KEY).createIntent(charge);  }  cancelIntent(intentId: string): Promise<boolean> {    return stripePayments(this.env.STRIPE_SECRET_KEY).cancelIntent(intentId);  }}// The public side: Stripe's webhook at /stripe/webhook, and nothing else.export default {  fetch(req, env) {    return handleWebhook(req, env);  },} satisfies ExportedHandler<Env>;