The best way to control Claude Code, Codex and more from any computer or phone

main
ts 50 lines 1.52 KB
Raw
1 import type {
2 CheckoutSession,
3 CreateCheckoutSessionError,
4 CreateCheckoutSessionRequest,
5 } from "@distilled.cloud/stripe/stripe";
6 import * as Binding from "alchemy/Binding";
7 import type { RuntimeContext } from "alchemy/RuntimeContext";
8 import type * as Effect from "effect/Effect";
9
10 /**
11 * Create a Stripe Checkout Session over HTTP. This is how a Worker starts
12 * a purchase: create the session for a Price, then redirect the buyer to
13 * `session.url`. Stripe hosts the payment page and sends
14 * `checkout.session.completed` when it succeeds.
15 *
16 * Account-scoped — binds the API key onto the host, not a specific
17 * resource.
18 *
19 * ### Starting a subscription checkout
20 * **Example:** Redirect a buyer to hosted Checkout
21 * ```typescript
22 * const createCheckout = yield* Stripe.CreateCheckoutSession();
23 *
24 * // inside a Worker route
25 * const session = yield* createCheckout({
26 * mode: "subscription",
27 * line_items: [{ price: price.id, quantity: 1 }],
28 * customer: customerId,
29 * success_url: `${origin}/welcome`,
30 * cancel_url: `${origin}/pricing`,
31 * });
32 * // redirect to session.url
33 * ```
34 *
35 * @binding
36 * @product Checkout
37 */
38 export interface CreateCheckoutSession extends Binding.Service<
39 CreateCheckoutSession,
40 "Stripe.CreateCheckoutSession",
41 () => Effect.Effect<
42 (
43 request: CreateCheckoutSessionRequest,
44 ) => Effect.Effect<CheckoutSession, CreateCheckoutSessionError, RuntimeContext>
45 >
46 > {}
47
48 export const CreateCheckoutSession = Binding.Service<CreateCheckoutSession>(
49 "Stripe.CreateCheckoutSession",
50 );