@better-auth/stripe 1.2.5-beta.5 → 1.2.5-beta.7

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.2.5-beta.5 build /home/runner/work/better-auth/better-auth/packages/stripe
2
+ > @better-auth/stripe@1.2.5-beta.7 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: 33.4 kB, chunk size: 33.4 kB, exports: stripe)
8
+ [log] dist/index.cjs (total size: 33.5 kB, chunk size: 33.5 kB, exports: stripe)
9
9
 
10
10
  [log] dist/client.cjs (total size: 160 B, chunk size: 160 B, exports: stripeClient)
11
11
 
12
- [log] dist/index.mjs (total size: 33.1 kB, chunk size: 33.1 kB, exports: stripe)
12
+ [log] dist/index.mjs (total size: 33.2 kB, chunk size: 33.2 kB, exports: stripe)
13
13
 
14
14
  [log] dist/client.mjs (total size: 133 B, chunk size: 133 B, exports: stripeClient)
15
15
 
16
- Σ Total dist size (byte size): 184 kB
16
+ Σ Total dist size (byte size): 192 kB
17
17
  [log]
package/dist/index.cjs CHANGED
@@ -11,7 +11,9 @@ async function getPlans(options) {
11
11
  }
12
12
  async function getPlanByPriceId(options, priceId) {
13
13
  return await getPlans(options).then(
14
- (res) => res?.find((plan) => plan.priceId === priceId)
14
+ (res) => res?.find(
15
+ (plan) => plan.priceId === priceId || plan.annualDiscountPriceId === priceId
16
+ )
15
17
  );
16
18
  }
