@better-auth/stripe 1.5.0-beta.1 → 1.5.0-beta.3

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.
@@ -2,6 +2,7 @@ import * as better_auth0 from "better-auth";
2
2
  import { GenericEndpointContext, InferOptionSchema, Session, User } from "better-auth";
3
3
  import * as better_call0 from "better-call";
4
4
  import * as zod0 from "zod";
5
+ import { Organization } from "better-auth/plugins/organization";
5
6
  import Stripe from "stripe";
6
7
 
7
8
  //#region src/schema.d.ts
@@ -49,6 +50,18 @@ declare const subscriptions: {
49
50
  required: false;
50
51
  defaultValue: false;
51
52
  };
53
+ cancelAt: {
54
+ type: "date";
55
+ required: false;
56
+ };
57
+ canceledAt: {
58
+ type: "date";
59
+ required: false;
60
+ };
61
+ endedAt: {
62
+ type: "date";
63
+ required: false;
64
+ };
52
65
  seats: {
53
66
  type: "number";
54
67
  required: false;
@@ -66,8 +79,29 @@ declare const user: {
66
79
  };
67
80
  };
68
81
  };
82
+ declare const organization: {
83
+ organization: {
84
+ fields: {
85
+ stripeCustomerId: {
86
+ type: "string";
87
+ required: false;
88
+ };
89
+ };
90
+ };
91
+ };
69
92
  //#endregion
70
93
  //#region src/types.d.ts
94
+ type AuthorizeReferenceAction = "upgrade-subscription" | "list-subscription" | "cancel-subscription" | "restore-subscription" | "billing-portal";
95
+ type WithStripeCustomerId = {
96
+ stripeCustomerId?: string;
97
+ };
98
+ type WithActiveOrganizationId = {
99
+ activeOrganizationId?: string;
100
+ };
101
+ type StripeCtxSession = {
102
+ session: Session & WithActiveOrganizationId;
103
+ user: User & WithStripeCustomerId;
104
+ };
71
105
  type StripePlan = {
72
106
  /**
73
107
  * Monthly price id
@@ -198,9 +232,26 @@ interface Subscription {
198
232
  */
199
233
  periodEnd?: Date | undefined;
200
234
  /**
201
- * Cancel at period end
235
+ * Whether this subscription will (if status=active)
236
+ * or did (if status=canceled) cancel at the end of the current billing period.
202
237
  */
203
238
  cancelAtPeriodEnd?: boolean | undefined;
239
+ /**
240
+ * If the subscription is scheduled to be canceled,
241
+ * this is the time at which the cancellation will take effect.
242
+ */
243
+ cancelAt?: Date | undefined;
244
+ /**
245
+ * If the subscription has been canceled, this is the time when it was canceled.
246
+ *
247
+ * Note: If the subscription was canceled with `cancel_at_period_end`,
248
+ * this reflects the cancellation request time, not when the subscription actually ends.
249
+ */
250
+ canceledAt?: Date | undefined;
251
+ /**
252
+ * If the subscription has ended, the date the subscription ended.
253
+ */
254
+ endedAt?: Date | undefined;
204
255
  /**
205
256
  * A field to group subscriptions so you can have multiple subscriptions
206
257
  * for one reference id
@@ -268,7 +319,7 @@ type SubscriptionOptions = {
268
319
  user: User & Record<string, any>;
269
320
  session: Session & Record<string, any>;
270
321
  referenceId: string;
271
- action: "upgrade-subscription" | "list-subscription" | "cancel-subscription" | "restore-subscription" | "billing-portal";
322
+ action: AuthorizeReferenceAction;
272
323
  }, ctx: GenericEndpointContext) => Promise<boolean>) | undefined;
273
324
  /**
274
325
  * A callback to run after a user has deleted their subscription
@@ -279,6 +330,16 @@ type SubscriptionOptions = {
279
330
  stripeSubscription: Stripe.Subscription;
280
331
  subscription: Subscription;
281
332
  }) => Promise<void>) | undefined;
333
+ /**
334
+ * A callback to run when a subscription is created
335
+ * @returns
336
+ */
337
+ onSubscriptionCreated?: ((data: {
338
+ event: Stripe.Event;
339
+ stripeSubscription: Stripe.Subscription;
340
+ subscription: Subscription;
341
+ plan: StripePlan;
342
+ }) => Promise<void>) | undefined;
282
343
  /**
283
344
  * parameters for session create params
284
345
  *
@@ -298,12 +359,6 @@ type SubscriptionOptions = {
298
359
  params?: Stripe.Checkout.SessionCreateParams;
299
360
  options?: Stripe.RequestOptions;
300
361
  }) | undefined;
301
- /**
302
- * Enable organization subscription
303
- */
304
- organization?: {
305
- enabled: boolean;
306
- } | undefined;
307
362
  };
