@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 88 lines 3.06 KB
Raw
1 /**
2 * Stripe webhook event classes. Each class is both the subscribe key
3 * (`events: [CustomerCreated]`) and the value the handler receives.
4 */
5 import type {
6 Account,
7 CheckoutSession,
8 Customer,
9 Invoice,
10 PaymentIntent,
11 Subscription,
12 } from "@distilled.cloud/stripe/stripe";
13
14 export interface StripeEventClass<Type extends string = string, Object = unknown> {
15 readonly type: Type;
16 new (object: any): StripeEventInstance<Type, Object>;
17 }
18
19 export interface StripeEventInstance<Type extends string = string, Object = unknown> {
20 readonly type: Type;
21 readonly object: Object;
22 }
23
24 export class CustomerCreated {
25 static readonly type = "customer.created" as const;
26 readonly type = "customer.created" as const;
27 constructor(readonly object: Customer) {}
28 }
29 export class CustomerUpdated {
30 static readonly type = "customer.updated" as const;
31 readonly type = "customer.updated" as const;
32 constructor(readonly object: Customer) {}
33 }
34 export class CustomerDeleted {
35 static readonly type = "customer.deleted" as const;
36 readonly type = "customer.deleted" as const;
37 constructor(readonly object: Customer) {}
38 }
39 export class InvoicePaid {
40 static readonly type = "invoice.paid" as const;
41 readonly type = "invoice.paid" as const;
42 constructor(readonly object: Invoice) {}
43 }
44 export class InvoicePaymentFailed {
45 static readonly type = "invoice.payment_failed" as const;
46 readonly type = "invoice.payment_failed" as const;
47 constructor(readonly object: Invoice) {}
48 }
49 export class CheckoutSessionCompleted {
50 static readonly type = "checkout.session.completed" as const;
51 readonly type = "checkout.session.completed" as const;
52 constructor(readonly object: CheckoutSession) {}
53 }
54 export class PaymentIntentSucceeded {
55 static readonly type = "payment_intent.succeeded" as const;
56 readonly type = "payment_intent.succeeded" as const;
57 constructor(readonly object: PaymentIntent) {}
58 }
59 export class PaymentIntentFailed {
60 static readonly type = "payment_intent.payment_failed" as const;
61 readonly type = "payment_intent.payment_failed" as const;
62 constructor(readonly object: PaymentIntent) {}
63 }
64 export class CustomerSubscriptionCreated {
65 static readonly type = "customer.subscription.created" as const;
66 readonly type = "customer.subscription.created" as const;
67 constructor(readonly object: Subscription) {}
68 }
69 export class CustomerSubscriptionUpdated {
70 static readonly type = "customer.subscription.updated" as const;
71 readonly type = "customer.subscription.updated" as const;
72 constructor(readonly object: Subscription) {}
73 }
74 export class CustomerSubscriptionDeleted {
75 static readonly type = "customer.subscription.deleted" as const;
76 readonly type = "customer.subscription.deleted" as const;
77 constructor(readonly object: Subscription) {}
78 }
79 /**
80 * Fires whenever a Connect account changes — most usefully when a merchant
81 * finishes hosted onboarding and `charges_enabled` / `payouts_enabled`
82 * flip to `true`.
83 */
84 export class AccountUpdated {
85 static readonly type = "account.updated" as const;
86 readonly type = "account.updated" as const;
87 constructor(readonly object: Account) {}
88 }