@better-auth/stripe 1.6.23 → 1.6.25

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.
package/dist/client.d.mts CHANGED
@@ -1,31 +1,29 @@
1
- import { l as StripePlan, n as stripe } from "./index-ntN1joRP.mjs";
2
- import * as better_auth0 from "better-auth";
3
-
1
+ import { l as StripePlan, n as stripe } from "./index-CbLwZwAG.mjs";
4
2
  //#region src/error-codes.d.ts
5
3
  declare const STRIPE_ERROR_CODES: {
6
- UNAUTHORIZED: better_auth0.RawError<"UNAUTHORIZED">;
7
- INVALID_REQUEST_BODY: better_auth0.RawError<"INVALID_REQUEST_BODY">;
8
- SUBSCRIPTION_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
9
- SUBSCRIPTION_PLAN_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
10
- ALREADY_SUBSCRIBED_PLAN: better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
11
- REFERENCE_ID_NOT_ALLOWED: better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
12
- CUSTOMER_NOT_FOUND: better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
13
- UNABLE_TO_CREATE_CUSTOMER: better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
14
- UNABLE_TO_CREATE_BILLING_PORTAL: better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
15
- STRIPE_SIGNATURE_NOT_FOUND: better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
16
- STRIPE_WEBHOOK_SECRET_NOT_FOUND: better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
17
- STRIPE_WEBHOOK_ERROR: better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
18
- FAILED_TO_CONSTRUCT_STRIPE_EVENT: better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
19
- FAILED_TO_FETCH_PLANS: better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
20
- EMAIL_VERIFICATION_REQUIRED: better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
21
- SUBSCRIPTION_NOT_ACTIVE: better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
22
- SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
23
- SUBSCRIPTION_NOT_PENDING_CHANGE: better_auth0.RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
24
- ORGANIZATION_NOT_FOUND: better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
25
- ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
26
- AUTHORIZE_REFERENCE_REQUIRED: better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
27
- ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
28
- ORGANIZATION_REFERENCE_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
4
+ UNAUTHORIZED: import("better-auth").RawError<"UNAUTHORIZED">;
5
+ INVALID_REQUEST_BODY: import("better-auth").RawError<"INVALID_REQUEST_BODY">;
6
+ SUBSCRIPTION_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_NOT_FOUND">;
7
+ SUBSCRIPTION_PLAN_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
8
+ ALREADY_SUBSCRIBED_PLAN: import("better-auth").RawError<"ALREADY_SUBSCRIBED_PLAN">;
9
+ REFERENCE_ID_NOT_ALLOWED: import("better-auth").RawError<"REFERENCE_ID_NOT_ALLOWED">;
10
+ CUSTOMER_NOT_FOUND: import("better-auth").RawError<"CUSTOMER_NOT_FOUND">;
11
+ UNABLE_TO_CREATE_CUSTOMER: import("better-auth").RawError<"UNABLE_TO_CREATE_CUSTOMER">;
12
+ UNABLE_TO_CREATE_BILLING_PORTAL: import("better-auth").RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
13
+ STRIPE_SIGNATURE_NOT_FOUND: import("better-auth").RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
14
+ STRIPE_WEBHOOK_SECRET_NOT_FOUND: import("better-auth").RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
15
+ STRIPE_WEBHOOK_ERROR: import("better-auth").RawError<"STRIPE_WEBHOOK_ERROR">;
16
+ FAILED_TO_CONSTRUCT_STRIPE_EVENT: import("better-auth").RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
17
+ FAILED_TO_FETCH_PLANS: import("better-auth").RawError<"FAILED_TO_FETCH_PLANS">;
18
+ EMAIL_VERIFICATION_REQUIRED: import("better-auth").RawError<"EMAIL_VERIFICATION_REQUIRED">;
19
+ SUBSCRIPTION_NOT_ACTIVE: import("better-auth").RawError<"SUBSCRIPTION_NOT_ACTIVE">;
20
+ SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: import("better-auth").RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
21
+ SUBSCRIPTION_NOT_PENDING_CHANGE: import("better-auth").RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
22
+ ORGANIZATION_NOT_FOUND: import("better-auth").RawError<"ORGANIZATION_NOT_FOUND">;
23
+ ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: import("better-auth").RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
24
+ AUTHORIZE_REFERENCE_REQUIRED: import("better-auth").RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
25
+ ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: import("better-auth").RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
26
+ ORGANIZATION_REFERENCE_ID_REQUIRED: import("better-auth").RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
29
27
  };
30
28
  //#endregion
31
29
  //#region src/client.d.ts
@@ -50,29 +48,29 @@ declare const stripeClient: <O extends {
50
48
  "/subscription/restore": "POST";
51
49
  };