308
363
  interface StripeOptions {
309
364
  /**
@@ -328,9 +383,7 @@ interface StripeOptions {
328
383
  */
329
384
  onCustomerCreate?: ((data: {
330
385
  stripeCustomer: Stripe.Customer;
331
- user: User & {
332
- stripeCustomerId: string;
333
- };
386
+ user: User & WithStripeCustomerId;
334
387
  }, ctx: GenericEndpointContext) => Promise<void>) | undefined;
335
388
  /**
336
389
  * A custom function to get the customer create
@@ -347,6 +400,37 @@ interface StripeOptions {
347
400
  } | ({
348
401
  enabled: true;
349
402
  } & SubscriptionOptions)) | undefined;
403
+ /**
404
+ * Organization Stripe integration
405
+ *
406
+ * Enable organizations to have their own Stripe customer ID
407
+ */
408
+ organization?: {
409
+ /**
410
+ * Enable organization Stripe customer
411
+ */
412
+ enabled: true;
413
+ /**
414
+ * A custom function to get the customer create params
415
+ * for organization customers.
416
+ *
417
+ * @param organization - the organization
418
+ * @param ctx - the context object
419
+ * @returns
420
+ */
421
+ getCustomerCreateParams?: ((organization: Organization, ctx: GenericEndpointContext) => Promise<Partial<Stripe.CustomerCreateParams>>) | undefined;
422
+ /**
423
+ * A callback to run after an organization customer has been created
424
+ *
425
+ * @param data - data containing stripeCustomer and organization
426
+ * @param ctx - the context object
427
+ * @returns
428
+ */
429
+ onCustomerCreate?: ((data: {
430
+ stripeCustomer: Stripe.Customer;
431
+ organization: Organization & WithStripeCustomerId;
432
+ }, ctx: GenericEndpointContext) => Promise<void>) | undefined;
433
+ } | undefined;
350
434
  /**
351
435
  * A callback to run after a stripe event is received
352
436
  * @param event - Stripe Event
@@ -356,10 +440,17 @@ interface StripeOptions {
356
440
  /**
357
441
  * Schema for the stripe plugin
358
442
  */
359
- schema?: InferOptionSchema<typeof subscriptions & typeof user> | undefined;
443
+ schema?: InferOptionSchema<typeof subscriptions & typeof user & typeof organization> | undefined;
360
444
  }
361
445
  //#endregion
362
446
  //#region src/index.d.ts
447
+ declare module "@better-auth/core" {
448
+ interface BetterAuthPluginRegistry<Auth, Context> {
449
+ stripe: {
450
+ creator: typeof stripe;
451
+ };
452
+ }
453
+ }
363
454
  declare const stripe: <O extends StripeOptions>(options: O) => {
364
455
  id: "stripe";
365
456
  endpoints: {
@@ -386,6 +477,10 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
386
477
  annual: zod0.ZodOptional<zod0.ZodBoolean>;
387
478
  referenceId: zod0.ZodOptional<zod0.ZodString>;
388
479
  subscriptionId: zod0.ZodOptional<zod0.ZodString>;
480
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
481
+ user: "user";
482
+ organization: "organization";
483
+ }>>;
389
484
  metadata: zod0.ZodOptional<zod0.ZodRecord<zod0.ZodString, zod0.ZodAny>>;
390
485
  seats: zod0.ZodOptional<zod0.ZodNumber>;
391
486
  successUrl: zod0.ZodDefault<zod0.ZodString>;
@@ -398,29 +493,33 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
398
493
  operationId: string;
399
494
  };