17
19
  async function getPlanByName(options, name) {
package/dist/index.d.cts CHANGED
@@ -293,18 +293,15 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
293
293
  id: "stripe";
294
294
  endpoints: {
295
295
  stripeWebhook: {
296
- <C extends [({
297
- body?: undefined;
298
- method?: "POST" | undefined;
299
- query?: Record<string, any> | undefined;
300
- params?: Record<string, any> | undefined;
301
- request?: Request | undefined;
302
- headers?: HeadersInit | undefined;
303
- asResponse?: boolean | undefined;
304
- returnHeaders?: boolean | undefined;
305
- use?: better_call.Middleware[] | undefined;
306
- path?: string | undefined;
307
- } | undefined)?]>(...inputCtx: C): Promise<C extends [{
296
+ <C extends [(better_call.InputContext<"/stripe/webhook", {
297
+ method: "POST";
298
+ metadata: {
299
+ isAction: boolean;
300
+ };
301
+ cloneRequest: true;
302
+ } & {
303
+ use: any[];
304
+ }> | undefined)?]>(...inputCtx: C): Promise<C extends [{
308
305
  asResponse: true;
309
306
  }] ? Response : C extends [{
310
307
  returnHeaders: true;
@@ -331,8 +328,66 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
331
328
  enabled: boolean;
332
329
  } ? {
333
330
  readonly upgradeSubscription: {
334
- <C extends [{
335
- body: {
331
+ <C extends [better_call.InputContext<"/subscription/upgrade", {
332
+ method: "POST";
333
+ body: z.ZodObject<{
334
+ /**
335
+ * The name of the plan to subscribe
336
+ */
337
+ plan: z.ZodString;
338
+ /**
339
+ * If annual plan should be applied.
340
+ */
341
+ annual: z.ZodOptional<z.ZodBoolean>;
342
+ /**
343
+ * Reference id of the subscription to upgrade
344
+ * This is used to identify the subscription to upgrade
345
+ * If not provided, the user's id will be used
346
+ */
347
+ referenceId: z.ZodOptional<z.ZodString>;
348
+ /**
349
+ * This is to allow a specific subscription to be upgrade.
350
+ * If subscription id is provided, and subscription isn't found,
351
+ * it'll throw an error.
352
+ */
353
+ subscriptionId: z.ZodOptional<z.ZodString>;
354
+ /**
355
+ * Any additional data you want to store in your database
356
+ * subscriptions
357
+ */
358
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
359
+ /**
360
+ * If a subscription
361
+ */
362
+ seats: z.ZodOptional<z.ZodNumber>;
363
+ /**
364
+ * Success url to redirect back after successful subscription
365
+ */
366
+ successUrl: z.ZodDefault<z.ZodString>;
367
+ /**
368
+ * Cancel URL
369
+ */
370
+ cancelUrl: z.ZodDefault<z.ZodString>;
371
+ /**
372
+ * Return URL
373
+ */
374
+ returnUrl: z.ZodOptional<z.ZodString>;
375
+ /**
376
+ * Disable Redirect
377
+ */
378
+ disableRedirect: z.ZodDefault<z.ZodBoolean>;
379
+ }, "strip", z.ZodTypeAny, {
380
+ plan: string;
381
+ successUrl: string;
382
+ cancelUrl: string;
383
+ disableRedirect: boolean;
384
+ metadata?: Record<string, any> | undefined;
385
+ annual?: boolean | undefined;
386
+ referenceId?: string | undefined;
387
+ subscriptionId?: string | undefined;
388
+ seats?: number | undefined;
389
+ returnUrl?: string | undefined;
390
+ }, {
336
391
  plan: string;
337
392
  metadata?: Record<string, any> | undefined;
338
393
  annual?: boolean | undefined;
@@ -343,17 +398,33 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
343
398
  cancelUrl?: string | undefined;
344
399
  returnUrl?: string | undefined;
345
400
  disableRedirect?: boolean | undefined;
346
- };
347
- method?: "POST" | undefined;
348
- query?: Record<string, any> | undefined;
349
- params?: Record<string, any> | undefined;
350
- request?: Request | undefined;
351
- headers?: HeadersInit | undefined;
352
- asResponse?: boolean | undefined;
353
- returnHeaders?: boolean | undefined;
354
- use?: better_call.Middleware[] | undefined;
355
- path?: string | undefined;
356
- }]>(...inputCtx: C): Promise<C extends [{
401
+ }>;
402
+ use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
403
+ session: {
404
+ session: Record<string, any> & {
405
+ id: string;
406
+ createdAt: Date;
407
+ updatedAt: Date;
408
+ userId: string;
409
+ expiresAt: Date;
410
+ token: string;
411
+ ipAddress?: string | null | undefined;
412
+ userAgent?: string | null | undefined;
413
+ };
414
+ user: Record<string, any> & {
415
+ id: string;
416
+ name: string;
417
+ email: string;
418
+ emailVerified: boolean;
419
+ createdAt: Date;
420
+ updatedAt: Date;
421
+ image?: string | null | undefined;
422
+ };
423
+ };
424
+ }>) | ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>))[];
425
+ } & {
426
+ use: any[];
427
+ }>]>(...inputCtx: C): Promise<C extends [{
357
428
  asResponse: true;
358
429
  }] ? Response : C extends [{
359
430
  returnHeaders: true;
@@ -578,15 +649,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
578
649
  returnUrl?: string | undefined;
579
650
  disableRedirect?: boolean | undefined;
580
651
  }>;
581
- use: (((inputContext: {
582
- body?: any;
583
- query?: Record<string, any> | undefined;
584
- request?: Request | undefined;
585
- headers?: Headers | undefined;
586
- asResponse?: boolean | undefined;
587
- returnHeaders?: boolean | undefined;
588
- use?: better_call.Middleware[] | undefined;
589
- }) => Promise<{
652
+ use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
590
653
  session: {
591
654
  session: Record<string, any> & {
592
655
  id: string;
@@ -608,33 +671,20 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
608
671
  image?: string | null | undefined;
609
672
  };
610
673
  };
611
- }>) | ((inputContext: {
612
- body?: any;
613
- query?: Record<string, any> | undefined;
614
- request?: Request | undefined;
615
- headers?: Headers | undefined;
616
- asResponse?: boolean | undefined;
617
- returnHeaders?: boolean | undefined;
618
- use?: better_call.Middleware[] | undefined;
619
- }) => Promise<void>))[];
674
+ }>) | ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>))[];
620
675
  } & {
621
676
  use: any[];
622
677
  };
623
678
  path: "/subscription/upgrade";
624
679
  };
625
680
  readonly cancelSubscriptionCallback: {
626
- <C extends [({
627
- body?: undefined;
628
- method?: "GET" | undefined;
629
- query?: Record<string, any> | undefined;
630
- params?: Record<string, any> | undefined;
631
- request?: Request | undefined;
632
- headers?: HeadersInit | undefined;
633
- asResponse?: boolean | undefined;
634
- returnHeaders?: boolean | undefined;
635
- use?: better_call.Middleware[] | undefined;
636
- path?: string | undefined;
637
- } | undefined)?]>(...inputCtx: C): Promise<C extends [{
681
+ <C extends [(better_call.InputContext<"/subscription/cancel/callback", {
682
+ method: "GET";
683
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
684
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>)[];
685
+ } & {
686
+ use: any[];
687
+ }> | undefined)?]>(...inputCtx: C): Promise<C extends [{
638
688
  asResponse: true;
639
689
  }] ? Response : C extends [{
640
690
  returnHeaders: true;
@@ -645,37 +695,54 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
645
695
  options: {
646
696
  method: "GET";
647
697
  query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
648
- use: ((inputContext: {
649
- body?: any;
650
- query?: Record<string, any> | undefined;
651
- request?: Request | undefined;
652
- headers?: Headers | undefined;
653
- asResponse?: boolean | undefined;
654
- returnHeaders?: boolean | undefined;
655
- use?: better_call.Middleware[] | undefined;
656
- }) => Promise<void>)[];
698
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>)[];
657
699
  } & {
658
700
  use: any[];
659
701
  };
660
702
  path: "/subscription/cancel/callback";
661
703
  };
662
704
  readonly cancelSubscription: {
663
- <C extends [{
664
- body: {
705
+ <C extends [better_call.InputContext<"/subscription/cancel", {
706
+ method: "POST";
707
+ body: z.ZodObject<{
708
+ referenceId: z.ZodOptional<z.ZodString>;
709
+ subscriptionId: z.ZodOptional<z.ZodString>;
710
+ returnUrl: z.ZodString;
711
+ }, "strip", z.ZodTypeAny, {
665
712
  returnUrl: string;
666
713
  referenceId?: string | undefined;
667
714
  subscriptionId?: string | undefined;
668
- };
669
- method?: "POST" | undefined;
670
- query?: Record<string, any> | undefined;
671
- params?: Record<string, any> | undefined;
672
- request?: Request | undefined;
673
- headers?: HeadersInit | undefined;
674
- asResponse?: boolean | undefined;
675
- returnHeaders?: boolean | undefined;
676
- use?: better_call.Middleware[] | undefined;
677
- path?: string | undefined;
678
- }]>(...inputCtx: C): Promise<C extends [{
715
+ }, {
716
+ returnUrl: string;
717
+ referenceId?: string | undefined;
718
+ subscriptionId?: string | undefined;
719
+ }>;
720
+ use: (((inputContext: better_call.MiddlewareInputContext<better_call.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
+ name: string;
735
+ email: string;
736
+ emailVerified: boolean;
737
+ createdAt: Date;
738
+ updatedAt: Date;
739
+ image?: string | null | undefined;
740
+ };
741
+ };
742
+ }>) | ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>))[];
743
+ } & {
744
+ use: any[];
745
+ }>]>(...inputCtx: C): Promise<C extends [{
679
746
  asResponse: true;
680
747
  }] ? Response : C extends [{
681
748
  returnHeaders: true;
@@ -704,15 +771,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
704
771
  referenceId?: string | undefined;
705
772
  subscriptionId?: string | undefined;
706
773
  }>;
707
- use: (((inputContext: {
708
- body?: any;
709
- query?: Record<string, any> | undefined;
710
- request?: Request | undefined;
711
- headers?: Headers | undefined;
712
- asResponse?: boolean | undefined;
713
- returnHeaders?: boolean | undefined;
714
- use?: better_call.Middleware[] | undefined;
715
- }) => Promise<{
774
+ use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
716
775
  session: {
717
776
  session: Record<string, any> & {
718
777
  id: string;
@@ -734,35 +793,48 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
734
793
  image?: string | null | undefined;
735
794
  };
736
795
  };
737
- }>) | ((inputContext: {
738
- body?: any;
739
- query?: Record<string, any> | undefined;
740
- request?: Request | undefined;
741
- headers?: Headers | undefined;
742
- asResponse?: boolean | undefined;
743
- returnHeaders?: boolean | undefined;
744
- use?: better_call.Middleware[] | undefined;
745
- }) => Promise<void>))[];
796
+ }>) | ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>))[];
746
797
  } & {
747
798
  use: any[];
748
799
  };
