@better-auth/stripe 1.3.0-beta.7 → 1.3.0-beta.9

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.
@@ -1,17 +1,17 @@
1
1
 
2
- > @better-auth/stripe@1.3.0-beta.7 build /home/runner/work/better-auth/better-auth/packages/stripe
2
+ > @better-auth/stripe@1.3.0-beta.9 build /home/runner/work/better-auth/better-auth/packages/stripe
3
3
  > unbuild
4
4
 
5
5
  [info] Automatically detected entries: src/index, src/client [esm] [cjs] [dts]
6
6
  [info] Building stripe
7
7
  [success] Build succeeded for stripe
8
- [log] dist/index.cjs (total size: 38.5 kB, chunk size: 38.5 kB, exports: stripe)
8
+ [log] dist/index.cjs (total size: 39 kB, chunk size: 39 kB, exports: stripe)
9
9
 
10
10
  [log] dist/client.cjs (total size: 224 B, chunk size: 224 B, exports: stripeClient)
11
11
 
12
- [log] dist/index.mjs (total size: 38.2 kB, chunk size: 38.2 kB, exports: stripe)
12
+ [log] dist/index.mjs (total size: 38.3 kB, chunk size: 38.3 kB, exports: stripe)
13
13
 
14
14
  [log] dist/client.mjs (total size: 197 B, chunk size: 197 B, exports: stripeClient)
15
15
 
16
- Σ Total dist size (byte size): 204 kB
16
+ Σ Total dist size (byte size): 195 kB
17
17
  [log]
package/dist/client.d.cts CHANGED
@@ -2,7 +2,7 @@ import { stripe } from './index.cjs';
2
2
  import 'better-auth';
3
3
  import 'better-call';
4
4
  import 'stripe';
5
- import 'zod';
5
+ import 'zod/v4';
6
6
  import 'better-auth/api';
7
7
 