400
495
  };
401
- use: (((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
402
- session: {
403
- session: Record<string, any> & {
404
- id: string;
405
- createdAt: Date;
406
- updatedAt: Date;
407
- userId: string;
408
- expiresAt: Date;
409
- token: string;
410
- ipAddress?: string | null | undefined;
411
- userAgent?: string | null | undefined;
412
- };
413
- user: Record<string, any> & {
414
- id: string;
415
- createdAt: Date;
416
- updatedAt: Date;
417
- email: string;
418
- emailVerified: boolean;
419
- name: string;
420
- image?: string | null | undefined;
496
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
497
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
498
+ session: {
499
+ session: Record<string, any> & {
500
+ id: string;
501
+ createdAt: Date;
502
+ updatedAt: Date;
503
+ userId: string;
504
+ expiresAt: Date;
505
+ token: string;
506
+ ipAddress?: string | null | undefined;
507
+ userAgent?: string | null | undefined;
508
+ };
509
+ user: Record<string, any> & {
510
+ id: string;
511
+ createdAt: Date;
512
+ updatedAt: Date;
513
+ email: string;
514
+ emailVerified: boolean;
515
+ name: string;
516
+ image?: string | null | undefined;
517
+ };
421
518
  };
422
- };
423
- }>))[];
519
+ }>)[];
520
+ }>) => Promise<{
521
+ session: StripeCtxSession;
522
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
424
523
  }, {
425
524
  url: string;
426
525
  redirect: boolean;
@@ -517,36 +616,45 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
517
616
  body: zod0.ZodObject<{
518
617
  referenceId: zod0.ZodOptional<zod0.ZodString>;
519
618
  subscriptionId: zod0.ZodOptional<zod0.ZodString>;
619
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
620
+ user: "user";
621
+ organization: "organization";
622
+ }>>;
520
623
  returnUrl: zod0.ZodString;
624
+ disableRedirect: zod0.ZodDefault<zod0.ZodBoolean>;
521
625
  }, better_auth0.$strip>;
522
626
  metadata: {
523
627
  openapi: {
524
628
  operationId: string;
525
629
  };
526
630
  };
527
- use: (((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
528
- session: {
529
- session: Record<string, any> & {
530
- id: string;
531
- createdAt: Date;
532
- updatedAt: Date;
533
- userId: string;
534
- expiresAt: Date;
535
- token: string;
536
- ipAddress?: string | null | undefined;
537
- userAgent?: string | null | undefined;
538
- };
539
- user: Record<string, any> & {
540
- id: string;
541
- createdAt: Date;
542
- updatedAt: Date;
543
- email: string;
544
- emailVerified: boolean;
545
- name: string;
546
- image?: string | null | undefined;
631
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
632
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
633
+ session: {
634
+ session: Record<string, any> & {
635
+ id: string;
636
+ createdAt: Date;
637
+ updatedAt: Date;
638
+ userId: string;
639
+ expiresAt: Date;
640
+ token: string;
641
+ ipAddress?: string | null | undefined;
642
+ userAgent?: string | null | undefined;
643
+ };
644
+ user: Record<string, any> & {
645
+ id: string;
646
+ createdAt: Date;
647
+ updatedAt: Date;
648
+ email: string;
649
+ emailVerified: boolean;
650
+ name: string;
651
+ image?: string | null | undefined;
652
+ };
547
653
  };
548
- };
549
- }>))[];
654
+ }>)[];
655
+ }>) => Promise<{
656
+ session: StripeCtxSession;
657
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
550
658
  }, {
551
659
  url: string;
552
660
  redirect: boolean;
@@ -556,69 +664,85 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
556
664
  body: zod0.ZodObject<{
557
665
  referenceId: zod0.ZodOptional<zod0.ZodString>;
558
666
  subscriptionId: zod0.ZodOptional<zod0.ZodString>;
667
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
668
+ user: "user";
669
+ organization: "organization";
670
+ }>>;
559
671
  }, better_auth0.$strip>;
