@better-auth/stripe 1.5.6 → 1.5.7-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as stripe, s as StripePlan } from "./index-nU1KjBOz.mjs";
1
+ import { n as stripe, s as StripePlan } from "./index-DDwLbqpK.mjs";
2
2
  import * as better_auth0 from "better-auth";
3
3
 
4
4
  //#region src/error-codes.d.ts
package/dist/client.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { t as STRIPE_ERROR_CODES } from "./error-codes-CCosYkXx.mjs";
2
-
1
+ import { t as STRIPE_ERROR_CODES } from "./error-codes-DFj-5pDu.mjs";
3
2
  //#region src/client.ts
4
3
  const stripeClient = (options) => {
5
4
  return {
@@ -12,7 +11,7 @@ const stripeClient = (options) => {
12
11
  $ERROR_CODES: STRIPE_ERROR_CODES
13
12
  };
14
13
  };
15
-
16
14
  //#endregion
17
15
  export { STRIPE_ERROR_CODES, stripeClient };
16
+
18
17
  //# sourceMappingURL=client.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth/client\";\nimport { STRIPE_ERROR_CODES } from \"./error-codes\";\nimport type { StripePlan, stripe } from \"./index\";\nexport const stripeClient = <\n\tO extends {\n\t\tsubscription: boolean;\n\t},\n>(\n\toptions?: O | undefined,\n) => {\n\treturn {\n\t\tid: \"stripe-client\",\n\t\t$InferServerPlugin: {} as ReturnType<\n\t\t\ttypeof stripe<\n\t\t\t\tO[\"subscription\"] extends true\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstripeClient: any;\n\t\t\t\t\t\t\tstripeWebhookSecret: string;\n\t\t\t\t\t\t\tsubscription: {\n\t\t\t\t\t\t\t\tenabled: true;\n\t\t\t\t\t\t\t\tplans: StripePlan[];\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstripeClient: any;\n\t\t\t\t\t\t\tstripeWebhookSecret: string;\n\t\t\t\t\t\t}\n\t\t\t>\n\t\t>,\n\t\tpathMethods: {\n\t\t\t\"/subscription/billing-portal\": \"POST\",\n\t\t\t\"/subscription/restore\": \"POST\",\n\t\t},\n\t\t$ERROR_CODES: STRIPE_ERROR_CODES,\n\t} satisfies BetterAuthClientPlugin;\n};\nexport * from \"./error-codes\";\n"],"mappings":";;;AAGA,MAAa,gBAKZ,YACI;AACJ,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EAiBtB,aAAa;GACZ,gCAAgC;GAChC,yBAAyB;GACzB;EACD,cAAc;EACd"}
1
+ {"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth/client\";\nimport { STRIPE_ERROR_CODES } from \"./error-codes\";\nimport type { StripePlan, stripe } from \"./index\";\nexport const stripeClient = <\n\tO extends {\n\t\tsubscription: boolean;\n\t},\n>(\n\toptions?: O | undefined,\n) => {\n\treturn {\n\t\tid: \"stripe-client\",\n\t\t$InferServerPlugin: {} as ReturnType<\n\t\t\ttypeof stripe<\n\t\t\t\tO[\"subscription\"] extends true\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstripeClient: any;\n\t\t\t\t\t\t\tstripeWebhookSecret: string;\n\t\t\t\t\t\t\tsubscription: {\n\t\t\t\t\t\t\t\tenabled: true;\n\t\t\t\t\t\t\t\tplans: StripePlan[];\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstripeClient: any;\n\t\t\t\t\t\t\tstripeWebhookSecret: string;\n\t\t\t\t\t\t}\n\t\t\t>\n\t\t>,\n\t\tpathMethods: {\n\t\t\t\"/subscription/billing-portal\": \"POST\",\n\t\t\t\"/subscription/restore\": \"POST\",\n\t\t},\n\t\t$ERROR_CODES: STRIPE_ERROR_CODES,\n\t} satisfies BetterAuthClientPlugin;\n};\nexport * from \"./error-codes\";\n"],"mappings":";;AAGA,MAAa,gBAKZ,YACI;AACJ,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EAiBtB,aAAa;GACZ,gCAAgC;GAChC,yBAAyB;GACzB;EACD,cAAc;EACd"}
@@ -1,5 +1,4 @@
1
1
  import { defineErrorCodes } from "@better-auth/core/utils/error-codes";