8
8
  declare const stripeClient: <O extends {
package/dist/client.d.mts CHANGED
@@ -2,7 +2,7 @@ import { stripe } from './index.mjs';
2
2
  import 'better-auth';
3
3
  import 'better-call';
4
4
  import 'stripe';
5
- import 'zod';
5
+ import 'zod/v4';
6
6
  import 'better-auth/api';
7
7
 
8
8
  declare const stripeClient: <O extends {
package/dist/client.d.ts CHANGED
@@ -2,7 +2,7 @@ import { stripe } from './index.js';
2
2
  import 'better-auth';
3
3
  import 'better-call';
4
4
  import 'stripe';
5
- import 'zod';
5
+ import 'zod/v4';
6
6
  import 'better-auth/api';
7
7
 
8
8
  declare const stripeClient: <O extends {
package/dist/index.cjs CHANGED
@@ -2,11 +2,25 @@
2
2
 
3
3
  const betterAuth = require('better-auth');
4
4
  const plugins = require('better-auth/plugins');
5
- const zod = require('zod');
5
+ const z = require('zod/v4');
6
6
  const api = require('better-auth/api');
7
7
  const crypto = require('better-auth/crypto');
8
8
  const db = require('better-auth/db');
9
9
 
10
+ function _interopNamespaceCompat(e) {
11
+ if (e && typeof e === 'object' && 'default' in e) return e;
12
+ const n = Object.create(null);
13
+ if (e) {
14
+ for (const k in e) {
15
+ n[k] = e[k];
16
+ }
17
+ }
18
+ n.default = e;
19
+ return n;
20
+ }
21
+
22
+ const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
23
+
10
24
  async function getPlans(options) {
11
25
  return typeof options?.subscription?.plans === "function" ? await options.subscription?.plans() : options.subscription?.plans;
12
26
  }
@@ -348,17 +362,17 @@ const stripe = (options) => {
348
362
  "/subscription/upgrade",
349
363
  {
350
364
  method: "POST",
351
- body: zod.z.object({
365
+ body: z__namespace.object({
352
366
  /**
353
367
  * The name of the plan to subscribe
354
368
  */
355
- plan: zod.z.string({
369
+ plan: z__namespace.string().meta({
356
370
  description: "The name of the plan to upgrade to"
357
371
  }),
358
372
  /**
359
373
  * If annual plan should be applied.
360
374
  */
361
- annual: zod.z.boolean({
375
+ annual: z__namespace.boolean().meta({
362
376
  description: "Whether to upgrade to an annual plan"
363
377
  }).optional(),
364
378
  /**
@@ -366,7 +380,7 @@ const stripe = (options) => {
366
380
  * This is used to identify the subscription to upgrade
367
381
  * If not provided, the user's id will be used
368
382
  */
369
- referenceId: zod.z.string({
383
+ referenceId: z__namespace.string().meta({
370
384
  description: "Reference id of the subscription to upgrade"
371
385
  }).optional(),
372
386
  /**
@@ -374,40 +388,40 @@ const stripe = (options) => {
374
388
  * If subscription id is provided, and subscription isn't found,
375
389
  * it'll throw an error.
376
390
  */
377
- subscriptionId: zod.z.string({
391
+ subscriptionId: z__namespace.string().meta({
378
392
  description: "The id of the subscription to upgrade"
379
393
  }).optional(),
380
394
  /**
381
395
  * Any additional data you want to store in your database
382
396
  * subscriptions
383
397
  */
384
- metadata: zod.z.record(zod.z.string(), zod.z.any()).optional(),
398
+ metadata: z__namespace.record(z__namespace.string(), z__namespace.any()).optional(),
385
399
  /**
386
400
  * If a subscription
387
401
  */
388
- seats: zod.z.number({
402
+ seats: z__namespace.number().meta({
389
403
  description: "Number of seats to upgrade to (if applicable)"
390
404
  }).optional(),
391
405
  /**
392
406
  * Success URL to redirect back after successful subscription
393
407
  */
394
- successUrl: zod.z.string({
408
+ successUrl: z__namespace.string().meta({
395
409
  description: "Callback URL to redirect back after successful subscription"
396
410
  }).default("/"),
397
411
  /**
398
412
  * Cancel URL
399
413
  */
400
- cancelUrl: zod.z.string({
414
+ cancelUrl: z__namespace.string().meta({
401
415
  description: "Callback URL to redirect back after successful subscription"
402
416
  }).default("/"),
403
417
  /**
404
418
  * Return URL
405
419
  */
406
- returnUrl: zod.z.string().optional(),
420
+ returnUrl: z__namespace.string().optional(),
407
421
  /**
408
422
  * Disable Redirect
409
423
  */
410
- disableRedirect: zod.z.boolean().default(false)
424
+ disableRedirect: z__namespace.boolean().default(false)
411
425
  }),
412
426
  use: [
413
427
  api.sessionMiddleware,
@@ -642,7 +656,7 @@ const stripe = (options) => {
642
656
  "/subscription/cancel/callback",
643
657
  {
644
658
  method: "GET",
645
- query: zod.z.record(zod.z.string(), zod.z.any()).optional(),
659
+ query: z__namespace.record(z__namespace.string(), z__namespace.any()).optional(),
646
660
  use: [api.originCheck((ctx) => ctx.query.callbackURL)]
647
661
  },
648
662
  async (ctx) => {
@@ -713,10 +727,10 @@ const stripe = (options) => {
713
727
  "/subscription/cancel",
714
728
  {
715
729
  method: "POST",
716
- body: zod.z.object({
717
- referenceId: zod.z.string().optional(),
718
- subscriptionId: zod.z.string().optional(),
719
- returnUrl: zod.z.string()
730
+ body: z__namespace.object({
731
+ referenceId: z__namespace.string().optional(),
732
+ subscriptionId: z__namespace.string().optional(),
733
+ returnUrl: z__namespace.string()
720
734
  }),
721
735
  use: [
722
736
  api.sessionMiddleware,
@@ -822,9 +836,9 @@ const stripe = (options) => {
822
836
  "/subscription/restore",
823
837
  {
824
838
  method: "POST",
825
- body: zod.z.object({
826
- referenceId: zod.z.string().optional(),
827
- subscriptionId: zod.z.string().optional()
839
+ body: z__namespace.object({
840
+ referenceId: z__namespace.string().optional(),
841
+ subscriptionId: z__namespace.string().optional()
828
842
  }),
829
843
  use: [api.sessionMiddleware, referenceMiddleware("restore-subscription")]
830
844
  },
@@ -911,9 +925,9 @@ const stripe = (options) => {
911
925
  "/subscription/list",
912
926
  {
913
927
  method: "GET",
914
- query: zod.z.optional(
915
- zod.z.object({
916
- referenceId: zod.z.string().optional()
928
+ query: z__namespace.optional(
929
+ z__namespace.object({
930
+ referenceId: z__namespace.string().optional()
917
931
  })
918
932
  ),
919
933
  use: [api.sessionMiddleware, referenceMiddleware("list-subscription")]
@@ -954,7 +968,7 @@ const stripe = (options) => {
954
968
  "/subscription/success",
955
969
  {
956
970
  method: "GET",
957
- query: zod.z.record(zod.z.string(), zod.z.any()).optional(),
971
+ query: z__namespace.record(z__namespace.string(), z__namespace.any()).optional(),
958
972
  use: [api.originCheck((ctx) => ctx.query.callbackURL)]
959
973
  },
960
974
  async (ctx) => {
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import * as better_auth from 'better-auth';
2
2
  import { User, Session, InferOptionSchema, GenericEndpointContext } from 'better-auth';
3
3
  import * as better_call from 'better-call';
4
4
  import Stripe from 'stripe';
5
- import { z } from 'zod';
5
+ import * as z from 'zod/v4';
6
6
  import { APIError } from 'better-auth/api';
7
7
 
8
8
  declare const subscriptions: {
@@ -397,10 +397,10 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
397
397
  <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
398
398
  body: {
399
399
  plan: string;
400
- metadata?: Record<string, any> | undefined;
401
400
  annual?: boolean | undefined;
402
401
  referenceId?: string | undefined;
403
402
  subscriptionId?: string | undefined;
403
+ metadata?: Record<string, any> | undefined;
404
404
  seats?: number | undefined;
405
405
  successUrl?: string | undefined;
406
406
  cancelUrl?: string | undefined;
@@ -584,91 +584,34 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
584
584
  options: {
585
585
  method: "POST";
586
586
  body: z.ZodObject<{
587
- /**
588
- * The name of the plan to subscribe
589
- */
590
587
  plan: z.ZodString;
591
- /**
592
- * If annual plan should be applied.
593
- */
594
588
  annual: z.ZodOptional<z.ZodBoolean>;
595
- /**
596
- * Reference id of the subscription to upgrade
597
- * This is used to identify the subscription to upgrade
598
- * If not provided, the user's id will be used
599
- */
600
589
  referenceId: z.ZodOptional<z.ZodString>;
601
- /**
602
- * This is to allow a specific subscription to be upgrade.
603
- * If subscription id is provided, and subscription isn't found,
604
- * it'll throw an error.
605
- */
606
590
  subscriptionId: z.ZodOptional<z.ZodString>;
607
- /**
608
- * Any additional data you want to store in your database
609
- * subscriptions
610
- */
611
591
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
612
- /**
613
- * If a subscription
614
- */
615
592
  seats: z.ZodOptional<z.ZodNumber>;
616
- /**
617
- * Success URL to redirect back after successful subscription
618
- */
619
593
  successUrl: z.ZodDefault<z.ZodString>;
620
- /**
621
- * Cancel URL
622
- */
623
594
  cancelUrl: z.ZodDefault<z.ZodString>;
624
- /**
625
- * Return URL
626
- */
627
595
  returnUrl: z.ZodOptional<z.ZodString>;
628
- /**
629
- * Disable Redirect
630
- */
631
596
  disableRedirect: z.ZodDefault<z.ZodBoolean>;
632
- }, "strip", z.ZodTypeAny, {
633
- plan: string;
634
- successUrl: string;
635
- cancelUrl: string;
636
- disableRedirect: boolean;
637
- metadata?: Record<string, any> | undefined;
638
- annual?: boolean | undefined;
639
- referenceId?: string | undefined;
640
- subscriptionId?: string | undefined;
641
- seats?: number | undefined;
642
- returnUrl?: string | undefined;
643
- }, {
644
- plan: string;
645
- metadata?: Record<string, any> | undefined;
646
- annual?: boolean | undefined;
647
- referenceId?: string | undefined;
648
- subscriptionId?: string | undefined;
649
- seats?: number | undefined;
650
- successUrl?: string | undefined;
651
- cancelUrl?: string | undefined;
652
- returnUrl?: string | undefined;
653
- disableRedirect?: boolean | undefined;
654
- }>;
597
+ }, z.core.$strip>;
655
598
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
656
599
  session: {
657
600
  session: Record<string, any> & {
658
601
  id: string;
659
- token: string;
660
602
  userId: string;
661
603
  expiresAt: Date;
662
604
  createdAt: Date;
663
605
  updatedAt: Date;
606
+ token: string;
664
607
  ipAddress?: string | null | undefined;
665
608
  userAgent?: string | null | undefined;
666
609
  };
667
610
  user: Record<string, any> & {
668
611
  id: string;
669
- name: string;
670
- emailVerified: boolean;
671
612
  email: string;
613
+ emailVerified: boolean;
614
+ name: string;
672
615
  createdAt: Date;
673
616
  updatedAt: Date;
674
617
  image?: string | null | undefined;
@@ -755,32 +698,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
755
698
  referenceId: z.ZodOptional<z.ZodString>;
756
699
  subscriptionId: z.ZodOptional<z.ZodString>;
757
700
  returnUrl: z.ZodString;
758
- }, "strip", z.ZodTypeAny, {
759
- returnUrl: string;
760
- referenceId?: string | undefined;
761
- subscriptionId?: string | undefined;
762
- }, {
763
- returnUrl: string;
764
- referenceId?: string | undefined;
765
- subscriptionId?: string | undefined;
766
- }>;
701
+ }, z.core.$strip>;
767
702
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
768
703
  session: {
769
704
  session: Record<string, any> & {
770
705
  id: string;
771
- token: string;
772
706
  userId: string;
773
707
  expiresAt: Date;
774
708
  createdAt: Date;
775
709
  updatedAt: Date;
710
+ token: string;
776
711
  ipAddress?: string | null | undefined;
777
712
  userAgent?: string | null | undefined;
778
713
  };
779
714
  user: Record<string, any> & {
780
715
  id: string;
781
- name: string;
782
- emailVerified: boolean;
783
716
  email: string;
717
+ emailVerified: boolean;
718
+ name: string;
784
719
  createdAt: Date;
785
720
  updatedAt: Date;
786
721
  image?: string | null | undefined;
@@ -825,30 +760,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
825
760
  body: z.ZodObject<{
826
761
  referenceId: z.ZodOptional<z.ZodString>;
827
762
  subscriptionId: z.ZodOptional<z.ZodString>;
828
- }, "strip", z.ZodTypeAny, {
829
- referenceId?: string | undefined;
830
- subscriptionId?: string | undefined;
831
- }, {
832
- referenceId?: string | undefined;
833
- subscriptionId?: string | undefined;
834
- }>;
763
+ }, z.core.$strip>;
835
764
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
836
765
  session: {
837
766
  session: Record<string, any> & {
838
767
  id: string;
839
- token: string;
840
768
  userId: string;
841
769
  expiresAt: Date;
842
770
  createdAt: Date;
843
771
  updatedAt: Date;
772
+ token: string;
844
773
  ipAddress?: string | null | undefined;
845
774
  userAgent?: string | null | undefined;
846
775
  };
847
776
  user: Record<string, any> & {
848
777
  id: string;
849
- name: string;
850
- emailVerified: boolean;
851
778
  email: string;
779
+ emailVerified: boolean;
780
+ name: string;
852
781
  createdAt: Date;
853
782
  updatedAt: Date;
854
783
  image?: string | null | undefined;
@@ -923,28 +852,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
923
852
  method: "GET";
924
853
  query: z.ZodOptional<z.ZodObject<{
925
854
  referenceId: z.ZodOptional<z.ZodString>;
926
- }, "strip", z.ZodTypeAny, {
927
- referenceId?: string | undefined;
928
- }, {
929
- referenceId?: string | undefined;
930
- }>>;
855
+ }, z.core.$strip>>;
931
856
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
932
857
  session: {
933
858
  session: Record<string, any> & {
934
859
  id: string;
935
- token: string;
936
860
  userId: string;
937
861
  expiresAt: Date;
938
862
  createdAt: Date;
939
863
  updatedAt: Date;
864
+ token: string;
940
865
  ipAddress?: string | null | undefined;
941
866
  userAgent?: string | null | undefined;
942
867
  };
943
868
  user: Record<string, any> & {
944
869
  id: string;
945
- name: string;
946
- emailVerified: boolean;
947
870
  email: string;
871
+ emailVerified: boolean;
872
+ name: string;
948
873
  createdAt: Date;
949
874
  updatedAt: Date;
950
875
  image?: string | null | undefined;
@@ -998,9 +923,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
998
923
  create: {
999
924
  after(user: {
1000
925
  id: string;
1001
- name: string;
1002
- emailVerified: boolean;
1003
926
  email: string;
927
+ emailVerified: boolean;
928
+ name: string;
1004
929
  createdAt: Date;
1005
930
  updatedAt: Date;
1006
931
  image?: string | null | undefined;
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import * as better_auth from 'better-auth';
2
2
  import { User, Session, InferOptionSchema, GenericEndpointContext } from 'better-auth';
3
3
  import * as better_call from 'better-call';
4
4
  import Stripe from 'stripe';
5
- import { z } from 'zod';
5
+ import * as z from 'zod/v4';
6
6
  import { APIError } from 'better-auth/api';
7
7
 
8
8
  declare const subscriptions: {
@@ -397,10 +397,10 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
397
397
  <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
398
398
  body: {
399
399
  plan: string;
400
- metadata?: Record<string, any> | undefined;
401
400
  annual?: boolean | undefined;
402
401
  referenceId?: string | undefined;
403
402
  subscriptionId?: string | undefined;
403
+ metadata?: Record<string, any> | undefined;
404
404
  seats?: number | undefined;
405
405
  successUrl?: string | undefined;
406
406
  cancelUrl?: string | undefined;
@@ -584,91 +584,34 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
584
584
  options: {
585
585
  method: "POST";
586
586
  body: z.ZodObject<{
587
- /**
588
- * The name of the plan to subscribe
589
- */
590
587
  plan: z.ZodString;
591
- /**
592
- * If annual plan should be applied.
593
- */
594
588
  annual: z.ZodOptional<z.ZodBoolean>;
595
- /**
596
- * Reference id of the subscription to upgrade
597
- * This is used to identify the subscription to upgrade
598
- * If not provided, the user's id will be used
599
- */
600
589
  referenceId: z.ZodOptional<z.ZodString>;
601
- /**
602
- * This is to allow a specific subscription to be upgrade.
603
- * If subscription id is provided, and subscription isn't found,
604
- * it'll throw an error.
605
- */
606
590
  subscriptionId: z.ZodOptional<z.ZodString>;
607
- /**
608
- * Any additional data you want to store in your database
609
- * subscriptions
610
- */
611
591
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
612
- /**
613
- * If a subscription
614
- */
615
592
  seats: z.ZodOptional<z.ZodNumber>;
616
- /**
617
- * Success URL to redirect back after successful subscription
618
- */
619
593
  successUrl: z.ZodDefault<z.ZodString>;
620
- /**
621
- * Cancel URL
622
- */
623
594
  cancelUrl: z.ZodDefault<z.ZodString>;
624
- /**
625
- * Return URL
626
- */
627
595
  returnUrl: z.ZodOptional<z.ZodString>;
628
- /**
629
- * Disable Redirect
630
- */
631
596
  disableRedirect: z.ZodDefault<z.ZodBoolean>;
632
- }, "strip", z.ZodTypeAny, {
633
- plan: string;
634
- successUrl: string;
635
- cancelUrl: string;
636
- disableRedirect: boolean;
637
- metadata?: Record<string, any> | undefined;
638
- annual?: boolean | undefined;
639
- referenceId?: string | undefined;
640
- subscriptionId?: string | undefined;
641
- seats?: number | undefined;
642
- returnUrl?: string | undefined;
643
- }, {
644
- plan: string;
645
- metadata?: Record<string, any> | undefined;
646
- annual?: boolean | undefined;
647
- referenceId?: string | undefined;
648
- subscriptionId?: string | undefined;
649
- seats?: number | undefined;
650
- successUrl?: string | undefined;
651
- cancelUrl?: string | undefined;
652
- returnUrl?: string | undefined;
653
- disableRedirect?: boolean | undefined;
654
- }>;
597
+ }, z.core.$strip>;
655
598
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
656
599
  session: {
657
600
  session: Record<string, any> & {
658
601
  id: string;
659
- token: string;
660
602
  userId: string;
661
603
  expiresAt: Date;
662
604
  createdAt: Date;
663
605
  updatedAt: Date;
606
+ token: string;
664
607
  ipAddress?: string | null | undefined;
665
608
  userAgent?: string | null | undefined;
666
609
  };
667
610
  user: Record<string, any> & {
668
611
  id: string;
669
- name: string;
670
- emailVerified: boolean;
671
612
  email: string;
613
+ emailVerified: boolean;
614
+ name: string;
672
615
  createdAt: Date;
673
616
  updatedAt: Date;
674
617
  image?: string | null | undefined;
@@ -755,32 +698,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
755
698
  referenceId: z.ZodOptional<z.ZodString>;
756
699
  subscriptionId: z.ZodOptional<z.ZodString>;
757
700
  returnUrl: z.ZodString;
758
- }, "strip", z.ZodTypeAny, {
759
- returnUrl: string;
760
- referenceId?: string | undefined;
761
- subscriptionId?: string | undefined;
762
- }, {
763
- returnUrl: string;
764
- referenceId?: string | undefined;
765
- subscriptionId?: string | undefined;
766
- }>;
701
+ }, z.core.$strip>;
767
702
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
768
703
  session: {
769
704
  session: Record<string, any> & {
770
705
  id: string;
771
- token: string;
772
706
  userId: string;
773
707
  expiresAt: Date;
774
708
  createdAt: Date;
775
709
  updatedAt: Date;
710
+ token: string;
776
711
  ipAddress?: string | null | undefined;
777
712
  userAgent?: string | null | undefined;
778
713
  };
779
714
  user: Record<string, any> & {
780
715
  id: string;
781
- name: string;
782
- emailVerified: boolean;
783
716
  email: string;
717
+ emailVerified: boolean;
718
+ name: string;
784
719
  createdAt: Date;
785
720
  updatedAt: Date;
786
721
  image?: string | null | undefined;
@@ -825,30 +760,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
825
760
  body: z.ZodObject<{
826
761
  referenceId: z.ZodOptional<z.ZodString>;
827
762
  subscriptionId: z.ZodOptional<z.ZodString>;
828
- }, "strip", z.ZodTypeAny, {
829
- referenceId?: string | undefined;
830
- subscriptionId?: string | undefined;
831
- }, {
832
- referenceId?: string | undefined;
833
- subscriptionId?: string | undefined;
834
- }>;
763
+ }, z.core.$strip>;
835
764
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
836
765
  session: {
837
766
  session: Record<string, any> & {
838
767
  id: string;
839
- token: string;
840
768
  userId: string;
841
769
  expiresAt: Date;
842
770
  createdAt: Date;
843
771
  updatedAt: Date;
772
+ token: string;
844
773
  ipAddress?: string | null | undefined;
845
774
  userAgent?: string | null | undefined;
846
775
  };
847
776
  user: Record<string, any> & {
848
777
  id: string;
849
- name: string;
850
- emailVerified: boolean;
851
778
  email: string;
779
+ emailVerified: boolean;
780
+ name: string;
852
781
  createdAt: Date;
853
782
  updatedAt: Date;
854
783
  image?: string | null | undefined;
@@ -923,28 +852,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
923
852
  method: "GET";
924
853
  query: z.ZodOptional<z.ZodObject<{
925
854
  referenceId: z.ZodOptional<z.ZodString>;
926
- }, "strip", z.ZodTypeAny, {
927
- referenceId?: string | undefined;
928
- }, {
929
- referenceId?: string | undefined;
930
- }>>;
855
+ }, z.core.$strip>>;
931
856
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
932
857
  session: {
933
858
  session: Record<string, any> & {
934
859
  id: string;
935
- token: string;
936
860
  userId: string;
937
861
  expiresAt: Date;
938
862
  createdAt: Date;
939
863
  updatedAt: Date;
864
+ token: string;
940
865
  ipAddress?: string | null | undefined;
941
866
  userAgent?: string | null | undefined;
942
867
  };
943
868
  user: Record<string, any> & {
944
869
  id: string;
945
- name: string;
946
- emailVerified: boolean;
947
870
  email: string;
871
+ emailVerified: boolean;
872
+ name: string;
948
873
  createdAt: Date;
949
874
  updatedAt: Date;
950
875
  image?: string | null | undefined;
@@ -998,9 +923,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
998
923
  create: {
999
924
  after(user: {
1000
925
  id: string;
1001
- name: string;
1002
- emailVerified: boolean;
1003
926
  email: string;
927
+ emailVerified: boolean;
928
+ name: string;
1004
929
  createdAt: Date;
1005
930
  updatedAt: Date;
1006
931
  image?: string | null | undefined;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as better_auth from 'better-auth';
2
2
  import { User, Session, InferOptionSchema, GenericEndpointContext } from 'better-auth';
3
3
  import * as better_call from 'better-call';
4
4
  import Stripe from 'stripe';
5
- import { z } from 'zod';
5
+ import * as z from 'zod/v4';
6
6
  import { APIError } from 'better-auth/api';
7
7
 
8
8
  declare const subscriptions: {
@@ -397,10 +397,10 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
397
397
  <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
398
398
  body: {
399
399
  plan: string;
400
- metadata?: Record<string, any> | undefined;
401
400
  annual?: boolean | undefined;
402
401
  referenceId?: string | undefined;
403
402
  subscriptionId?: string | undefined;
403
+ metadata?: Record<string, any> | undefined;
404
404
  seats?: number | undefined;
405
405
  successUrl?: string | undefined;
406
406
  cancelUrl?: string | undefined;
@@ -584,91 +584,34 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
584
584
  options: {
585
585
  method: "POST";
586
586
  body: z.ZodObject<{
587
- /**
588
- * The name of the plan to subscribe
589
- */
590
587
  plan: z.ZodString;
591
- /**
592
- * If annual plan should be applied.
593
- */
594
588
  annual: z.ZodOptional<z.ZodBoolean>;
595
- /**
596
- * Reference id of the subscription to upgrade
597
- * This is used to identify the subscription to upgrade
598
- * If not provided, the user's id will be used
599
- */
600
589
  referenceId: z.ZodOptional<z.ZodString>;
601
- /**
602
- * This is to allow a specific subscription to be upgrade.
603
- * If subscription id is provided, and subscription isn't found,
604
- * it'll throw an error.
605
- */
606
590
  subscriptionId: z.ZodOptional<z.ZodString>;
607
- /**
608
- * Any additional data you want to store in your database
609
- * subscriptions
610
- */
611
591
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
612
- /**
613
- * If a subscription
614
- */
615
592
  seats: z.ZodOptional<z.ZodNumber>;
616
- /**
617
- * Success URL to redirect back after successful subscription
618
- */
619
593
  successUrl: z.ZodDefault<z.ZodString>;
620
- /**
621
- * Cancel URL
622
- */
623
594
  cancelUrl: z.ZodDefault<z.ZodString>;
624
- /**
625
- * Return URL
626
- */
627
595
  returnUrl: z.ZodOptional<z.ZodString>;
628
- /**
629
- * Disable Redirect
630
- */
631
596
  disableRedirect: z.ZodDefault<z.ZodBoolean>;
632
- }, "strip", z.ZodTypeAny, {
633
- plan: string;
634
- successUrl: string;
635
- cancelUrl: string;
636
- disableRedirect: boolean;
637
- metadata?: Record<string, any> | undefined;
638
- annual?: boolean | undefined;
639
- referenceId?: string | undefined;
640
- subscriptionId?: string | undefined;
641
- seats?: number | undefined;
642
- returnUrl?: string | undefined;
643
- }, {
644
- plan: string;
645
- metadata?: Record<string, any> | undefined;
646
- annual?: boolean | undefined;
647
- referenceId?: string | undefined;
648
- subscriptionId?: string | undefined;
649
- seats?: number | undefined;
650
- successUrl?: string | undefined;
651
- cancelUrl?: string | undefined;
652
- returnUrl?: string | undefined;
653
- disableRedirect?: boolean | undefined;
654
- }>;
597
+ }, z.core.$strip>;
655
598
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
656
599
  session: {
657
600
  session: Record<string, any> & {
658
601
  id: string;
659
- token: string;
660
602
  userId: string;
661
603
  expiresAt: Date;
662
604
  createdAt: Date;
663
605
  updatedAt: Date;
606
+ token: string;
664
607
  ipAddress?: string | null | undefined;
665
608
  userAgent?: string | null | undefined;
666
609
  };
667
610
  user: Record<string, any> & {
668
611
  id: string;
669
- name: string;
670
- emailVerified: boolean;
671
612
  email: string;
613
+ emailVerified: boolean;
614
+ name: string;
672
615
  createdAt: Date;
673
616
  updatedAt: Date;
674
617
  image?: string | null | undefined;
@@ -755,32 +698,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
755
698
  referenceId: z.ZodOptional<z.ZodString>;
756
699
  subscriptionId: z.ZodOptional<z.ZodString>;
757
700
  returnUrl: z.ZodString;
758
- }, "strip", z.ZodTypeAny, {
759
- returnUrl: string;
760
- referenceId?: string | undefined;
761
- subscriptionId?: string | undefined;
762
- }, {
763
- returnUrl: string;
764
- referenceId?: string | undefined;
765
- subscriptionId?: string | undefined;
766
- }>;
701
+ }, z.core.$strip>;
767
702
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
768
703
  session: {
769
704
  session: Record<string, any> & {
770
705
  id: string;
771
- token: string;
772
706
  userId: string;
773
707
  expiresAt: Date;
774
708
  createdAt: Date;
775
709
  updatedAt: Date;
710
+ token: string;
776
711
  ipAddress?: string | null | undefined;
777
712
  userAgent?: string | null | undefined;
778
713
  };
779
714
  user: Record<string, any> & {
780
715
  id: string;
781
- name: string;
782
- emailVerified: boolean;
783
716
  email: string;
717
+ emailVerified: boolean;
718
+ name: string;
784
719
  createdAt: Date;
785
720
  updatedAt: Date;
786
721
  image?: string | null | undefined;
@@ -825,30 +760,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
825
760
  body: z.ZodObject<{
826
761
  referenceId: z.ZodOptional<z.ZodString>;
827
762
  subscriptionId: z.ZodOptional<z.ZodString>;
828
- }, "strip", z.ZodTypeAny, {
829
- referenceId?: string | undefined;
830
- subscriptionId?: string | undefined;
831
- }, {
832
- referenceId?: string | undefined;
833
- subscriptionId?: string | undefined;
834
- }>;
763
+ }, z.core.$strip>;
835
764
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
836
765
  session: {
837
766
  session: Record<string, any> & {
838
767
  id: string;
839
- token: string;
840
768
  userId: string;
841
769
  expiresAt: Date;
842
770
  createdAt: Date;
843
771
  updatedAt: Date;
772
+ token: string;
844
773
  ipAddress?: string | null | undefined;
845
774
  userAgent?: string | null | undefined;
846
775
  };
847
776
  user: Record<string, any> & {
848
777
  id: string;
849
- name: string;
850
- emailVerified: boolean;
851
778
  email: string;
779
+ emailVerified: boolean;
780
+ name: string;
852
781
  createdAt: Date;
853
782
  updatedAt: Date;
854
783
  image?: string | null | undefined;
@@ -923,28 +852,24 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
923
852
  method: "GET";
924
853
  query: z.ZodOptional<z.ZodObject<{
925
854
  referenceId: z.ZodOptional<z.ZodString>;
926
- }, "strip", z.ZodTypeAny, {
927
- referenceId?: string | undefined;
928
- }, {
929
- referenceId?: string | undefined;
930
- }>>;
855
+ }, z.core.$strip>>;
931
856
  use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
932
857
  session: {
933
858
  session: Record<string, any> & {
934
859
  id: string;
935
- token: string;
936
860
  userId: string;
937
861
  expiresAt: Date;
938
862
  createdAt: Date;
939
863
  updatedAt: Date;
864
+ token: string;
940
865
  ipAddress?: string | null | undefined;
941
866
  userAgent?: string | null | undefined;
942
867
  };
943
868
  user: Record<string, any> & {
944
869
  id: string;
945
- name: string;
946
- emailVerified: boolean;
947
870
  email: string;
871
+ emailVerified: boolean;
872
+ name: string;
948
873
  createdAt: Date;
949
874
  updatedAt: Date;
950
875
  image?: string | null | undefined;
@@ -998,9 +923,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
998
923
  create: {
999
924
  after(user: {
1000
925
  id: string;
1001
- name: string;
1002
- emailVerified: boolean;
1003
926
  email: string;
927
+ emailVerified: boolean;
928
+ name: string;
1004
929
  createdAt: Date;
1005
930
  updatedAt: Date;
1006
931
  image?: string | null | undefined;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { logger } from 'better-auth';
2
2
  import { createAuthEndpoint, createAuthMiddleware } from 'better-auth/plugins';
3
- import { z } from 'zod';
3
+ import * as z from 'zod/v4';
4
4
  import { originCheck, getSessionFromCtx, sessionMiddleware, APIError } from 'better-auth/api';
5
5
  import { generateRandomString } from 'better-auth/crypto';
6
6
  import { mergeSchema } from 'better-auth/db';
@@ -350,13 +350,13 @@ const stripe = (options) => {
350
350
  /**
351
351
  * The name of the plan to subscribe
352
352
  */
353
- plan: z.string({
353
+ plan: z.string().meta({
354
354
  description: "The name of the plan to upgrade to"
355
355
  }),
356
356
  /**
357
357
  * If annual plan should be applied.
358
358
  */
359
- annual: z.boolean({
359
+ annual: z.boolean().meta({
360
360
  description: "Whether to upgrade to an annual plan"
361
361
  }).optional(),
362
362
  /**
@@ -364,7 +364,7 @@ const stripe = (options) => {
364
364
  * This is used to identify the subscription to upgrade
365
365
  * If not provided, the user's id will be used
366
366
  */
367
- referenceId: z.string({
367
+ referenceId: z.string().meta({
368
368
  description: "Reference id of the subscription to upgrade"
369
369
  }).optional(),
370
370
  /**
@@ -372,7 +372,7 @@ const stripe = (options) => {
372
372
  * If subscription id is provided, and subscription isn't found,
373
373
  * it'll throw an error.
374
374
  */
375
- subscriptionId: z.string({
375
+ subscriptionId: z.string().meta({
376
376
  description: "The id of the subscription to upgrade"
377
377
  }).optional(),
378
378
  /**
@@ -383,19 +383,19 @@ const stripe = (options) => {
383
383
  /**
384
384
  * If a subscription
385
385
  */
386
- seats: z.number({
386
+ seats: z.number().meta({
387
387
  description: "Number of seats to upgrade to (if applicable)"
388
388
  }).optional(),
389
389
  /**
390
390
  * Success URL to redirect back after successful subscription
391
391
  */
392
- successUrl: z.string({
392
+ successUrl: z.string().meta({
393
393
  description: "Callback URL to redirect back after successful subscription"
394
394
  }).default("/"),
395
395
  /**
396
396
  * Cancel URL
397
397
  */
398
- cancelUrl: z.string({
398
+ cancelUrl: z.string().meta({
399
399
  description: "Callback URL to redirect back after successful subscription"
400
400
  }).default("/"),
401
401
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@better-auth/stripe",
3
3
  "author": "Bereket Engida",
4
- "version": "1.3.0-beta.7",
4
+ "version": "1.3.0-beta.9",
5
5
  "main": "dist/index.cjs",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -34,8 +34,8 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "zod": "^3.24.1",
38
- "better-auth": "^1.3.0-beta.7"
37
+ "zod": "^4.0.0",
38
+ "better-auth": "^1.3.0-beta.9"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/better-sqlite3": "^7.6.12",
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  } from "better-auth";
6
6
  import { createAuthEndpoint, createAuthMiddleware } from "better-auth/plugins";
7
7
  import Stripe from "stripe";
8
- import { z } from "zod";
8
+ import * as z from "zod/v4";
9
9
  import {
10
10
  sessionMiddleware,
11
11
  APIError,
@@ -114,14 +114,15 @@ export const stripe = <O extends StripeOptions>(options: O) => {
114
114
  /**
115
115
  * The name of the plan to subscribe
116
116
  */
117
- plan: z.string({
117
+ plan: z.string().meta({
118
118
  description: "The name of the plan to upgrade to",
119
119
  }),
120
120
  /**
121
121
  * If annual plan should be applied.
122
122
  */
123
123
  annual: z
124
- .boolean({
124
+ .boolean()
125
+ .meta({
125
126
  description: "Whether to upgrade to an annual plan",
126
127
  })
127
128
  .optional(),
@@ -131,7 +132,8 @@ export const stripe = <O extends StripeOptions>(options: O) => {
131
132
  * If not provided, the user's id will be used
132
133
  */
133
134
  referenceId: z
134
- .string({
135
+ .string()
136
+ .meta({
135
137
  description: "Reference id of the subscription to upgrade",
136
138
  })
137
139
  .optional(),
@@ -141,7 +143,8 @@ export const stripe = <O extends StripeOptions>(options: O) => {
141
143
  * it'll throw an error.
142
144
  */
143
145
  subscriptionId: z
144
- .string({
146
+ .string()
147
+ .meta({
145
148
  description: "The id of the subscription to upgrade",
146
149
  })
147
150
  .optional(),
@@ -154,7 +157,8 @@ export const stripe = <O extends StripeOptions>(options: O) => {
154
157
  * If a subscription
155
158
  */
156
159
  seats: z
157
- .number({
160
+ .number()
161
+ .meta({
158
162
  description: "Number of seats to upgrade to (if applicable)",
159
163
  })
160
164
  .optional(),
@@ -162,7 +166,8 @@ export const stripe = <O extends StripeOptions>(options: O) => {
162
166
  * Success URL to redirect back after successful subscription
163
167
  */
164
168
  successUrl: z
165
- .string({
169
+ .string()
170
+ .meta({
166
171
  description:
167
172
  "Callback URL to redirect back after successful subscription",
168
173
  })
@@ -171,7 +176,8 @@ export const stripe = <O extends StripeOptions>(options: O) => {
171
176
  * Cancel URL
172
177
  */
173
178
  cancelUrl: z
174
- .string({
179
+ .string()
180
+ .meta({
175
181
  description:
176
182
  "Callback URL to redirect back after successful subscription",
177
183
  })