560
672
  metadata: {
561
673
  openapi: {
562
674
  operationId: string;
563
675
  };
564
676
  };
565
- use: (((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
566
- session: {
567
- session: Record<string, any> & {
568
- id: string;
569
- createdAt: Date;
570
- updatedAt: Date;
571
- userId: string;
572
- expiresAt: Date;
573
- token: string;
574
- ipAddress?: string | null | undefined;
575
- userAgent?: string | null | undefined;
576
- };
577
- user: Record<string, any> & {
578
- id: string;
579
- createdAt: Date;
580
- updatedAt: Date;
581
- email: string;
582
- emailVerified: boolean;
583
- name: string;
584
- image?: string | null | undefined;
677
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
678
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
679
+ session: {
680
+ session: Record<string, any> & {
681
+ id: string;
682
+ createdAt: Date;
683
+ updatedAt: Date;
684
+ userId: string;
685
+ expiresAt: Date;
686
+ token: string;
687
+ ipAddress?: string | null | undefined;
688
+ userAgent?: string | null | undefined;
689
+ };
690
+ user: Record<string, any> & {
691
+ id: string;
692
+ createdAt: Date;
693
+ updatedAt: Date;
694
+ email: string;
695
+ emailVerified: boolean;
696
+ name: string;
697
+ image?: string | null | undefined;
698
+ };
585
699
  };
586
- };
587
- }>))[];
700
+ }>)[];
701
+ }>) => Promise<{
702
+ session: StripeCtxSession;
703
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
588
704
  }, Stripe.Response<Stripe.Subscription>>;
589
705
  listActiveSubscriptions: better_call0.StrictEndpoint<"/subscription/list", {
590
706
  method: "GET";
591
707
  query: zod0.ZodOptional<zod0.ZodObject<{
592
708
  referenceId: zod0.ZodOptional<zod0.ZodString>;
709
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
710
+ user: "user";
711
+ organization: "organization";
712
+ }>>;
593
713
  }, better_auth0.$strip>>;
594
714
  metadata: {
595
715
  openapi: {
596
716
  operationId: string;
597
717
  };
598
718
  };
599
- use: (((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
600
- session: {
601
- session: Record<string, any> & {
602
- id: string;
603
- createdAt: Date;
604
- updatedAt: Date;
605
- userId: string;
606
- expiresAt: Date;
607
- token: string;
608
- ipAddress?: string | null | undefined;
609
- userAgent?: string | null | undefined;
610
- };
611
- user: Record<string, any> & {
612
- id: string;
613
- createdAt: Date;
614
- updatedAt: Date;
615
- email: string;
616
- emailVerified: boolean;
617
- name: string;
618
- image?: string | null | undefined;
719
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
720
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
721
+ session: {
722
+ session: Record<string, any> & {
723
+ id: string;
724
+ createdAt: Date;
725
+ updatedAt: Date;
726
+ userId: string;
727
+ expiresAt: Date;
728
+ token: string;
729
+ ipAddress?: string | null | undefined;
730
+ userAgent?: string | null | undefined;
731
+ };
732
+ user: Record<string, any> & {
733
+ id: string;
734
+ createdAt: Date;
735
+ updatedAt: Date;
736
+ email: string;
737
+ emailVerified: boolean;
738
+ name: string;
739
+ image?: string | null | undefined;
740
+ };
619
741
  };
620
- };
621
- }>))[];
742
+ }>)[];
743
+ }>) => Promise<{
744
+ session: StripeCtxSession;
745
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
622
746
  }, {
623
747
  limits: Record<string, unknown> | undefined;
624
748
  priceId: string | undefined;
@@ -633,6 +757,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
633
757
  periodStart?: Date | undefined;
634
758
  periodEnd?: Date | undefined;
635
759
  cancelAtPeriodEnd?: boolean | undefined;
760
+ cancelAt?: Date | undefined;
761
+ canceledAt?: Date | undefined;
762
+ endedAt?: Date | undefined;
636
763
  groupId?: string | undefined;
637
764
  seats?: number | undefined;
638
765
  }[]>;