2
-
3
2
  //#region src/error-codes.ts
4
3
  const STRIPE_ERROR_CODES = defineErrorCodes({
5
4
  UNAUTHORIZED: "Unauthorized access",
@@ -26,7 +25,7 @@ const STRIPE_ERROR_CODES = defineErrorCodes({
26
25
  ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: "Cannot delete organization with active subscription",
27
26
  ORGANIZATION_REFERENCE_ID_REQUIRED: "Reference ID is required. Provide referenceId or set activeOrganizationId in session"
28
27
  });
29
-
30
28
  //#endregion
31
29
  export { STRIPE_ERROR_CODES as t };
32
- //# sourceMappingURL=error-codes-CCosYkXx.mjs.map
30
+
31
+ //# sourceMappingURL=error-codes-DFj-5pDu.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-codes-CCosYkXx.mjs","names":[],"sources":["../src/error-codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"@better-auth/core/utils/error-codes\";\n\nexport const STRIPE_ERROR_CODES = defineErrorCodes({\n\tUNAUTHORIZED: \"Unauthorized access\",\n\tINVALID_REQUEST_BODY: \"Invalid request body\",\n\tSUBSCRIPTION_NOT_FOUND: \"Subscription not found\",\n\tSUBSCRIPTION_PLAN_NOT_FOUND: \"Subscription plan not found\",\n\tALREADY_SUBSCRIBED_PLAN: \"You're already subscribed to this plan\",\n\tREFERENCE_ID_NOT_ALLOWED: \"Reference id is not allowed\",\n\tCUSTOMER_NOT_FOUND: \"Stripe customer not found for this user\",\n\tUNABLE_TO_CREATE_CUSTOMER: \"Unable to create customer\",\n\tUNABLE_TO_CREATE_BILLING_PORTAL: \"Unable to create billing portal session\",\n\tSTRIPE_SIGNATURE_NOT_FOUND: \"Stripe signature not found\",\n\tSTRIPE_WEBHOOK_SECRET_NOT_FOUND: \"Stripe webhook secret not found\",\n\tSTRIPE_WEBHOOK_ERROR: \"Stripe webhook error\",\n\tFAILED_TO_CONSTRUCT_STRIPE_EVENT: \"Failed to construct Stripe event\",\n\tFAILED_TO_FETCH_PLANS: \"Failed to fetch plans\",\n\tEMAIL_VERIFICATION_REQUIRED:\n\t\t\"Email verification is required before you can subscribe to a plan\",\n\tSUBSCRIPTION_NOT_ACTIVE: \"Subscription is not active\",\n\t/**\n\t * @deprecated Use `SUBSCRIPTION_NOT_PENDING_CHANGE` instead.\n\t */\n\tSUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:\n\t\t\"Subscription is not scheduled for cancellation\",\n\tSUBSCRIPTION_NOT_PENDING_CHANGE:\n\t\t\"Subscription has no pending cancellation or scheduled plan change\",\n\tORGANIZATION_NOT_FOUND: \"Organization not found\",\n\tORGANIZATION_SUBSCRIPTION_NOT_ENABLED:\n\t\t\"Organization subscription is not enabled\",\n\tAUTHORIZE_REFERENCE_REQUIRED:\n\t\t\"Organization subscriptions require authorizeReference callback to be configured\",\n\tORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:\n\t\t\"Cannot delete organization with active subscription\",\n\tORGANIZATION_REFERENCE_ID_REQUIRED:\n\t\t\"Reference ID is required. Provide referenceId or set activeOrganizationId in session\",\n});\n"],"mappings":";;;AAEA,MAAa,qBAAqB,iBAAiB;CAClD,cAAc;CACd,sBAAsB;CACtB,wBAAwB;CACxB,6BAA6B;CAC7B,yBAAyB;CACzB,0BAA0B;CAC1B,oBAAoB;CACpB,2BAA2B;CAC3B,iCAAiC;CACjC,4BAA4B;CAC5B,iCAAiC;CACjC,sBAAsB;CACtB,kCAAkC;CAClC,uBAAuB;CACvB,6BACC;CACD,yBAAyB;CAIzB,6CACC;CACD,iCACC;CACD,wBAAwB;CACxB,uCACC;CACD,8BACC;CACD,sCACC;CACD,oCACC;CACD,CAAC"}
1
+ {"version":3,"file":"error-codes-DFj-5pDu.mjs","names":[],"sources":["../src/error-codes.ts"],"sourcesContent":["import { defineErrorCodes } from \"@better-auth/core/utils/error-codes\";\n\nexport const STRIPE_ERROR_CODES = defineErrorCodes({\n\tUNAUTHORIZED: \"Unauthorized access\",\n\tINVALID_REQUEST_BODY: \"Invalid request body\",\n\tSUBSCRIPTION_NOT_FOUND: \"Subscription not found\",\n\tSUBSCRIPTION_PLAN_NOT_FOUND: \"Subscription plan not found\",\n\tALREADY_SUBSCRIBED_PLAN: \"You're already subscribed to this plan\",\n\tREFERENCE_ID_NOT_ALLOWED: \"Reference id is not allowed\",\n\tCUSTOMER_NOT_FOUND: \"Stripe customer not found for this user\",\n\tUNABLE_TO_CREATE_CUSTOMER: \"Unable to create customer\",\n\tUNABLE_TO_CREATE_BILLING_PORTAL: \"Unable to create billing portal session\",\n\tSTRIPE_SIGNATURE_NOT_FOUND: \"Stripe signature not found\",\n\tSTRIPE_WEBHOOK_SECRET_NOT_FOUND: \"Stripe webhook secret not found\",\n\tSTRIPE_WEBHOOK_ERROR: \"Stripe webhook error\",\n\tFAILED_TO_CONSTRUCT_STRIPE_EVENT: \"Failed to construct Stripe event\",\n\tFAILED_TO_FETCH_PLANS: \"Failed to fetch plans\",\n\tEMAIL_VERIFICATION_REQUIRED:\n\t\t\"Email verification is required before you can subscribe to a plan\",\n\tSUBSCRIPTION_NOT_ACTIVE: \"Subscription is not active\",\n\t/**\n\t * @deprecated Use `SUBSCRIPTION_NOT_PENDING_CHANGE` instead.\n\t */\n\tSUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:\n\t\t\"Subscription is not scheduled for cancellation\",\n\tSUBSCRIPTION_NOT_PENDING_CHANGE:\n\t\t\"Subscription has no pending cancellation or scheduled plan change\",\n\tORGANIZATION_NOT_FOUND: \"Organization not found\",\n\tORGANIZATION_SUBSCRIPTION_NOT_ENABLED:\n\t\t\"Organization subscription is not enabled\",\n\tAUTHORIZE_REFERENCE_REQUIRED:\n\t\t\"Organization subscriptions require authorizeReference callback to be configured\",\n\tORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:\n\t\t\"Cannot delete organization with active subscription\",\n\tORGANIZATION_REFERENCE_ID_REQUIRED:\n\t\t\"Reference ID is required. Provide referenceId or set activeOrganizationId in session\",\n});\n"],"mappings":";;AAEA,MAAa,qBAAqB,iBAAiB;CAClD,cAAc;CACd,sBAAsB;CACtB,wBAAwB;CACxB,6BAA6B;CAC7B,yBAAyB;CACzB,0BAA0B;CAC1B,oBAAoB;CACpB,2BAA2B;CAC3B,iCAAiC;CACjC,4BAA4B;CAC5B,iCAAiC;CACjC,sBAAsB;CACtB,kCAAkC;CAClC,uBAAuB;CACvB,6BACC;CACD,yBAAyB;CAIzB,6CACC;CACD,iCACC;CACD,wBAAwB;CACxB,uCACC;CACD,8BACC;CACD,sCACC;CACD,oCACC;CACD,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import * as better_auth0 from "better-auth";
2
2
  import { GenericEndpointContext, InferOptionSchema, Session, User } from "better-auth";
3
- import * as zod from "zod";
4
3
  import * as better_call0 from "better-call";
5
4
  import { Organization } from "better-auth/plugins/organization";
6
5
  import Stripe from "stripe";
@@ -502,75 +501,34 @@ declare module "@better-auth/core" {
502
501
  declare const stripe: <O extends StripeOptions>(options: O) => {
503
502
  id: "stripe";
504
503
  endpoints: {
505
- stripeWebhook: better_call0.StrictEndpoint<"/stripe/webhook", {
506
- method: "POST";
507
- metadata: {
508
- openapi: {
509
- operationId: string;
510
- };
511
- scope: "server";
512
- };
513
- cloneRequest: true;
514
- disableBody: true;
515
- }, {
504
+ stripeWebhook: better_call0.Endpoint<"/stripe/webhook", "POST", undefined, Record<string, any> | undefined, [], {
516
505
  success: boolean;
517
- }>;
506
+ }, {
507
+ openapi: {
508
+ operationId: string;
509
+ };
510
+ scope: "server";
511
+ }, undefined>;
518
512
  } & (O["subscription"] extends {
519
513
  enabled: true;
520
514
  } ? {
521
- upgradeSubscription: better_call0.StrictEndpoint<"/subscription/upgrade", {
522
- method: "POST";
523
- body: zod.ZodObject<{
524
- plan: zod.ZodString;
525
- annual: zod.ZodOptional<zod.ZodBoolean>;
526
- referenceId: zod.ZodOptional<zod.ZodString>;
527
- subscriptionId: zod.ZodOptional<zod.ZodString>;
528
- customerType: zod.ZodOptional<zod.ZodEnum<{
529
- user: "user";
530
- organization: "organization";
531
- }>>;
532
- metadata: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
533
- seats: zod.ZodOptional<zod.ZodNumber>;
534
- locale: zod.ZodOptional<zod.ZodCustom<Stripe.Checkout.Session.Locale, Stripe.Checkout.Session.Locale>>;
535
- successUrl: zod.ZodDefault<zod.ZodString>;
536
- cancelUrl: zod.ZodDefault<zod.ZodString>;
537
- returnUrl: zod.ZodOptional<zod.ZodString>;
538
- scheduleAtPeriodEnd: zod.ZodDefault<zod.ZodBoolean>;
539
- disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
540
- }, better_auth0.$strip>;
541
- metadata: {
542
- openapi: {
543
- operationId: string;
544
- };
545
- };
546
- use: (((inputContext: better_call0.MiddlewareInputContext<{
547
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
548
- session: {
549
- session: Record<string, any> & {
550
- id: string;
551
- createdAt: Date;
552
- updatedAt: Date;
553
- userId: string;
554
- expiresAt: Date;
555
- token: string;
556
- ipAddress?: string | null | undefined;
557
- userAgent?: string | null | undefined;
558
- };
559
- user: Record<string, any> & {
560
- id: string;
561
- createdAt: Date;
562
- updatedAt: Date;
563
- email: string;
564
- emailVerified: boolean;
565
- name: string;
566
- image?: string | null | undefined;
567
- };
568
- };
569
- }>)[];
570
- }>) => Promise<{
571
- session: StripeCtxSession;
572
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
573
- }, {
515
+ upgradeSubscription: better_call0.Endpoint<"/subscription/upgrade", "POST", {
516
+ plan: string;
517
+ annual?: boolean | undefined;
518
+ referenceId?: string | undefined;
519
+ subscriptionId?: string | undefined;
520
+ customerType?: "user" | "organization" | undefined;
521
+ metadata?: Record<string, any> | undefined;
522
+ seats?: number | undefined;
523
+ locale?: Stripe.Checkout.Session.Locale | undefined;
524
+ successUrl?: string | undefined;
525
+ cancelUrl?: string | undefined;
526
+ returnUrl?: string | undefined;
527
+ scheduleAtPeriodEnd?: boolean | undefined;
528
+ disableRedirect?: boolean | undefined;
529
+ }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
530
+ session: StripeCtxSession;
531
+ }>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>], {
574
532
  url: string;
575
533
  redirect: boolean;
576
534
  } | {
@@ -651,140 +609,44 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
651
609
  idempotencyKey?: string;
652
610
  stripeAccount?: string;
653
611
  };
654
- }>;
655
- cancelSubscription: better_call0.StrictEndpoint<"/subscription/cancel", {
656
- method: "POST";
657
- body: zod.ZodObject<{
658
- referenceId: zod.ZodOptional<zod.ZodString>;
659
- subscriptionId: zod.ZodOptional<zod.ZodString>;
660
- customerType: zod.ZodOptional<zod.ZodEnum<{
661
- user: "user";
662
- organization: "organization";
663
- }>>;
664
- returnUrl: zod.ZodString;
665
- disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
666
- }, better_auth0.$strip>;
667
- metadata: {
668
- openapi: {
669
- operationId: string;
670
- };
671
- };
672
- use: (((inputContext: better_call0.MiddlewareInputContext<{
673
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
674
- session: {
675
- session: Record<string, any> & {
676
- id: string;
677
- createdAt: Date;
678
- updatedAt: Date;
679
- userId: string;
680
- expiresAt: Date;
681
- token: string;
682
- ipAddress?: string | null | undefined;
683
- userAgent?: string | null | undefined;
684
- };
685
- user: Record<string, any> & {
686
- id: string;
687
- createdAt: Date;
688
- updatedAt: Date;
689
- email: string;
690
- emailVerified: boolean;
691
- name: string;
692
- image?: string | null | undefined;
693
- };
694
- };
695
- }>)[];
696
- }>) => Promise<{
697
- session: StripeCtxSession;
698
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
699
612
  }, {
613
+ openapi: {
614
+ operationId: string;
615
+ };
616
+ }, undefined>;
617
+ cancelSubscription: better_call0.Endpoint<"/subscription/cancel", "POST", {
618
+ returnUrl: string;
619
+ referenceId?: string | undefined;
620
+ subscriptionId?: string | undefined;
621
+ customerType?: "user" | "organization" | undefined;
622
+ disableRedirect?: boolean | undefined;
623
+ }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
624
+ session: StripeCtxSession;
625
+ }>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>], {
700
626
  url: string;
701
627
  redirect: boolean;
702
- }>;
703
- restoreSubscription: better_call0.StrictEndpoint<"/subscription/restore", {
704
- method: "POST";
705
- body: zod.ZodObject<{
706
- referenceId: zod.ZodOptional<zod.ZodString>;
707
- subscriptionId: zod.ZodOptional<zod.ZodString>;
708
- customerType: zod.ZodOptional<zod.ZodEnum<{
709
- user: "user";
710
- organization: "organization";
711
- }>>;
712
- }, better_auth0.$strip>;
713
- metadata: {
714
- openapi: {
715
- operationId: string;
716
- };
628
+ }, {
629
+ openapi: {
630
+ operationId: string;
717
631
  };
718
- use: (((inputContext: better_call0.MiddlewareInputContext<{
719
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
720
- session: {
721
- session: Record<string, any> & {
722
- id: string;
723
- createdAt: Date;
724
- updatedAt: Date;
725
- userId: string;
726
- expiresAt: Date;
727
- token: string;
728
- ipAddress?: string | null | undefined;
729
- userAgent?: string | null | undefined;
730
- };
731
- user: Record<string, any> & {
732
- id: string;
733
- createdAt: Date;
734
- updatedAt: Date;
735
- email: string;
736
- emailVerified: boolean;
737
- name: string;
738
- image?: string | null | undefined;
739
- };
740
- };
741
- }>)[];
742
- }>) => Promise<{
743
- session: StripeCtxSession;
744
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
745
- }, Stripe.Response<Stripe.Subscription>>;
746
- listActiveSubscriptions: better_call0.StrictEndpoint<"/subscription/list", {
747
- method: "GET";
748
- query: zod.ZodOptional<zod.ZodObject<{
749
- referenceId: zod.ZodOptional<zod.ZodString>;
750
- customerType: zod.ZodOptional<zod.ZodEnum<{
751
- user: "user";
752
- organization: "organization";
753
- }>>;
754
- }, better_auth0.$strip>>;
755
- metadata: {
756
- openapi: {
757
- operationId: string;
758
- };
632
+ }, undefined>;
633
+ restoreSubscription: better_call0.Endpoint<"/subscription/restore", "POST", {
634
+ referenceId?: string | undefined;
635
+ subscriptionId?: string | undefined;
636
+ customerType?: "user" | "organization" | undefined;
637
+ }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
638
+ session: StripeCtxSession;
639
+ }>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>], Stripe.Response<Stripe.Subscription>, {
640
+ openapi: {
641
+ operationId: string;
759
642
  };
760
- use: (((inputContext: better_call0.MiddlewareInputContext<{
761
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
762
- session: {
763
- session: Record<string, any> & {
764
- id: string;
765
- createdAt: Date;
766
- updatedAt: Date;
767
- userId: string;
768
- expiresAt: Date;
769
- token: string;
770
- ipAddress?: string | null | undefined;
771
- userAgent?: string | null | undefined;
772
- };
773
- user: Record<string, any> & {
774
- id: string;
775
- createdAt: Date;
776
- updatedAt: Date;
777
- email: string;
778
- emailVerified: boolean;
779
- name: string;
780
- image?: string | null | undefined;
781
- };
782
- };
783
- }>)[];
784
- }>) => Promise<{
785
- session: StripeCtxSession;
786
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
787
- }, {
643
+ }, undefined>;
644
+ listActiveSubscriptions: better_call0.Endpoint<"/subscription/list", "GET", undefined, {
645
+ referenceId?: string | undefined;
646
+ customerType?: "user" | "organization" | undefined;
647
+ } | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
648
+ session: StripeCtxSession;
649
+ }>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>], {
788
650
  limits: Record<string, unknown> | undefined;
789
651
  priceId: string | undefined;
790
652
  id: string;
@@ -805,65 +667,32 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
805
667
  seats?: number | undefined;
806
668
  billingInterval?: "day" | "week" | "month" | "year" | undefined;
807
669
  stripeScheduleId?: string | undefined;
808
- }[]>;
809
- subscriptionSuccess: better_call0.StrictEndpoint<"/subscription/success", {
810
- method: "GET";
811
- query: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
812
- metadata: {
813
- openapi: {
814
- operationId: string;
815
- };
670
+ }[], {
671
+ openapi: {
672
+ operationId: string;
816
673
  };
817
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>)[];
818
- }, never>;
819
- createBillingPortal: better_call0.StrictEndpoint<"/subscription/billing-portal", {
820
- method: "POST";
821
- body: zod.ZodObject<{
822
- locale: zod.ZodOptional<zod.ZodCustom<Stripe.Checkout.Session.Locale, Stripe.Checkout.Session.Locale>>;
823
- referenceId: zod.ZodOptional<zod.ZodString>;
824
- customerType: zod.ZodOptional<zod.ZodEnum<{
825
- user: "user";
826
- organization: "organization";
827
- }>>;
828
- returnUrl: zod.ZodDefault<zod.ZodString>;
829
- disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
830
- }, better_auth0.$strip>;
831
- metadata: {
832
- openapi: {
833
- operationId: string;
834
- };
674
+ }, undefined>;
675
+ subscriptionSuccess: better_call0.Endpoint<"/subscription/success", "GET", undefined, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>], never, {
676
+ openapi: {
677
+ operationId: string;
835
678
  };
836
- use: (((inputContext: better_call0.MiddlewareInputContext<{
837
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
838
- session: {
839
- session: Record<string, any> & {
840
- id: string;
841
- createdAt: Date;
842
- updatedAt: Date;
843
- userId: string;
844
- expiresAt: Date;
845
- token: string;
846
- ipAddress?: string | null | undefined;
847
- userAgent?: string | null | undefined;
848
- };
849
- user: Record<string, any> & {
850
- id: string;
851
- createdAt: Date;
852
- updatedAt: Date;
853
- email: string;
854
- emailVerified: boolean;
855
- name: string;
856
- image?: string | null | undefined;
857
- };
858
- };
859
- }>)[];
860
- }>) => Promise<{
861
- session: StripeCtxSession;
862
- }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
863
- }, {
679
+ }, undefined>;
680
+ createBillingPortal: better_call0.Endpoint<"/subscription/billing-portal", "POST", {
681
+ locale?: Stripe.Checkout.Session.Locale | undefined;
682
+ referenceId?: string | undefined;
683
+ customerType?: "user" | "organization" | undefined;
684
+ returnUrl?: string | undefined;
685
+ disableRedirect?: boolean | undefined;
686
+ }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
687
+ session: StripeCtxSession;
688
+ }>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>, better_call0.Middleware<(inputContext: Record<string, any>) => Promise<void>>], {
864
689
  url: string;
865
690
  redirect: boolean;
866
- }>;
691
+ }, {
692
+ openapi: {
693
+ operationId: string;
694
+ };
695
+ }, undefined>;
867
696
  } : {});