52
50
  $ERROR_CODES: {
53
- UNAUTHORIZED: better_auth0.RawError<"UNAUTHORIZED">;
54
- INVALID_REQUEST_BODY: better_auth0.RawError<"INVALID_REQUEST_BODY">;
55
- SUBSCRIPTION_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
56
- SUBSCRIPTION_PLAN_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
57
- ALREADY_SUBSCRIBED_PLAN: better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
58
- REFERENCE_ID_NOT_ALLOWED: better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
59
- CUSTOMER_NOT_FOUND: better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
60
- UNABLE_TO_CREATE_CUSTOMER: better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
61
- UNABLE_TO_CREATE_BILLING_PORTAL: better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
62
- STRIPE_SIGNATURE_NOT_FOUND: better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
63
- STRIPE_WEBHOOK_SECRET_NOT_FOUND: better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
64
- STRIPE_WEBHOOK_ERROR: better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
65
- FAILED_TO_CONSTRUCT_STRIPE_EVENT: better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
66
- FAILED_TO_FETCH_PLANS: better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
67
- EMAIL_VERIFICATION_REQUIRED: better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
68
- SUBSCRIPTION_NOT_ACTIVE: better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
69
- SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
70
- SUBSCRIPTION_NOT_PENDING_CHANGE: better_auth0.RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
71
- ORGANIZATION_NOT_FOUND: better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
72
- ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
73
- AUTHORIZE_REFERENCE_REQUIRED: better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
74
- ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
75
- ORGANIZATION_REFERENCE_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
51
+ UNAUTHORIZED: import("better-auth").RawError<"UNAUTHORIZED">;
52
+ INVALID_REQUEST_BODY: import("better-auth").RawError<"INVALID_REQUEST_BODY">;
53
+ SUBSCRIPTION_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_NOT_FOUND">;
54
+ SUBSCRIPTION_PLAN_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
55
+ ALREADY_SUBSCRIBED_PLAN: import("better-auth").RawError<"ALREADY_SUBSCRIBED_PLAN">;
56
+ REFERENCE_ID_NOT_ALLOWED: import("better-auth").RawError<"REFERENCE_ID_NOT_ALLOWED">;
57
+ CUSTOMER_NOT_FOUND: import("better-auth").RawError<"CUSTOMER_NOT_FOUND">;
58
+ UNABLE_TO_CREATE_CUSTOMER: import("better-auth").RawError<"UNABLE_TO_CREATE_CUSTOMER">;
59
+ UNABLE_TO_CREATE_BILLING_PORTAL: import("better-auth").RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
60
+ STRIPE_SIGNATURE_NOT_FOUND: import("better-auth").RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
61
+ STRIPE_WEBHOOK_SECRET_NOT_FOUND: import("better-auth").RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
62
+ STRIPE_WEBHOOK_ERROR: import("better-auth").RawError<"STRIPE_WEBHOOK_ERROR">;
63
+ FAILED_TO_CONSTRUCT_STRIPE_EVENT: import("better-auth").RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
64
+ FAILED_TO_FETCH_PLANS: import("better-auth").RawError<"FAILED_TO_FETCH_PLANS">;
65
+ EMAIL_VERIFICATION_REQUIRED: import("better-auth").RawError<"EMAIL_VERIFICATION_REQUIRED">;
66
+ SUBSCRIPTION_NOT_ACTIVE: import("better-auth").RawError<"SUBSCRIPTION_NOT_ACTIVE">;
67
+ SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: import("better-auth").RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
68
+ SUBSCRIPTION_NOT_PENDING_CHANGE: import("better-auth").RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
69
+ ORGANIZATION_NOT_FOUND: import("better-auth").RawError<"ORGANIZATION_NOT_FOUND">;
70
+ ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: import("better-auth").RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
71
+ AUTHORIZE_REFERENCE_REQUIRED: import("better-auth").RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
72
+ ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: import("better-auth").RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
73
+ ORGANIZATION_REFERENCE_ID_REQUIRED: import("better-auth").RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
76
74
  };
77
75
  };
78
76
  //#endregion
package/dist/client.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as STRIPE_ERROR_CODES, t as PACKAGE_VERSION } from "./version-DVUKHm6Z.mjs";
1
+ import { n as STRIPE_ERROR_CODES, t as PACKAGE_VERSION } from "./version-DROhXblk.mjs";
2
2
  //#region src/client.ts