@@ -645,55 +772,51 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
645
772
  };
646
773
  };
647
774
  use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>)[];
648
- }, {
649
- status: ("NOT_FOUND" | "FOUND" | "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") | better_call0.Status;
650
- body: ({
651
- message?: string;
652
- code?: string;
653
- cause?: unknown;
654
- } & Record<string, any>) | undefined;
655
- headers: HeadersInit;
656
- statusCode: number;
657
- name: string;
658
- message: string;
659
- stack?: string;
660
- cause?: unknown;
661
- }>;
775
+ }, never>;
662
776
  createBillingPortal: better_call0.StrictEndpoint<"/subscription/billing-portal", {
663
777
  method: "POST";
664
778
  body: zod0.ZodObject<{
665
779
  locale: zod0.ZodOptional<zod0.ZodCustom<Stripe.Checkout.Session.Locale, Stripe.Checkout.Session.Locale>>;
666
780
  referenceId: zod0.ZodOptional<zod0.ZodString>;
781
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
782
+ user: "user";
783
+ organization: "organization";
784
+ }>>;
667
785
  returnUrl: zod0.ZodDefault<zod0.ZodString>;
786
+ disableRedirect: zod0.ZodDefault<zod0.ZodBoolean>;
668
787
  }, better_auth0.$strip>;
669
788
  metadata: {
670
789
  openapi: {
671
790
  operationId: string;
672
791
  };
673
792
  };