749
800
  path: "/subscription/cancel";
750
801
  };
751
802
  readonly listActiveSubscriptions: {
752
- <C extends [({
753
- body?: undefined;
754
- method?: "GET" | undefined;
755
- query?: {
803
+ <C extends [(better_call.InputContext<"/subscription/list", {
804
+ method: "GET";
805
+ query: z.ZodOptional<z.ZodObject<{
806
+ referenceId: z.ZodOptional<z.ZodString>;
807
+ }, "strip", z.ZodTypeAny, {
756
808
  referenceId?: string | undefined;
757
- } | undefined;
758
- params?: Record<string, any> | undefined;
759
- request?: Request | undefined;
760
- headers?: HeadersInit | undefined;
761
- asResponse?: boolean | undefined;
762
- returnHeaders?: boolean | undefined;
763
- use?: better_call.Middleware[] | undefined;
764
- path?: string | undefined;
765
- } | undefined)?]>(...inputCtx: C): Promise<C extends [{
809
+ }, {
810
+ referenceId?: string | undefined;
811
+ }>>;
812
+ use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
813
+ session: {
814
+ session: Record<string, any> & {
815
+ id: string;
816
+ createdAt: Date;
817
+ updatedAt: Date;
818
+ userId: string;
819
+ expiresAt: Date;
820
+ token: string;
821
+ ipAddress?: string | null | undefined;
822
+ userAgent?: string | null | undefined;
823
+ };
824
+ user: Record<string, any> & {
825
+ id: string;
826
+ name: string;
827
+ email: string;
828
+ emailVerified: boolean;
829
+ createdAt: Date;
830
+ updatedAt: Date;
831
+ image?: string | null | undefined;
832
+ };
833
+ };
834
+ }>) | ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>))[];
835
+ } & {
836
+ use: any[];
837
+ }> | undefined)?]>(...inputCtx: C): Promise<C extends [{
766
838
  asResponse: true;
767
839
  }] ? Response : C extends [{
768
840
  returnHeaders: true;
@@ -811,15 +883,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
811
883
  }, {
812
884
  referenceId?: string | undefined;
813
885
  }>>;
814
- use: (((inputContext: {
815
- body?: any;
816
- query?: Record<string, any> | undefined;
817
- request?: Request | undefined;
818
- headers?: Headers | undefined;
819
- asResponse?: boolean | undefined;
820
- returnHeaders?: boolean | undefined;
821
- use?: better_call.Middleware[] | undefined;
822
- }) => Promise<{
886
+ use: (((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<{
823
887
  session: {
824
888
  session: Record<string, any> & {
825
889
  id: string;
@@ -841,33 +905,20 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
841
905
  image?: string | null | undefined;
842
906
  };
843
907
  };
844
- }>) | ((inputContext: {
845
- body?: any;
846
- query?: Record<string, any> | undefined;
847
- request?: Request | undefined;
848
- headers?: Headers | undefined;
849
- asResponse?: boolean | undefined;
850
- returnHeaders?: boolean | undefined;
851
- use?: better_call.Middleware[] | undefined;
852
- }) => Promise<void>))[];
908
+ }>) | ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>))[];
853
909
  } & {
854
910
  use: any[];
855
911
  };