868
697
  init(ctx: better_auth0.AuthContext): {
869
698
  options: {
@@ -1002,4 +831,4 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
1002
831
  type StripePlugin<O extends StripeOptions> = ReturnType<typeof stripe<O>>;
1003
832
  //#endregion
1004
833
  export { StripeCtxSession as a, Subscription as c, WithStripeCustomerId as d, CustomerType as i, SubscriptionOptions as l, stripe as n, StripeOptions as o, AuthorizeReferenceAction as r, StripePlan as s, StripePlugin as t, WithActiveOrganizationId as u };
1005
- //# sourceMappingURL=index-nU1KjBOz.d.mts.map
834
+ //# sourceMappingURL=index-DDwLbqpK.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as StripeCtxSession, c as Subscription, d as WithStripeCustomerId, i as CustomerType, l as SubscriptionOptions, n as stripe, o as StripeOptions, r as AuthorizeReferenceAction, s as StripePlan, t as StripePlugin, u as WithActiveOrganizationId } from "./index-nU1KjBOz.mjs";
1
+ import { a as StripeCtxSession, c as Subscription, d as WithStripeCustomerId, i as CustomerType, l as SubscriptionOptions, n as stripe, o as StripeOptions, r as AuthorizeReferenceAction, s as StripePlan, t as StripePlugin, u as WithActiveOrganizationId } from "./index-DDwLbqpK.mjs";
2
2
  export { AuthorizeReferenceAction, CustomerType, StripeCtxSession, StripeOptions, StripePlan, StripePlugin, Subscription, SubscriptionOptions, WithActiveOrganizationId, WithStripeCustomerId, stripe };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as STRIPE_ERROR_CODES } from "./error-codes-CCosYkXx.mjs";
1
+ import { t as STRIPE_ERROR_CODES } from "./error-codes-DFj-5pDu.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";
@@ -6,7 +6,6 @@ import { APIError as APIError$1 } from "@better-auth/core/error";
6
6
  import { getSessionFromCtx, originCheck, sessionMiddleware } from "better-auth/api";
7
7
  import * as z from "zod";
8
8
  import { mergeSchema } from "better-auth/db";
9
-
10
9
  //#region src/metadata.ts
11
10
  /**
12
11
  * Customer metadata - set internal fields and extract typed fields.
@@ -48,7 +47,6 @@ const subscriptionMetadata = {
48
47
  };
49
48
  }
50
49
  };
51
-
52
50
  //#endregion
53
51
  //#region src/utils.ts
54
52
  async function getPlans(subscriptionOptions) {
@@ -120,7 +118,6 @@ async function resolvePlanItem(options, items) {
120
118
  plan: void 0
121
119
  } : void 0;
122
120
  }
123
-
124
121
  //#endregion
125
122
  //#region src/hooks.ts
126
123
  /**
@@ -425,7 +422,6 @@ async function onSubscriptionDeleted(ctx, options, event) {
425
422
  ctx.context.logger.error(`Stripe webhook failed. Error: ${error}`);
426
423
  }
427
424
  }
428
-
429
425
  //#endregion
430
426
  //#region src/middleware.ts
431
427
  const stripeSessionMiddleware = createAuthMiddleware({ use: [sessionMiddleware] }, async (ctx) => {
@@ -464,7 +460,6 @@ const referenceMiddleware = (subscriptionOptions, action) => createAuthMiddlewar
464
460
  action
465
461
  }, ctx)) throw APIError$1.from("UNAUTHORIZED", STRIPE_ERROR_CODES.UNAUTHORIZED);
466
462
  });
467
-
468
463
  //#endregion
469
464
  //#region src/routes.ts
470
465
  /**
@@ -1468,7 +1463,6 @@ const stripeWebhook = (options) => {
1468
1463
  return ctx.json({ success: true });
1469
1464
  });
1470
1465
  };
1471
-
1472
1466
  //#endregion
1473
1467
  //#region src/schema.ts
1474
1468
  const subscriptions = { subscription: { fields: {
@@ -1563,7 +1557,6 @@ const getSchema = (options) => {
1563
1557
  }
1564
1558
  return mergeSchema(baseSchema, options.schema);
1565
1559
  };
1566
-
1567
1560
  //#endregion
1568
1561
  //#region src/index.ts
1569
1562
  const stripe = (options) => {
@@ -1796,7 +1789,7 @@ const stripe = (options) => {
1796
1789
  $ERROR_CODES: STRIPE_ERROR_CODES
1797
1790
  };
1798
1791
  };
1799
-
1800
1792
  //#endregion
1801
1793
  export { stripe };
1794
+
1802
1795
  //# sourceMappingURL=index.mjs.map