674
- use: (((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
675
- session: {
676
- session: Record<string, any> & {
677
- id: string;
678
- createdAt: Date;
679
- updatedAt: Date;
680
- userId: string;
681
- expiresAt: Date;
682
- token: string;
683
- ipAddress?: string | null | undefined;
684
- userAgent?: string | null | undefined;
685
- };
686
- user: Record<string, any> & {
687
- id: string;
688
- createdAt: Date;
689
- updatedAt: Date;
690
- email: string;
691
- emailVerified: boolean;
692
- name: string;
693
- image?: string | null | undefined;
793
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
794
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
795
+ session: {
796
+ session: Record<string, any> & {
797
+ id: string;
798
+ createdAt: Date;
799
+ updatedAt: Date;
800
+ userId: string;
801
+ expiresAt: Date;
802
+ token: string;
803
+ ipAddress?: string | null | undefined;
804
+ userAgent?: string | null | undefined;
805
+ };
806
+ user: Record<string, any> & {
807
+ id: string;
808
+ createdAt: Date;
809
+ updatedAt: Date;
810
+ email: string;
811
+ emailVerified: boolean;
812
+ name: string;
813
+ image?: string | null | undefined;
814
+ };
694
815
  };
695
- };
696
- }>))[];
816
+ }>)[];
817
+ }>) => Promise<{
818
+ session: StripeCtxSession;
819
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
697
820
  }, {
698
821
  url: string;
699
822
  redirect: boolean;
@@ -704,34 +827,26 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
704
827
  databaseHooks: {
705
828
  user: {
706
829
  create: {
707
- after(user: {
708
- id: string;
709
- createdAt: Date;
710
- updatedAt: Date;
711
- email: string;
712
- emailVerified: boolean;
713
- name: string;
714
- image?: string | null | undefined;
715
- } & Record<string, unknown>, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
830
+ after(user: User & WithStripeCustomerId, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
716
831
  };
717
832
  update: {
718
- after(user: {
719
- id: string;
720
- createdAt: Date;
721
- updatedAt: Date;
722
- email: string;
723
- emailVerified: boolean;
724
- name: string;
725
- image?: string | null | undefined;
726
- } & Record<string, unknown>, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
833
+ after(user: User & WithStripeCustomerId, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
727
834
  };
728
835
  };
729
836
  };
730
837
  };
731
- };
838
+ } | undefined;
732
839
  schema: {};
733
840
  options: NoInfer<O>;
734
841
  $ERROR_CODES: {
842
+ readonly UNAUTHORIZED: {
843
+ code: "UNAUTHORIZED";
844
+ message: "Unauthorized access";
845
+ };
846
+ readonly INVALID_REQUEST_BODY: {
847
+ code: "INVALID_REQUEST_BODY";
848
+ message: "Invalid request body";
849
+ };
735
850
  readonly SUBSCRIPTION_NOT_FOUND: {
736
851
  code: "SUBSCRIPTION_NOT_FOUND";
737
852
  message: "Subscription not found";
@@ -744,10 +859,38 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
744
859
  code: "ALREADY_SUBSCRIBED_PLAN";
745
860
  message: "You're already subscribed to this plan";
746
861
  };
862
+ readonly REFERENCE_ID_NOT_ALLOWED: {
863
+ code: "REFERENCE_ID_NOT_ALLOWED";
864
+ message: "Reference id is not allowed";
865
+ };
866
+ readonly CUSTOMER_NOT_FOUND: {
867
+ code: "CUSTOMER_NOT_FOUND";
868
+ message: "Stripe customer not found for this user";
869
+ };
747
870
  readonly UNABLE_TO_CREATE_CUSTOMER: {
748
871
  code: "UNABLE_TO_CREATE_CUSTOMER";
749
872
  message: "Unable to create customer";
750
873
  };
874
+ readonly UNABLE_TO_CREATE_BILLING_PORTAL: {
875
+ code: "UNABLE_TO_CREATE_BILLING_PORTAL";
876
+ message: "Unable to create billing portal session";
877
+ };
878
+ readonly STRIPE_SIGNATURE_NOT_FOUND: {
879
+ code: "STRIPE_SIGNATURE_NOT_FOUND";
880
+ message: "Stripe signature not found";
881
+ };
882
+ readonly STRIPE_WEBHOOK_SECRET_NOT_FOUND: {
883
+ code: "STRIPE_WEBHOOK_SECRET_NOT_FOUND";
884
+ message: "Stripe webhook secret not found";
885
+ };
886
+ readonly STRIPE_WEBHOOK_ERROR: {
887
+ code: "STRIPE_WEBHOOK_ERROR";
888
+ message: "Stripe webhook error";
889
+ };
890
+ readonly FAILED_TO_CONSTRUCT_STRIPE_EVENT: {
891
+ code: "FAILED_TO_CONSTRUCT_STRIPE_EVENT";
892
+ message: "Failed to construct Stripe event";
893
+ };
751
894
  readonly FAILED_TO_FETCH_PLANS: {
752
895
  code: "FAILED_TO_FETCH_PLANS";
753
896
  message: "Failed to fetch plans";
@@ -764,6 +907,22 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
764
907
  code: "SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION";
765
908
  message: "Subscription is not scheduled for cancellation";
766
909
  };
910
+ readonly ORGANIZATION_NOT_FOUND: {
911
+ code: "ORGANIZATION_NOT_FOUND";
912
+ message: "Organization not found";
913
+ };
914
+ readonly ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: {
915
+ code: "ORGANIZATION_SUBSCRIPTION_NOT_ENABLED";
916
+ message: "Organization subscription is not enabled";
917
+ };
918
+ readonly ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: {
919
+ code: "ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION";
920
+ message: "Cannot delete organization with active subscription";
921
+ };
922
+ readonly ORGANIZATION_REFERENCE_ID_REQUIRED: {
923
+ code: "ORGANIZATION_REFERENCE_ID_REQUIRED";
924
+ message: "Reference ID is required. Provide referenceId or set activeOrganizationId in session";
925
+ };
767
926
  };
768
927
  };
769
928
  type StripePlugin<O extends StripeOptions> = ReturnType<typeof stripe<O>>;
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as SubscriptionOptions, i as Subscription, n as stripe, r as StripePlan, t as StripePlugin } from "./index-DpiQGYLJ.mjs";
1
+ import { a as SubscriptionOptions, i as Subscription, n as stripe, r as StripePlan, t as StripePlugin } from "./index-BnHmwMru.mjs";
2
2
  export { StripePlan, StripePlugin, Subscription, SubscriptionOptions, stripe };