3
3
  const stripeClient = (options) => {
4
4
  return {
@@ -1,11 +1,6 @@
1
- import * as better_auth0 from "better-auth";
2
1
  import { GenericEndpointContext, InferOptionSchema, Session, User } from "better-auth";
3
- import * as zod from "zod";
4
- import * as better_call0 from "better-call";
5
2
  import { Organization } from "better-auth/plugins/organization";
6
3
  import Stripe from "stripe";
7
- import * as zod_v4_core0 from "zod/v4/core";
8
-
9
4
  //#region src/schema.d.ts
10
5
  declare const subscriptions: {
11
6
  subscription: {
@@ -509,7 +504,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
509
504
  id: "stripe";
510
505
  version: string;
511
506
  endpoints: {
512
- stripeWebhook: better_call0.StrictEndpoint<"/stripe/webhook", {
507
+ stripeWebhook: import("better-call").StrictEndpoint<"/stripe/webhook", {
513
508
  method: "POST";
514
509
  metadata: {
515
510
  openapi: {
@@ -525,33 +520,33 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
525
520
  } & (O["subscription"] extends {
526
521
  enabled: true;
527
522
  } ? {
528
- upgradeSubscription: better_call0.StrictEndpoint<"/subscription/upgrade", {
523
+ upgradeSubscription: import("better-call").StrictEndpoint<"/subscription/upgrade", {
529
524
  method: "POST";
530
- body: zod.ZodObject<{
531
- plan: zod.ZodString;
532
- annual: zod.ZodOptional<zod.ZodBoolean>;
533
- referenceId: zod.ZodOptional<zod.ZodString>;
534
- subscriptionId: zod.ZodOptional<zod.ZodString>;
535
- customerType: zod.ZodOptional<zod.ZodEnum<{
525
+ body: import("zod").ZodObject<{
526
+ plan: import("zod").ZodString;
527
+ annual: import("zod").ZodOptional<import("zod").ZodBoolean>;
528
+ referenceId: import("zod").ZodOptional<import("zod").ZodString>;
529
+ subscriptionId: import("zod").ZodOptional<import("zod").ZodString>;
530
+ customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
536
531
  user: "user";
537
532
  organization: "organization";
538
533
  }>>;
539
- metadata: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
540
- seats: zod.ZodOptional<zod.ZodNumber>;
541
- locale: zod.ZodOptional<zod.ZodCustom<CheckoutSessionLocale, CheckoutSessionLocale>>;
542
- successUrl: zod.ZodDefault<zod.ZodString>;
543
- cancelUrl: zod.ZodDefault<zod.ZodString>;
544
- returnUrl: zod.ZodOptional<zod.ZodString>;
545
- scheduleAtPeriodEnd: zod.ZodDefault<zod.ZodBoolean>;
546
- disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
547
- }, zod_v4_core0.$strip>;
534
+ metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
535
+ seats: import("zod").ZodOptional<import("zod").ZodNumber>;
536
+ locale: import("zod").ZodOptional<import("zod").ZodCustom<CheckoutSessionLocale, CheckoutSessionLocale>>;
537
+ successUrl: import("zod").ZodDefault<import("zod").ZodString>;
538
+ cancelUrl: import("zod").ZodDefault<import("zod").ZodString>;
539
+ returnUrl: import("zod").ZodOptional<import("zod").ZodString>;
540
+ scheduleAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>;
541
+ disableRedirect: import("zod").ZodDefault<import("zod").ZodBoolean>;
542
+ }, import("zod/v4/core").$strip>;
548
543
  metadata: {
549
544
  openapi: {
550
545
  operationId: string;
551
546
  };
552
547
  };
553
- use: (((inputContext: better_call0.MiddlewareInputContext<{
554
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
548
+ use: (((inputContext: import("better-call").MiddlewareInputContext<{
549
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
555
550
  session: {
556
551
  session: Record<string, any> & {
557
552
  id: string;
@@ -576,9 +571,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
576
571
  }>)[];
577
572
  }>) => Promise<{
578
573
  session: StripeCtxSession;
579
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
574
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
580
575
  referenceId: string;
581
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
576
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>))[];
582
577
  }, {
583
578
  url: string;
584
579
  redirect: boolean;
@@ -596,25 +591,25 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
596
591
  } & {
597
592
  redirect: boolean;
598
593
  })>;
599
- cancelSubscription: better_call0.StrictEndpoint<"/subscription/cancel", {
594
+ cancelSubscription: import("better-call").StrictEndpoint<"/subscription/cancel", {
600
595
  method: "POST";
601
- body: zod.ZodObject<{
602
- referenceId: zod.ZodOptional<zod.ZodString>;
603
- subscriptionId: zod.ZodOptional<zod.ZodString>;
604
- customerType: zod.ZodOptional<zod.ZodEnum<{
596
+ body: import("zod").ZodObject<{
597
+ referenceId: import("zod").ZodOptional<import("zod").ZodString>;
598
+ subscriptionId: import("zod").ZodOptional<import("zod").ZodString>;
599
+ customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
605
600
  user: "user";
606
601
  organization: "organization";
607
602
  }>>;
608
- returnUrl: zod.ZodString;
609
- disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
610
- }, zod_v4_core0.$strip>;
603
+ returnUrl: import("zod").ZodString;
604
+ disableRedirect: import("zod").ZodDefault<import("zod").ZodBoolean>;
605
+ }, import("zod/v4/core").$strip>;
611
606
  metadata: {
612
607
  openapi: {
613
608
  operationId: string;
614
609
  };
615
610
  };
616
- use: (((inputContext: better_call0.MiddlewareInputContext<{
617
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
611
+ use: (((inputContext: import("better-call").MiddlewareInputContext<{
612
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
618
613
  session: {
619
614
  session: Record<string, any> & {
620
615
  id: string;
@@ -639,30 +634,30 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
639
634
  }>)[];
640
635
  }>) => Promise<{
641
636
  session: StripeCtxSession;
642
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
637
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
643
638
  referenceId: string;
644
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
639
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>))[];
645
640
  }, {
646
641
  url: string;
647
642
  redirect: boolean;
648
643
  }>;
649
- restoreSubscription: better_call0.StrictEndpoint<"/subscription/restore", {
644
+ restoreSubscription: import("better-call").StrictEndpoint<"/subscription/restore", {
650
645
  method: "POST";
651
- body: zod.ZodObject<{
652
- referenceId: zod.ZodOptional<zod.ZodString>;
653
- subscriptionId: zod.ZodOptional<zod.ZodString>;
654
- customerType: zod.ZodOptional<zod.ZodEnum<{
646
+ body: import("zod").ZodObject<{
647
+ referenceId: import("zod").ZodOptional<import("zod").ZodString>;
648
+ subscriptionId: import("zod").ZodOptional<import("zod").ZodString>;
649
+ customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
655
650
  user: "user";
656
651
  organization: "organization";
657
652
  }>>;
658
- }, zod_v4_core0.$strip>;
653
+ }, import("zod/v4/core").$strip>;
659
654
  metadata: {
660
655
  openapi: {
661
656
  operationId: string;
662
657
  };
663
658
  };
664
- use: (((inputContext: better_call0.MiddlewareInputContext<{
665
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
659
+ use: (((inputContext: import("better-call").MiddlewareInputContext<{
660
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
666
661
  session: {
667
662
  session: Record<string, any> & {
668
663
  id: string;
@@ -687,26 +682,26 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
687
682
  }>)[];
688
683
  }>) => Promise<{
689
684
  session: StripeCtxSession;
690
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
685
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
691
686
  referenceId: string;
692
687
  }>))[];
693
688
  }, Stripe.Response<Stripe.Subscription>>;
694
- listActiveSubscriptions: better_call0.StrictEndpoint<"/subscription/list", {
689
+ listActiveSubscriptions: import("better-call").StrictEndpoint<"/subscription/list", {
695
690
  method: "GET";
696
- query: zod.ZodOptional<zod.ZodObject<{
697
- referenceId: zod.ZodOptional<zod.ZodString>;
698
- customerType: zod.ZodOptional<zod.ZodEnum<{
691
+ query: import("zod").ZodOptional<import("zod").ZodObject<{
692
+ referenceId: import("zod").ZodOptional<import("zod").ZodString>;
693
+ customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
699
694
  user: "user";
700
695
  organization: "organization";
701
696
  }>>;
702
- }, zod_v4_core0.$strip>>;
697
+ }, import("zod/v4/core").$strip>>;
703
698
  metadata: {
704
699
  openapi: {
705
700
  operationId: string;
706
701
  };
707
702
  };
708
- use: (((inputContext: better_call0.MiddlewareInputContext<{
709
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
703
+ use: (((inputContext: import("better-call").MiddlewareInputContext<{
704
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
710
705
  session: {
711
706
  session: Record<string, any> & {
712
707
  id: string;
@@ -731,7 +726,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
731
726
  }>)[];
732
727
  }>) => Promise<{
733
728
  session: StripeCtxSession;
734
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
729
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
735
730
  referenceId: string;
736
731
  }>))[];
737
732
  }, {
@@ -756,35 +751,35 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
756
751
  billingInterval?: "day" | "week" | "month" | "year" | undefined;
757
752
  stripeScheduleId?: string | undefined;
758
753
  }[]>;
759
- subscriptionSuccess: better_call0.StrictEndpoint<"/subscription/success", {
754
+ subscriptionSuccess: import("better-call").StrictEndpoint<"/subscription/success", {
760
755
  method: "GET";
761
- query: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
756
+ query: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
762
757
  metadata: {
763
758
  openapi: {
764
759
  operationId: string;
765
760
  };
766
761
  };
767
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>)[];
762
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
768
763
  }, never>;
769
- createBillingPortal: better_call0.StrictEndpoint<"/subscription/billing-portal", {
764
+ createBillingPortal: import("better-call").StrictEndpoint<"/subscription/billing-portal", {
770
765
  method: "POST";
771
- body: zod.ZodObject<{
772
- locale: zod.ZodOptional<zod.ZodCustom<CheckoutSessionLocale, CheckoutSessionLocale>>;
773
- referenceId: zod.ZodOptional<zod.ZodString>;
774
- customerType: zod.ZodOptional<zod.ZodEnum<{
766
+ body: import("zod").ZodObject<{
767
+ locale: import("zod").ZodOptional<import("zod").ZodCustom<CheckoutSessionLocale, CheckoutSessionLocale>>;
768
+ referenceId: import("zod").ZodOptional<import("zod").ZodString>;
769
+ customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
775
770
  user: "user";
776
771
  organization: "organization";
777
772
  }>>;
778
- returnUrl: zod.ZodDefault<zod.ZodString>;
779
- disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
780
- }, zod_v4_core0.$strip>;
773
+ returnUrl: import("zod").ZodDefault<import("zod").ZodString>;
774
+ disableRedirect: import("zod").ZodDefault<import("zod").ZodBoolean>;
775
+ }, import("zod/v4/core").$strip>;
781
776
  metadata: {
782
777
  openapi: {
783
778
  operationId: string;
784
779
  };
785
780
  };
786
- use: (((inputContext: better_call0.MiddlewareInputContext<{
787
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
781
+ use: (((inputContext: import("better-call").MiddlewareInputContext<{
782
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
788
783
  session: {
789
784
  session: Record<string, any> & {
790
785
  id: string;
@@ -809,23 +804,23 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
809
804
  }>)[];
810
805
  }>) => Promise<{
811
806
  session: StripeCtxSession;
812
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
807
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
813
808
  referenceId: string;
814
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
809
+ }>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>))[];
815
810
  }, {
816
811
  url: string;
817
812
  redirect: boolean;
818
813
  }>;
819
814
  } : {});
820
- init(ctx: better_auth0.AuthContext): {
815
+ init(ctx: import("better-auth").AuthContext): {
821
816
  options: {
822
817
  databaseHooks: {
823
818
  user: {
824
819
  create: {
825
- after(user: User & WithStripeCustomerId, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
820
+ after(user: User & WithStripeCustomerId, ctx: import("better-auth").GenericEndpointContext | null): Promise<void>;
826
821
  };
827
822
  update: {
828
- after(user: User & WithStripeCustomerId, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
823
+ after(user: User & WithStripeCustomerId, ctx: import("better-auth").GenericEndpointContext | null): Promise<void>;
829
824
  };
830
825
  };
831
826
  };
@@ -926,29 +921,29 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
926
921
  } : {});
927
922
  options: NoInfer<O>;
928
923
  $ERROR_CODES: {
929
- UNAUTHORIZED: better_auth0.RawError<"UNAUTHORIZED">;
930
- INVALID_REQUEST_BODY: better_auth0.RawError<"INVALID_REQUEST_BODY">;
931
- SUBSCRIPTION_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
932
- SUBSCRIPTION_PLAN_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
933
- ALREADY_SUBSCRIBED_PLAN: better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
934
- REFERENCE_ID_NOT_ALLOWED: better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
935
- CUSTOMER_NOT_FOUND: better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
936
- UNABLE_TO_CREATE_CUSTOMER: better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
937
- UNABLE_TO_CREATE_BILLING_PORTAL: better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
938
- STRIPE_SIGNATURE_NOT_FOUND: better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
939
- STRIPE_WEBHOOK_SECRET_NOT_FOUND: better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
940
- STRIPE_WEBHOOK_ERROR: better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
941
- FAILED_TO_CONSTRUCT_STRIPE_EVENT: better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
942
- FAILED_TO_FETCH_PLANS: better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
943
- EMAIL_VERIFICATION_REQUIRED: better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
944
- SUBSCRIPTION_NOT_ACTIVE: better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
945
- SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
946
- SUBSCRIPTION_NOT_PENDING_CHANGE: better_auth0.RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
947
- ORGANIZATION_NOT_FOUND: better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
948
- ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
949
- AUTHORIZE_REFERENCE_REQUIRED: better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
950
- ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
951
- ORGANIZATION_REFERENCE_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
924
+ UNAUTHORIZED: import("better-auth").RawError<"UNAUTHORIZED">;
925
+ INVALID_REQUEST_BODY: import("better-auth").RawError<"INVALID_REQUEST_BODY">;
926
+ SUBSCRIPTION_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_NOT_FOUND">;
927
+ SUBSCRIPTION_PLAN_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
928
+ ALREADY_SUBSCRIBED_PLAN: import("better-auth").RawError<"ALREADY_SUBSCRIBED_PLAN">;
929
+ REFERENCE_ID_NOT_ALLOWED: import("better-auth").RawError<"REFERENCE_ID_NOT_ALLOWED">;
930
+ CUSTOMER_NOT_FOUND: import("better-auth").RawError<"CUSTOMER_NOT_FOUND">;
931
+ UNABLE_TO_CREATE_CUSTOMER: import("better-auth").RawError<"UNABLE_TO_CREATE_CUSTOMER">;
932
+ UNABLE_TO_CREATE_BILLING_PORTAL: import("better-auth").RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
933
+ STRIPE_SIGNATURE_NOT_FOUND: import("better-auth").RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
934
+ STRIPE_WEBHOOK_SECRET_NOT_FOUND: import("better-auth").RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
935
+ STRIPE_WEBHOOK_ERROR: import("better-auth").RawError<"STRIPE_WEBHOOK_ERROR">;
936
+ FAILED_TO_CONSTRUCT_STRIPE_EVENT: import("better-auth").RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
937
+ FAILED_TO_FETCH_PLANS: import("better-auth").RawError<"FAILED_TO_FETCH_PLANS">;
938
+ EMAIL_VERIFICATION_REQUIRED: import("better-auth").RawError<"EMAIL_VERIFICATION_REQUIRED">;
939
+ SUBSCRIPTION_NOT_ACTIVE: import("better-auth").RawError<"SUBSCRIPTION_NOT_ACTIVE">;
940
+ SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: import("better-auth").RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
941
+ SUBSCRIPTION_NOT_PENDING_CHANGE: import("better-auth").RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
942
+ ORGANIZATION_NOT_FOUND: import("better-auth").RawError<"ORGANIZATION_NOT_FOUND">;
943
+ ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: import("better-auth").RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
944
+ AUTHORIZE_REFERENCE_REQUIRED: import("better-auth").RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
945
+ ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: import("better-auth").RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
946
+ ORGANIZATION_REFERENCE_ID_REQUIRED: import("better-auth").RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
952
947
  };
953
948
  };
954
949
  type StripePlugin<O extends StripeOptions> = ReturnType<typeof stripe<O>>;
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as CheckoutSessionLocale, c as StripeOptions, d as SubscriptionOptions, f as WithActiveOrganizationId, i as CheckoutSessionLineItem, l as StripePlan, n as stripe, o as CustomerType, p as WithStripeCustomerId, r as AuthorizeReferenceAction, s as StripeCtxSession, t as StripePlugin, u as Subscription } from "./index-ntN1joRP.mjs";
2
- export { AuthorizeReferenceAction, CheckoutSessionLineItem, CheckoutSessionLocale, CustomerType, StripeCtxSession, StripeOptions, StripePlan, StripePlugin, Subscription, SubscriptionOptions, WithActiveOrganizationId, WithStripeCustomerId, stripe };
1
+ import { a as CheckoutSessionLocale, c as StripeOptions, d as SubscriptionOptions, f as WithActiveOrganizationId, i as CheckoutSessionLineItem, l as StripePlan, n as stripe, o as CustomerType, p as WithStripeCustomerId, r as AuthorizeReferenceAction, s as StripeCtxSession, t as StripePlugin, u as Subscription } from "./index-CbLwZwAG.mjs";
2
+ export { type AuthorizeReferenceAction, type CheckoutSessionLineItem, type CheckoutSessionLocale, type CustomerType, type StripeCtxSession, type StripeOptions, type StripePlan, StripePlugin, type Subscription, type SubscriptionOptions, type WithActiveOrganizationId, type WithStripeCustomerId, stripe };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as STRIPE_ERROR_CODES, t as PACKAGE_VERSION } from "./version-DVUKHm6Z.mjs";
1
+ import { n as STRIPE_ERROR_CODES, t as PACKAGE_VERSION } from "./version-DROhXblk.mjs";
2
2
  import { APIError, HIDE_METADATA } from "better-auth";
3
3
  import { defu } from "defu";
4
4
  import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
@@ -7,7 +7,7 @@ import { getSessionFromCtx, originCheck, sessionMiddleware } from "better-auth/a
7
7
  import * as z from "zod";
8
8
  import { mergeSchema } from "better-auth/db";
9
9
  //#region src/metadata.ts
10
- const UNSAFE_METADATA_KEYS = new Set([
10
+ const UNSAFE_METADATA_KEYS = /* @__PURE__ */ new Set([
11
11
  "__proto__",
12
12
  "constructor",
13
13
  "prototype"
@@ -34,9 +34,15 @@ const customerMetadata = {
34
34
  organizationId: "organizationId",
35
35
  customerType: "customerType"
36
36
  },
37
+ /**
38
+ * Create metadata with internal fields that cannot be overridden by user metadata.
39
+ */
37
40
  set(internalFields, ...userMetadata) {
38
41
  return mergeMetadata(internalFields, userMetadata);
39
42
  },
43
+ /**
44
+ * Extract internal fields from Stripe metadata.
45
+ */
40
46
  get(metadata) {
41
47
  return {
42
48
  userId: metadata?.userId,
@@ -51,9 +57,15 @@ const subscriptionMetadata = {
51
57
  subscriptionId: "subscriptionId",
52
58
  referenceId: "referenceId"
53
59
  },
60
+ /**
61
+ * Create metadata with internal fields that cannot be overridden by user metadata.
62
+ */
54
63
  set(internalFields, ...userMetadata) {
55
64
  return mergeMetadata(internalFields, userMetadata);
56
65
  },
66
+ /**
67
+ * Extract internal fields from Stripe metadata.
68
+ */
57
69
  get(metadata) {
58
70
  return {
59
71
  userId: metadata?.userId,
@@ -539,20 +551,65 @@ async function retrieveStripeSubscription(client, ctx, stripeSubscriptionId) {
539
551
  });
540
552
  }
541
553
  const upgradeSubscriptionBodySchema = z.object({
554
+ /**
555
+ * The name of the plan to subscribe
556
+ */
542
557
  plan: z.string().meta({ description: "The name of the plan to upgrade to. Eg: \"pro\"" }),
558
+ /**
559
+ * If annual plan should be applied.
560
+ */
543
561
  annual: z.boolean().meta({ description: "Whether to upgrade to an annual plan. Eg: true" }).optional(),
562
+ /**
563
+ * Reference ID for the subscription based on customerType:
564
+ * - `user`: defaults to `user.id`
565
+ * - `organization`: defaults to `session.activeOrganizationId`
566
+ */
544
567
  referenceId: z.string().meta({ description: "Reference ID for the subscription. Eg: \"org_123\"" }).optional(),
568
+ /**
569
+ * The Stripe subscription ID to upgrade.
570
+ * If provided and not found, it'll throw an error.
571
+ */
545
572
  subscriptionId: z.string().meta({ description: "The Stripe subscription ID to upgrade. Eg: \"sub_1ABC2DEF3GHI4JKL\"" }).optional(),
573
+ /**
574
+ * Customer type for the subscription.
575
+ * - `user`: User owns the subscription (default)
576
+ * - `organization`: Organization owns the subscription (requires referenceId)
577
+ */
546
578
  customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional(),
579
+ /**
580
+ * Additional metadata to store with the subscription.
581
+ */
547
582
  metadata: z.record(z.string(), z.any()).optional(),
583
+ /**
584
+ * Number of seats for subscriptions.
585
+ */
548
586
  seats: z.number().meta({ description: "Number of seats to upgrade to (if applicable). Eg: 1" }).optional(),
587
+ /**
588
+ * The IETF language tag of the locale Checkout is displayed in.
589
+ * If not provided or set to `auto`, the browser's locale is used.
590
+ */
549
591
  locale: z.custom((localization) => {
550
592
  return typeof localization === "string";
551
593
  }).meta({ description: "The locale to display Checkout in. Eg: 'en', 'ko'. If not provided or set to `auto`, the browser's locale is used." }).optional(),
594
+ /**
595
+ * The URL to which Stripe should send customers when payment or setup is complete.
596
+ */
552
597
  successUrl: z.string().meta({ description: "Callback URL to redirect back after successful subscription. Eg: \"https://example.com/success\"" }).default("/"),
598
+ /**
599
+ * If set, checkout shows a back button and customers will be directed here if they cancel payment.
600
+ */
553
601
  cancelUrl: z.string().meta({ description: "If set, checkout shows a back button and customers will be directed here if they cancel payment. Eg: \"https://example.com/pricing\"" }).default("/"),
602
+ /**
603
+ * The URL to return to from the Billing Portal (used when upgrading existing subscriptions)
604
+ */
554
605
  returnUrl: z.string().meta({ description: "URL to take customers to when they click on the billing portal’s link to return to your website. Eg: \"https://example.com/dashboard\"" }).optional(),
606
+ /**
607
+ * Schedule the plan change at the end of the current billing period instead of applying immediately.
608
+ */
555
609
  scheduleAtPeriodEnd: z.boolean().meta({ description: "Schedule the plan change at the end of the current billing period instead of applying immediately." }).default(false),
610
+ /**
611
+ * Disable Redirect
612
+ */
556
613
  disableRedirect: z.boolean().meta({ description: "Disable redirect after successful subscription. Eg: true" }).default(false)
557
614
  });
558
615
  /**
@@ -726,7 +783,8 @@ const upgradeSubscription = (options) => {
726
783
  const stripeSubscriptionPriceId = planItem?.price.id;
727
784
  const incompleteSubscription = subscriptions.find((sub) => sub.status === "incomplete");
728
785
  const priceId = ctx.body.annual ? plan.annualDiscountPriceId : plan.priceId;
729
- const resolvedPrice = await resolveStripePrice(client, priceId, ctx.body.annual ? plan.annualDiscountLookupKey : plan.lookupKey);
786
+ const lookupKey = ctx.body.annual ? plan.annualDiscountLookupKey : plan.lookupKey;
787
+ const resolvedPrice = await resolveStripePrice(client, priceId, lookupKey);
730
788
  const priceIdToUse = resolvedPrice?.id ?? priceId;
731
789
  if (!priceIdToUse) throw ctx.error("BAD_REQUEST", { message: "Price ID not found for the selected plan" });
732
790
  const isMetered = isMeteredPrice(resolvedPrice);
@@ -1063,8 +1121,16 @@ const upgradeSubscription = (options) => {
1063
1121
  const cancelSubscriptionBodySchema = z.object({
1064
1122
  referenceId: z.string().meta({ description: "Reference id of the subscription to cancel. Eg: '123'" }).optional(),
1065
1123
  subscriptionId: z.string().meta({ description: "The Stripe subscription ID to cancel. Eg: 'sub_1ABC2DEF3GHI4JKL'" }).optional(),
1124
+ /**
1125
+ * Customer type for the subscription.
1126
+ * - `user`: User owns the subscription (default)
1127
+ * - `organization`: Organization owns the subscription
1128
+ */
1066
1129
  customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional(),
1067
1130
  returnUrl: z.string().meta({ description: "URL to take customers to when they click on the billing portal's link to return to your website. Eg: \"/account\"" }),
1131
+ /**
1132
+ * Disable Redirect
1133
+ */
1068
1134
  disableRedirect: z.boolean().meta({ description: "Disable redirect after successful subscription cancellation. Eg: true" }).default(false)
1069
1135
  });
1070
1136
  /**
@@ -1165,6 +1231,11 @@ const cancelSubscription = (options) => {
1165
1231
  const restoreSubscriptionBodySchema = z.object({
1166
1232
  referenceId: z.string().meta({ description: "Reference id of the subscription to restore. Eg: '123'" }).optional(),
1167
1233
  subscriptionId: z.string().meta({ description: "The Stripe subscription ID to restore. Eg: 'sub_1ABC2DEF3GHI4JKL'" }).optional(),
1234
+ /**
1235
+ * Customer type for the subscription.
1236
+ * - `user`: User owns the subscription (default)
1237
+ * - `organization`: Organization owns the subscription
1238
+ */
1168
1239
  customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional()
1169
1240
  });
1170
1241
  const restoreSubscription = (options) => {
@@ -1252,6 +1323,11 @@ const restoreSubscription = (options) => {
1252
1323
  };
1253
1324
  const listActiveSubscriptionsQuerySchema = z.optional(z.object({
1254
1325
  referenceId: z.string().meta({ description: "Reference id of the subscription to list. Eg: '123'" }).optional(),
1326
+ /**
1327
+ * Customer type for the subscription.
1328
+ * - `user`: User owns the subscription (default)
1329
+ * - `organization`: Organization owns the subscription
1330
+ */
1255
1331
  customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional()
1256
1332
  }));
1257
1333
  /**
@@ -1383,12 +1459,24 @@ const subscriptionSuccess = (options) => {
1383
1459
  });
1384
1460
  };
1385
1461
  const createBillingPortalBodySchema = z.object({
1462
+ /**
1463
+ * The IETF language tag of the locale Customer Portal is displayed in.
1464
+ * If not provided or set to `auto`, the browser's locale is used.
1465
+ */
1386
1466
  locale: z.custom((localization) => {
1387
1467
  return typeof localization === "string";
1388
1468
  }).meta({ description: "The IETF language tag of the locale Customer Portal is displayed in. Eg: 'en', 'ko'. If not provided or set to `auto`, the browser's locale is used." }).optional(),
1389
1469
  referenceId: z.string().optional(),
1470
+ /**
1471
+ * Customer type for the subscription.
1472
+ * - `user`: User owns the subscription (default)
1473
+ * - `organization`: Organization owns the subscription
1474
+ */
1390
1475
  customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional(),
1391
1476
  returnUrl: z.string().default("/"),
1477
+ /**
1478
+ * Disable Redirect
1479
+ */
1392
1480
  disableRedirect: z.boolean().meta({ description: "Disable redirect after creating billing portal session. Eg: true" }).default(false)
1393
1481
  });
1394
1482
  const createBillingPortal = (options) => {
@@ -1733,8 +1821,8 @@ const stripe = (options) => {
1733
1821
  await existingHooks.afterUpdateOrganization(data);
1734
1822
  await afterUpdateStripeOrg(data);
1735
1823
  } : afterUpdateStripeOrg,
1736
- beforeDeleteOrganization: existingHooks.beforeDeleteOrganization ? async (data) => {
1737
- await existingHooks.beforeDeleteOrganization(data);
1824
+ beforeDeleteOrganization: existingHooks.beforeDeleteOrganization ? async (data, ctx) => {
1825
+ await existingHooks.beforeDeleteOrganization(data, ctx);
1738
1826
  await beforeDeleteStripeOrg(data);
1739
1827
  } : beforeDeleteStripeOrg,
1740
1828
  afterAddMember: existingHooks.afterAddMember ? async (data) => {
@@ -17,6 +17,9 @@ const STRIPE_ERROR_CODES = defineErrorCodes({
17
17
  FAILED_TO_FETCH_PLANS: "Failed to fetch plans",
18
18
  EMAIL_VERIFICATION_REQUIRED: "Email verification is required before you can subscribe to a plan",
19
19
  SUBSCRIPTION_NOT_ACTIVE: "Subscription is not active",
20
+ /**
21
+ * @deprecated Use `SUBSCRIPTION_NOT_PENDING_CHANGE` instead.
22
+ */
20
23
  SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: "Subscription is not scheduled for cancellation",
21
24
  SUBSCRIPTION_NOT_PENDING_CHANGE: "Subscription has no pending cancellation or scheduled plan change",
22
25
  ORGANIZATION_NOT_FOUND: "Organization not found",
@@ -27,6 +30,6 @@ const STRIPE_ERROR_CODES = defineErrorCodes({
27
30
  });
28
31
  //#endregion
29
32
  //#region src/version.ts
30
- const PACKAGE_VERSION = "1.6.23";
33
+ const PACKAGE_VERSION = "1.6.25";
31
34
  //#endregion
32
35
  export { STRIPE_ERROR_CODES as n, PACKAGE_VERSION as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/stripe",
3
- "version": "1.6.23",
3
+ "version": "1.6.25",
4
4
  "description": "Stripe plugin for Better Auth",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -57,15 +57,15 @@
57
57
  "devDependencies": {
58
58
  "better-call": "1.3.7",
59
59
  "stripe": "^22.0.1",
60
- "tsdown": "0.21.1",
61
- "@better-auth/core": "1.6.23",
62
- "better-auth": "1.6.23"
60
+ "tsdown": "0.22.7",
61
+ "@better-auth/core": "1.6.25",
62
+ "better-auth": "1.6.25"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "better-call": "1.3.7",
66
66
  "stripe": "^18 || ^19 || ^20 || ^21 || ^22",
67
- "@better-auth/core": "^1.6.23",
68
- "better-auth": "^1.6.23"
67
+ "@better-auth/core": "^1.6.25",
68
+ "better-auth": "^1.6.25"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "tsdown",