@faire-auth/stripe 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1005 @@
1
+ import { ContextVars, InferOptionSchema } from "faire-auth";
2
+ import Stripe from "stripe";
3
+ import * as z from "zod";
4
+ import { Session, User } from "faire-auth/db";
5
+ import { Context } from "@faire-auth/core/types";
6
+ declare const subscriptions: {
7
+ subscription: {
8
+ fields: {
9
+ plan: {
10
+ type: "string";
11
+ required: true;
12
+ };
13
+ referenceId: {
14
+ type: "string";
15
+ required: true;
16
+ };
17
+ stripeCustomerId: {
18
+ type: "string";
19
+ required: false;
20
+ };
21
+ stripeSubscriptionId: {
22
+ type: "string";
23
+ required: false;
24
+ };
25
+ status: {
26
+ type: "string";
27
+ defaultValue: string;
28
+ };
29
+ periodStart: {
30
+ type: "date";
31
+ required: false;
32
+ };
33
+ periodEnd: {
34
+ type: "date";
35
+ required: false;
36
+ };
37
+ trialStart: {
38
+ type: "date";
39
+ required: false;
40
+ };
41
+ trialEnd: {
42
+ type: "date";
43
+ required: false;
44
+ };
45
+ cancelAtPeriodEnd: {
46
+ type: "boolean";
47
+ required: false;
48
+ defaultValue: false;
49
+ };
50
+ seats: {
51
+ type: "number";
52
+ required: false;
53
+ };
54
+ };
55
+ };
56
+ };
57
+ declare const user: {
58
+ user: {
59
+ fields: {
60
+ stripeCustomerId: {
61
+ type: "string";
62
+ required: false;
63
+ };
64
+ };
65
+ };
66
+ };
67
+ type StripePlan = {
68
+ /**
69
+ * Monthly price id
70
+ */
71
+ priceId?: string;
72
+ /**
73
+ * To use lookup key instead of price id
74
+ *
75
+ * https://docs.stripe.com/products-prices/
76
+ * manage-prices#lookup-keys
77
+ */
78
+ lookupKey?: string;
79
+ /**
80
+ * A yearly discount price id
81
+ *
82
+ * useful when you want to offer a discount for
83
+ * yearly subscription
84
+ */
85
+ annualDiscountPriceId?: string;
86
+ /**
87
+ * To use lookup key instead of price id
88
+ *
89
+ * https://docs.stripe.com/products-prices/
90
+ * manage-prices#lookup-keys
91
+ */
92
+ annualDiscountLookupKey?: string;
93
+ /**
94
+ * Plan name
95
+ */
96
+ name: string;
97
+ /**
98
+ * Limits for the plan
99
+ */
100
+ limits?: Record<string, number>;
101
+ /**
102
+ * Plan group name
103
+ *
104
+ * useful when you want to group plans or
105
+ * when a user can subscribe to multiple plans.
106
+ */
107
+ group?: string;
108
+ /**
109
+ * Free trial days
110
+ */
111
+ freeTrial?: {
112
+ /**
113
+ * Number of days
114
+ */
115
+ days: number;
116
+ /**
117
+ * A function that will be called when the trial
118
+ * starts.
119
+ *
120
+ * @param subscription
121
+ * @returns
122
+ */
123
+ onTrialStart?: (subscription: Subscription) => Promise<void>;
124
+ /**
125
+ * A function that will be called when the trial
126
+ * ends
127
+ *
128
+ * @param subscription - Subscription
129
+ * @returns
130
+ */
131
+ onTrialEnd?: <V extends object>(data: {
132
+ subscription: Subscription;
133
+ }, ctx: Context<ContextVars<V>>) => Promise<void>;
134
+ /**
135
+ * A function that will be called when the trial
136
+ * expired.
137
+ * @param subscription - Subscription
138
+ * @returns
139
+ */
140
+ onTrialExpired?: <V extends object>(subscription: Subscription, ctx: Context<ContextVars<V>>) => Promise<void>;
141
+ };
142
+ };
143
+ interface Subscription {
144
+ /**
145
+ * Database identifier
146
+ */
147
+ id: string;
148
+ /**
149
+ * The plan name
150
+ */
151
+ plan: string;
152
+ /**
153
+ * Stripe customer id
154
+ */
155
+ stripeCustomerId?: string;
156
+ /**
157
+ * Stripe subscription id
158
+ */
159
+ stripeSubscriptionId?: string;
160
+ /**
161
+ * Trial start date
162
+ */
163
+ trialStart?: Date;
164
+ /**
165
+ * Trial end date
166
+ */
167
+ trialEnd?: Date;
168
+ /**
169
+ * Price Id for the subscription
170
+ */
171
+ priceId?: string;
172
+ /**
173
+ * To what reference id the subscription belongs to
174
+ * @example
175
+ * - userId for a user
176
+ * - workspace id for a saas platform
177
+ * - website id for a hosting platform
178
+ *
179
+ * @default - userId
180
+ */
181
+ referenceId: string;
182
+ /**
183
+ * Subscription status
184
+ */
185
+ status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "trialing" | "unpaid";
186
+ /**
187
+ * The billing cycle start date
188
+ */
189
+ periodStart?: Date;
190
+ /**
191
+ * The billing cycle end date
192
+ */
193
+ periodEnd?: Date;
194
+ /**
195
+ * Whether this subscription will (if status=active)
196
+ * or did (if status=canceled) cancel at the end of the current billing period.
197
+ */
198
+ cancelAtPeriodEnd?: boolean;
199
+ /**
200
+ * If the subscription is scheduled to be canceled,
201
+ * this is the time at which the cancellation will take effect.
202
+ */
203
+ cancelAt?: Date;
204
+ /**
205
+ * If the subscription has been canceled, this is the time when it was canceled.
206
+ *
207
+ * Note: If the subscription was canceled with `cancel_at_period_end`,
208
+ * this reflects the cancellation request time, not when the subscription actually ends.
209
+ */
210
+ canceledAt?: Date;
211
+ /**
212
+ * If the subscription has ended, the date the subscription ended.
213
+ */
214
+ endedAt?: Date;
215
+ /**
216
+ * A field to group subscriptions so you can have multiple subscriptions
217
+ * for one reference id
218
+ */
219
+ groupId?: string;
220
+ /**
221
+ * Number of seats for the subscription (useful for team plans)
222
+ */
223
+ seats?: number;
224
+ }
225
+ interface SubscriptionOptions {
226
+ enabled: boolean;
227
+ /**
228
+ * Subscription Configuration
229
+ */
230
+ /**
231
+ * List of plan
232
+ */
233
+ plans: StripePlan[] | (() => StripePlan[] | Promise<StripePlan[]>);
234
+ /**
235
+ * Require email verification before a user is allowed to upgrade
236
+ * their subscriptions
237
+ *
238
+ * @default false
239
+ */
240
+ requireEmailVerification?: boolean;
241
+ /**
242
+ * A callback to run after a user has subscribed to a package
243
+ * @param event - Stripe Event
244
+ * @param subscription - Subscription Data
245
+ * @returns
246
+ */
247
+ onSubscriptionComplete?: <V extends object>(data: {
248
+ event: Stripe.Event;
249
+ stripeSubscription: Stripe.Subscription;
250
+ subscription: Subscription;
251
+ plan: StripePlan;
252
+ }, ctx: Context<ContextVars<V>>) => Promise<void>;
253
+ /**
254
+ * A callback to run after a user is about to cancel their subscription
255
+ * @returns
256
+ */
257
+ onSubscriptionUpdate?: (data: {
258
+ event: Stripe.Event;
259
+ subscription: Subscription;
260
+ }) => Promise<void>;
261
+ /**
262
+ * A callback to run after a user is about to cancel their subscription
263
+ * @returns
264
+ */
265
+ onSubscriptionCancel?: (data: {
266
+ event?: Stripe.Event | undefined;
267
+ subscription: Subscription;
268
+ stripeSubscription: Stripe.Subscription;
269
+ cancellationDetails?: Stripe.Subscription.CancellationDetails | null;
270
+ }) => Promise<void>;
271
+ /**
272
+ * A function to check if the reference id is valid
273
+ * and belongs to the user
274
+ *
275
+ * @param data - data containing user, session and referenceId
276
+ * @param ctx - the context object
277
+ * @returns
278
+ */
279
+ authorizeReference?: <V extends object>(data: {
280
+ user: User;
281
+ session: Session;
282
+ referenceId: string;
283
+ action: "upgrade-subscription" | "list-subscription" | "cancel-subscription" | "restore-subscription" | "billing-portal";
284
+ }, ctx: Context<ContextVars<V>>) => Promise<boolean>;
285
+ /**
286
+ * A callback to run after a user has deleted their subscription
287
+ * @returns
288
+ */
289
+ onSubscriptionDeleted?: (data: {
290
+ event: Stripe.Event;
291
+ stripeSubscription: Stripe.Subscription;
292
+ subscription: Subscription;
293
+ }) => Promise<void>;
294
+ /**
295
+ * parameters for session create params
296
+ *
297
+ * @param data - data containing user, session and plan
298
+ * @param ctx - the context object
299
+ */
300
+ getCheckoutSessionParams?: <V extends object>(data: {
301
+ user: User;
302
+ session: Session;
303
+ plan: StripePlan;
304
+ subscription: Subscription;
305
+ }, ctx: Context<ContextVars<V>>) => Promise<{
306
+ params?: Stripe.Checkout.SessionCreateParams;
307
+ options?: Stripe.RequestOptions;
308
+ }> | {
309
+ params?: Stripe.Checkout.SessionCreateParams;
310
+ options?: Stripe.RequestOptions;
311
+ };
312
+ /**
313
+ * Enable organization subscription
314
+ */
315
+ organization?: {
316
+ enabled: boolean;
317
+ };
318
+ }
319
+ interface StripeOptions {
320
+ /**
321
+ * Stripe Client
322
+ */
323
+ stripeClient: Stripe;
324
+ /**
325
+ * Stripe Webhook Secret
326
+ *
327
+ * @description Stripe webhook secret key
328
+ */
329
+ stripeWebhookSecret: string;
330
+ /**
331
+ * Enable customer creation when a user signs up
332
+ */
333
+ createCustomerOnSignUp?: boolean;
334
+ /**
335
+ * A callback to run after a customer has been created
336
+ * @param customer - Customer Data
337
+ * @param stripeCustomer - Stripe Customer Data
338
+ * @returns
339
+ */
340
+ onCustomerCreate?: <V extends object>(data: {
341
+ stripeCustomer: Stripe.Customer;
342
+ user: User;
343
+ }, ctx: Context<ContextVars<V>>) => Promise<void>;
344
+ /**
345
+ * A custom function to get the customer create
346
+ * params
347
+ * @param data - data containing user and session
348
+ * @returns
349
+ */
350
+ getCustomerCreateParams?: <V extends object>(data: {
351
+ user: User;
352
+ session: Session;
353
+ }, ctx: Context<ContextVars<V>>) => Promise<{}>;
354
+ /**
355
+ * Subscriptions
356
+ */
357
+ subscription?: {
358
+ enabled: false;
359
+ } | ({
360
+ enabled: true;
361
+ } & SubscriptionOptions);
362
+ /**
363
+ * A callback to run after a stripe event is received
364
+ * @param event - Stripe Event
365
+ * @returns
366
+ */
367
+ onEvent?: (event: Stripe.Event) => Promise<void>;
368
+ /**
369
+ * Schema for the stripe plugin
370
+ */
371
+ schema?: InferOptionSchema<typeof subscriptions & typeof user>;
372
+ }
373
+ declare const stripe: <O extends StripeOptions>(options: O) => {
374
+ id: "stripe";
375
+ routes: {
376
+ stripeWebhook: import("faire-auth").AuthEndpoint<{
377
+ getRoutingPath: () => "/stripe/webhook";
378
+ operationId: "stripeWebhook";
379
+ method: "post";
380
+ path: "/stripe/webhook";
381
+ client: false;
382
+ responses: {
383
+ 200: {
384
+ description: string;
385
+ content: {
386
+ "application/json": {
387
+ schema: z.ZodObject<{
388
+ success: z.ZodLiteral<true>;
389
+ }, z.core.$strip>;
390
+ };
391
+ };
392
+ };
393
+ } & {
394
+ 400: {
395
+ description: string;
396
+ content: {
397
+ "application/json": {
398
+ schema: z.core.$ZodBranded<z.ZodObject<{
399
+ success: z.ZodLiteral<false>;
400
+ code: z.ZodOptional<z.ZodString>;
401
+ message: z.ZodOptional<z.ZodString>;
402
+ }, z.core.$strip>, "error", "out">;
403
+ };
404
+ };
405
+ };
406
+ } & {
407
+ 500: {
408
+ description: string;
409
+ content: {
410
+ "application/json": {
411
+ schema: z.core.$ZodBranded<z.ZodObject<{
412
+ success: z.ZodLiteral<false>;
413
+ code: z.ZodOptional<z.ZodString>;
414
+ message: z.ZodOptional<z.ZodString>;
415
+ }, z.core.$strip>, "error", "out">;
416
+ };
417
+ };
418
+ };
419
+ };
420
+ }>;
421
+ } & (O["subscription"] extends {
422
+ enabled: boolean;
423
+ } ? {
424
+ /**
425
+ * ### Endpoint
426
+ *
427
+ * POST `/subscription/upgrade`
428
+ *
429
+ * ### API Methods
430
+ *
431
+ * **server:**
432
+ * `auth.api.upgradeSubscription`
433
+ *
434
+ * **client:**
435
+ * `authClient.subscription.upgrade`
436
+ *
437
+ * @see [Read our docs to learn more.](https://faire-auth.com/docs/plugins/stripe#api-method-subscription-upgrade)
438
+ */
439
+ readonly upgradeSubscription: import("faire-auth").AuthEndpoint<{
440
+ getRoutingPath: () => "/subscription/upgrade";
441
+ operationId: "upgradeSubscription";
442
+ method: "post";
443
+ path: "/subscription/upgrade";
444
+ middleware: [(ctx: import("hono").Context<import("faire-auth").ContextVars<{
445
+ session: {
446
+ user: {
447
+ stripeCustomerId?: string;
448
+ };
449
+ };
450
+ } & {
451
+ session: {
452
+ session: Session;
453
+ user: User;
454
+ };
455
+ }>, string, {}>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
456
+ success: false;
457
+ code?: string | undefined;
458
+ message?: string | undefined;
459
+ }, 401>)>, (ctx: import("hono").Context<import("faire-auth").ContextVars<object>, string, {}>, next: import("hono").Next) => Promise<void | Response>, (ctx: import("hono").Context<import("faire-auth").ContextVars<{
460
+ session?: {
461
+ session: Session;
462
+ user: User;
463
+ };
464
+ }>, "/subscription/billing-portal" | "/subscription/cancel" | "/subscription/list" | "/subscription/restore" | "/subscription/upgrade", {
465
+ out: {
466
+ json: {
467
+ referenceId?: string;
468
+ };
469
+ query: {
470
+ referenceId?: string;
471
+ };
472
+ };
473
+ }>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
474
+ success: false;
475
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
476
+ success: false;
477
+ }, 400, "json">)>];
478
+ request: {
479
+ body: {
480
+ description?: string;
481
+ content: {
482
+ "application/json": {
483
+ schema: z.ZodObject<{
484
+ plan: z.ZodString;
485
+ annual: z.ZodOptional<z.ZodBoolean>;
486
+ referenceId: z.ZodOptional<z.ZodString>;
487
+ subscriptionId: z.ZodOptional<z.ZodString>;
488
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
489
+ seats: z.ZodOptional<z.ZodNumber>;
490
+ successUrl: z.ZodDefault<z.ZodString>;
491
+ cancelUrl: z.ZodDefault<z.ZodString>;
492
+ returnUrl: z.ZodOptional<z.ZodString>;
493
+ disableRedirect: z.ZodDefault<z.ZodBoolean>;
494
+ }, z.core.$strip>;
495
+ };
496
+ };
497
+ required: true;
498
+ };
499
+ };
500
+ responses: {
501
+ 200: {
502
+ description: string;
503
+ content: {
504
+ "application/json": {
505
+ schema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.ZodObject<{
506
+ redirect: z.ZodLiteral<false>;
507
+ url: z.ZodDefault<z.ZodNull>;
508
+ }, z.core.$strip>, z.ZodObject<{
509
+ redirect: z.ZodLiteral<true>;
510
+ url: z.ZodURL;
511
+ }, z.core.$strip>], "redirect">, z.ZodType<Partial<Stripe.Checkout.Session>, Partial<Stripe.Checkout.Session>, z.core.$ZodTypeInternals<Partial<Stripe.Checkout.Session>, Partial<Stripe.Checkout.Session>>>>;
512
+ };
513
+ };
514
+ };
515
+ } & {
516
+ 400: {
517
+ description: string;
518
+ content: {
519
+ "application/json": {
520
+ schema: z.core.$ZodBranded<z.ZodObject<{
521
+ success: z.ZodLiteral<false>;
522
+ code: z.ZodOptional<z.ZodString>;
523
+ message: z.ZodOptional<z.ZodString>;
524
+ }, z.core.$strip>, "error", "out">;
525
+ };
526
+ };
527
+ };
528
+ } & {
529
+ 401: {
530
+ description: string;
531
+ content: {
532
+ "application/json": {
533
+ schema: z.core.$ZodBranded<z.ZodObject<{
534
+ success: z.ZodLiteral<false>;
535
+ code: z.ZodOptional<z.ZodString>;
536
+ message: z.ZodOptional<z.ZodString>;
537
+ }, z.core.$strip>, "error", "out">;
538
+ };
539
+ };
540
+ };
541
+ } & {
542
+ 500: {
543
+ description: string;
544
+ content: {
545
+ "application/json": {
546
+ schema: z.core.$ZodBranded<z.ZodObject<{
547
+ success: z.ZodLiteral<false>;
548
+ code: z.ZodOptional<z.ZodString>;
549
+ message: z.ZodOptional<z.ZodString>;
550
+ }, z.core.$strip>, "error", "out">;
551
+ };
552
+ };
553
+ };
554
+ };
555
+ }>;
556
+ readonly cancelSubscriptionCallback: import("faire-auth").AuthEndpoint<{
557
+ getRoutingPath: () => "/subscription/cancel/callback";
558
+ operationId: "cancelSubscriptionCallback";
559
+ method: "get";
560
+ path: "/subscription/cancel/callback";
561
+ middleware: [(ctx: import("hono").Context<import("faire-auth").ContextVars<object>, string, {}>, next: import("hono").Next) => Promise<void | Response>];
562
+ request: {
563
+ query: z.ZodObject<{
564
+ callbackURL: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodTransform<string | undefined, string | undefined>, z.ZodOptional<z.ZodURL>>, z.ZodTransform<string | undefined, string | undefined>>>;
565
+ subscriptionId: z.ZodOptional<z.ZodString>;
566
+ }, z.core.$strip>;
567
+ };
568
+ responses: {
569
+ 200: {
570
+ description: string;
571
+ content: {
572
+ "application/json": {
573
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
574
+ };
575
+ };
576
+ };
577
+ } & {
578
+ 302: {
579
+ description: string;
580
+ };
581
+ };
582
+ }>;
583
+ /**
584
+ * ### Endpoint
585
+ *
586
+ * POST `/subscription/cancel`
587
+ *
588
+ * ### API Methods
589
+ *
590
+ * **server:**
591
+ * `auth.api.cancelSubscription`
592
+ *
593
+ * **client:**
594
+ * `authClient.subscription.cancel`
595
+ *
596
+ * @see [Read our docs to learn more.](https://faire-auth.com/docs/plugins/stripe#api-method-subscription-cancel)
597
+ */
598
+ readonly cancelSubscription: import("faire-auth").AuthEndpoint<{
599
+ getRoutingPath: () => "/subscription/cancel";
600
+ operationId: "cancelSubscription";
601
+ method: "post";
602
+ path: "/subscription/cancel";
603
+ middleware: [(ctx: import("hono").Context<import("faire-auth").ContextVars<object & {
604
+ session: {
605
+ session: Session;
606
+ user: User;
607
+ };
608
+ }>, string, {}>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
609
+ success: false;
610
+ code?: string | undefined;
611
+ message?: string | undefined;
612
+ }, 401>)>, (ctx: import("hono").Context<import("faire-auth").ContextVars<object>, string, {}>, next: import("hono").Next) => Promise<void | Response>, (ctx: import("hono").Context<import("faire-auth").ContextVars<{
613
+ session?: {
614
+ session: Session;
615
+ user: User;
616
+ };
617
+ }>, "/subscription/billing-portal" | "/subscription/cancel" | "/subscription/list" | "/subscription/restore" | "/subscription/upgrade", {
618
+ out: {
619
+ json: {
620
+ referenceId?: string;
621
+ };
622
+ query: {
623
+ referenceId?: string;
624
+ };
625
+ };
626
+ }>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
627
+ success: false;
628
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
629
+ success: false;
630
+ }, 400, "json">)>];
631
+ request: {
632
+ body: {
633
+ description?: string;
634
+ content: {
635
+ "application/json": {
636
+ schema: z.ZodObject<{
637
+ referenceId: z.ZodOptional<z.ZodString>;
638
+ subscriptionId: z.ZodOptional<z.ZodString>;
639
+ returnUrl: z.ZodString;
640
+ }, z.core.$strip>;
641
+ };
642
+ };
643
+ required: true;
644
+ };
645
+ };
646
+ responses: {
647
+ 200: {
648
+ description: string;
649
+ content: {
650
+ "application/json": {
651
+ schema: z.ZodObject<{
652
+ url: z.ZodString;
653
+ redirect: z.ZodLiteral<true>;
654
+ }, z.core.$strip>;
655
+ };
656
+ };
657
+ };
658
+ } & {
659
+ 400: {
660
+ description: string;
661
+ content: {
662
+ "application/json": {
663
+ schema: z.core.$ZodBranded<z.ZodObject<{
664
+ success: z.ZodLiteral<false>;
665
+ code: z.ZodOptional<z.ZodString>;
666
+ message: z.ZodOptional<z.ZodString>;
667
+ }, z.core.$strip>, "error", "out">;
668
+ };
669
+ };
670
+ };
671
+ } & {
672
+ 401: {
673
+ description: string;
674
+ content: {
675
+ "application/json": {
676
+ schema: z.core.$ZodBranded<z.ZodObject<{
677
+ success: z.ZodLiteral<false>;
678
+ code: z.ZodOptional<z.ZodString>;
679
+ message: z.ZodOptional<z.ZodString>;
680
+ }, z.core.$strip>, "error", "out">;
681
+ };
682
+ };
683
+ };
684
+ };
685
+ }>;
686
+ readonly restoreSubscription: import("faire-auth").AuthEndpoint<{
687
+ getRoutingPath: () => "/subscription/restore";
688
+ operationId: "restoreSubscription";
689
+ method: "post";
690
+ path: "/subscription/restore";
691
+ middleware: [(ctx: import("hono").Context<import("faire-auth").ContextVars<object & {
692
+ session: {
693
+ session: Session;
694
+ user: User;
695
+ };
696
+ }>, string, {}>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
697
+ success: false;
698
+ code?: string | undefined;
699
+ message?: string | undefined;
700
+ }, 401>)>, (ctx: import("hono").Context<import("faire-auth").ContextVars<{
701
+ session?: {
702
+ session: Session;
703
+ user: User;
704
+ };
705
+ }>, "/subscription/billing-portal" | "/subscription/cancel" | "/subscription/list" | "/subscription/restore" | "/subscription/upgrade", {
706
+ out: {
707
+ json: {
708
+ referenceId?: string;
709
+ };
710
+ query: {
711
+ referenceId?: string;
712
+ };
713
+ };
714
+ }>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
715
+ success: false;
716
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
717
+ success: false;
718
+ }, 400, "json">)>];
719
+ request: {
720
+ body: {
721
+ description?: string;
722
+ content: {
723
+ "application/json": {
724
+ schema: z.ZodObject<{
725
+ referenceId: z.ZodOptional<z.ZodString>;
726
+ subscriptionId: z.ZodOptional<z.ZodString>;
727
+ }, z.core.$strip>;
728
+ };
729
+ };
730
+ required: true;
731
+ };
732
+ };
733
+ responses: {
734
+ 200: {
735
+ description: string;
736
+ content: {
737
+ "application/json": {
738
+ schema: z.ZodType<Stripe.Subscription, unknown, z.core.$ZodTypeInternals<Stripe.Subscription, unknown>>;
739
+ };
740
+ };
741
+ };
742
+ } & {
743
+ 400: {
744
+ description: string;
745
+ content: {
746
+ "application/json": {
747
+ schema: z.core.$ZodBranded<z.ZodObject<{
748
+ success: z.ZodLiteral<false>;
749
+ code: z.ZodOptional<z.ZodString>;
750
+ message: z.ZodOptional<z.ZodString>;
751
+ }, z.core.$strip>, "error", "out">;
752
+ };
753
+ };
754
+ };
755
+ } & {
756
+ 401: {
757
+ description: string;
758
+ content: {
759
+ "application/json": {
760
+ schema: z.core.$ZodBranded<z.ZodObject<{
761
+ success: z.ZodLiteral<false>;
762
+ code: z.ZodOptional<z.ZodString>;
763
+ message: z.ZodOptional<z.ZodString>;
764
+ }, z.core.$strip>, "error", "out">;
765
+ };
766
+ };
767
+ };
768
+ };
769
+ }>;
770
+ /**
771
+ * ### Endpoint
772
+ *
773
+ * GET `/subscription/list`
774
+ *
775
+ * ### API Methods
776
+ *
777
+ * **server:**
778
+ * `auth.api.listActiveSubscriptions`
779
+ *
780
+ * **client:**
781
+ * `authClient.subscription.list`
782
+ *
783
+ * @see [Read our docs to learn more.](https://faire-auth.com/docs/plugins/stripe#api-method-subscription-list)
784
+ */
785
+ readonly listActiveSubscriptions: import("faire-auth").AuthEndpoint<{
786
+ getRoutingPath: () => "/subscription/list";
787
+ operationId: "listActiveSubscriptions";
788
+ method: "get";
789
+ path: "/subscription/list";
790
+ middleware: [(ctx: import("hono").Context<import("faire-auth").ContextVars<object & {
791
+ session: {
792
+ session: Session;
793
+ user: User;
794
+ };
795
+ }>, string, {}>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
796
+ success: false;
797
+ code?: string | undefined;
798
+ message?: string | undefined;
799
+ }, 401>)>, (ctx: import("hono").Context<import("faire-auth").ContextVars<{
800
+ session?: {
801
+ session: Session;
802
+ user: User;
803
+ };
804
+ }>, "/subscription/billing-portal" | "/subscription/cancel" | "/subscription/list" | "/subscription/restore" | "/subscription/upgrade", {
805
+ out: {
806
+ json: {
807
+ referenceId?: string;
808
+ };
809
+ query: {
810
+ referenceId?: string;
811
+ };
812
+ };
813
+ }>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
814
+ success: false;
815
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
816
+ success: false;
817
+ }, 400, "json">)>];
818
+ request: {
819
+ query: z.ZodObject<{
820
+ referenceId: z.ZodOptional<z.ZodString>;
821
+ }, z.core.$strip>;
822
+ };
823
+ responses: {
824
+ 200: {
825
+ description: string;
826
+ content: {
827
+ "application/json": {
828
+ schema: z.ZodType<Subscription[], unknown, z.core.$ZodTypeInternals<Subscription[], unknown>>;
829
+ };
830
+ };
831
+ };
832
+ } & {
833
+ 400: {
834
+ description: string;
835
+ content: {
836
+ "application/json": {
837
+ schema: z.core.$ZodBranded<z.ZodObject<{
838
+ success: z.ZodLiteral<false>;
839
+ code: z.ZodOptional<z.ZodString>;
840
+ message: z.ZodOptional<z.ZodString>;
841
+ }, z.core.$strip>, "error", "out">;
842
+ };
843
+ };
844
+ };
845
+ } & {
846
+ 401: {
847
+ description: string;
848
+ content: {
849
+ "application/json": {
850
+ schema: z.core.$ZodBranded<z.ZodObject<{
851
+ success: z.ZodLiteral<false>;
852
+ code: z.ZodOptional<z.ZodString>;
853
+ message: z.ZodOptional<z.ZodString>;
854
+ }, z.core.$strip>, "error", "out">;
855
+ };
856
+ };
857
+ };
858
+ };
859
+ }>;
860
+ readonly subscriptionSuccess: import("faire-auth").AuthEndpoint<{
861
+ getRoutingPath: () => "/subscription/success";
862
+ operationId: "subscriptionSuccess";
863
+ method: "get";
864
+ path: "/subscription/success";
865
+ middleware: [(ctx: import("hono").Context<import("faire-auth").ContextVars<object>, string, {}>, next: import("hono").Next) => Promise<void | Response>];
866
+ request: {
867
+ query: z.ZodObject<{
868
+ callbackURL: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodTransform<string | undefined, string | undefined>, z.ZodOptional<z.ZodURL>>, z.ZodTransform<string | undefined, string | undefined>>>;
869
+ subscriptionId: z.ZodOptional<z.ZodString>;
870
+ }, z.core.$strip>;
871
+ };
872
+ responses: {
873
+ 200: {
874
+ description: string;
875
+ content: {
876
+ "application/json": {
877
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
878
+ };
879
+ };
880
+ };
881
+ } & {
882
+ 302: {
883
+ description: string;
884
+ };
885
+ };
886
+ }>;
887
+ readonly createBillingPortal: import("faire-auth").AuthEndpoint<{
888
+ getRoutingPath: () => "/subscription/billing-portal";
889
+ operationId: "createBillingPortal";
890
+ method: "post";
891
+ path: "/subscription/billing-portal";
892
+ middleware: [(ctx: import("hono").Context<import("faire-auth").ContextVars<{
893
+ session: {
894
+ user: {
895
+ stripeCustomerId?: string;
896
+ };
897
+ };
898
+ } & {
899
+ session: {
900
+ session: Session;
901
+ user: User;
902
+ };
903
+ }>, string, {}>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
904
+ success: false;
905
+ code?: string | undefined;
906
+ message?: string | undefined;
907
+ }, 401>)>, (ctx: import("hono").Context<import("faire-auth").ContextVars<object>, string, {}>, next: import("hono").Next) => Promise<void | Response>, (ctx: import("hono").Context<import("faire-auth").ContextVars<{
908
+ session?: {
909
+ session: Session;
910
+ user: User;
911
+ };
912
+ }>, "/subscription/billing-portal" | "/subscription/cancel" | "/subscription/list" | "/subscription/restore" | "/subscription/upgrade", {
913
+ out: {
914
+ json: {
915
+ referenceId?: string;
916
+ };
917
+ query: {
918
+ referenceId?: string;
919
+ };
920
+ };
921
+ }>, next: import("hono").Next) => Promise<void | (Response & import("hono").TypedResponse<{
922
+ success: false;
923
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
924
+ success: false;
925
+ }, 400, "json">)>];
926
+ request: {
927
+ body: {
928
+ description?: string;
929
+ content: {
930
+ "application/json": {
931
+ schema: z.ZodObject<{
932
+ locale: z.ZodOptional<z.ZodCustom<Stripe.Checkout.Session.Locale, Stripe.Checkout.Session.Locale>>;
933
+ referenceId: z.ZodOptional<z.ZodString>;
934
+ returnUrl: z.ZodDefault<z.ZodString>;
935
+ }, z.core.$strip>;
936
+ };
937
+ };
938
+ required: true;
939
+ };
940
+ };
941
+ responses: {
942
+ 200: {
943
+ description: string;
944
+ content: {
945
+ "application/json": {
946
+ schema: z.ZodObject<{
947
+ url: z.ZodString;
948
+ redirect: z.ZodLiteral<true>;
949
+ }, z.core.$strip>;
950
+ };
951
+ };
952
+ };
953
+ } & {
954
+ 400: {
955
+ description: string;
956
+ content: {
957
+ "application/json": {
958
+ schema: z.core.$ZodBranded<z.ZodObject<{
959
+ success: z.ZodLiteral<false>;
960
+ code: z.ZodOptional<z.ZodString>;
961
+ message: z.ZodOptional<z.ZodString>;
962
+ }, z.core.$strip>, "error", "out">;
963
+ };
964
+ };
965
+ };
966
+ } & {
967
+ 401: {
968
+ description: string;
969
+ content: {
970
+ "application/json": {
971
+ schema: z.core.$ZodBranded<z.ZodObject<{
972
+ success: z.ZodLiteral<false>;
973
+ code: z.ZodOptional<z.ZodString>;
974
+ message: z.ZodOptional<z.ZodString>;
975
+ }, z.core.$strip>, "error", "out">;
976
+ };
977
+ };
978
+ };
979
+ };
980
+ }>;
981
+ } : {});
982
+ init(ctx: import("@faire-auth/core/types").AuthContext<import("faire-auth").ContextVars<any>, import("@faire-auth/core/types").FaireAuthOptions<import("faire-auth").ContextVars<any>>>): {
983
+ options: {
984
+ databaseHooks: {
985
+ user: {
986
+ create: {
987
+ after(user: {
988
+ [x: string]: unknown;
989
+ id: string;
990
+ createdAt: Date;
991
+ updatedAt: Date;
992
+ email: string;
993
+ emailVerified: boolean;
994
+ name?: string;
995
+ image?: string | null;
996
+ }, ctx: import("hono").Context<any, any, {}> | undefined): Promise<void>;
997
+ };
998
+ };
999
+ };
1000
+ };
1001
+ };
1002
+ schema: {};
1003
+ };
1004
+ type StripePlugin<O extends StripeOptions> = ReturnType<typeof stripe<O>>;
1005
+ export { Subscription as i, stripe as n, StripePlan as r, StripePlugin as t };