856
912
  path: "/subscription/list";
857
913
  };
858
914
  readonly subscriptionSuccess: {
859
- <C extends [({
860
- body?: undefined;
861
- method?: "GET" | undefined;
862
- query?: Record<string, any> | undefined;
863
- params?: Record<string, any> | undefined;
864
- request?: Request | undefined;
865
- headers?: HeadersInit | undefined;
866
- asResponse?: boolean | undefined;
867
- returnHeaders?: boolean | undefined;
868
- use?: better_call.Middleware[] | undefined;
869
- path?: string | undefined;
870
- } | undefined)?]>(...inputCtx: C): Promise<C extends [{
915
+ <C extends [(better_call.InputContext<"/subscription/success", {
916
+ method: "GET";
917
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
918
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>)[];
919
+ } & {
920
+ use: any[];
921
+ }> | undefined)?]>(...inputCtx: C): Promise<C extends [{
871
922
  asResponse: true;
872
923
  }] ? Response : C extends [{
873
924
  returnHeaders: true;
@@ -878,15 +929,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
878
929
  options: {
879
930
  method: "GET";
880
931
  query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
881
- use: ((inputContext: {
882
- body?: any;
883
- query?: Record<string, any> | undefined;
884
- request?: Request | undefined;
885
- headers?: Headers | undefined;
886
- asResponse?: boolean | undefined;
887
- returnHeaders?: boolean | undefined;
888
- use?: better_call.Middleware[] | undefined;
889
- }) => Promise<void>)[];
932
+ use: ((inputContext: better_call.MiddlewareInputContext<better_call.MiddlewareOptions>) => Promise<void>)[];
890
933
  } & {
891
934
  use: any[];
892
935
  };