@better-auth/stripe 1.7.0-rc.0 → 1.7.0-rc.2
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-
|
|
2
|
-
import * as better_auth0 from "better-auth";
|
|
3
|
-
|
|
1
|
+
import { l as StripePlan, n as stripe } from "./index-DdrRRo4X.mjs";
|
|
4
2
|
//#region src/error-codes.d.ts
|
|
5
3
|
declare const STRIPE_ERROR_CODES: {
|
|
6
|
-
UNAUTHORIZED:
|
|
7
|
-
INVALID_REQUEST_BODY:
|
|
8
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
9
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
10
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
11
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
12
|
-
CUSTOMER_NOT_FOUND:
|
|
13
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
14
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
15
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
16
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
17
|
-
STRIPE_WEBHOOK_ERROR:
|
|
18
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
19
|
-
FAILED_TO_FETCH_PLANS:
|
|
20
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
21
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
22
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
23
|
-
SUBSCRIPTION_NOT_PENDING_CHANGE:
|
|
24
|
-
ORGANIZATION_NOT_FOUND:
|
|
25
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
26
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
27
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
28
|
-
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:
|
|
54
|
-
INVALID_REQUEST_BODY:
|
|
55
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
56
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
57
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
58
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
59
|
-
CUSTOMER_NOT_FOUND:
|
|
60
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
61
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
62
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
63
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
64
|
-
STRIPE_WEBHOOK_ERROR:
|
|
65
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
66
|
-
FAILED_TO_FETCH_PLANS:
|
|
67
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
68
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
69
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
70
|
-
SUBSCRIPTION_NOT_PENDING_CHANGE:
|
|
71
|
-
ORGANIZATION_NOT_FOUND:
|
|
72
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
73
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
74
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
75
|
-
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,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:
|
|
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:
|
|
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
|
-
},
|
|
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:
|
|
554
|
-
use: ((inputContext:
|
|
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:
|
|
574
|
+
}>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
580
575
|
referenceId: string;
|
|
581
|
-
}>) | ((inputContext:
|
|
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:
|
|
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
|
-
},
|
|
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:
|
|
617
|
-
use: ((inputContext:
|
|
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:
|
|
637
|
+
}>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
643
638
|
referenceId: string;
|
|
644
|
-
}>) | ((inputContext:
|
|
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:
|
|
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
|
-
},
|
|
653
|
+
}, import("zod/v4/core").$strip>;
|
|
659
654
|
metadata: {
|
|
660
655
|
openapi: {
|
|
661
656
|
operationId: string;
|
|
662
657
|
};
|
|
663
658
|
};
|
|
664
|
-
use: (((inputContext:
|
|
665
|
-
use: ((inputContext:
|
|
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:
|
|
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:
|
|
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
|
-
},
|
|
697
|
+
}, import("zod/v4/core").$strip>>;
|
|
703
698
|
metadata: {
|
|
704
699
|
openapi: {
|
|
705
700
|
operationId: string;
|
|
706
701
|
};
|
|
707
702
|
};
|
|
708
|
-
use: (((inputContext:
|
|
709
|
-
use: ((inputContext:
|
|
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:
|
|
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:
|
|
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:
|
|
762
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>)[];
|
|
768
763
|
}, never>;
|
|
769
|
-
createBillingPortal:
|
|
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
|
-
},
|
|
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:
|
|
787
|
-
use: ((inputContext:
|
|
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:
|
|
807
|
+
}>) | ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
813
808
|
referenceId: string;
|
|
814
|
-
}>) | ((inputContext:
|
|
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:
|
|
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:
|
|
820
|
+
after(user: User & WithStripeCustomerId, ctx: import("better-auth").GenericEndpointContext | null): Promise<void>;
|
|
826
821
|
};
|
|
827
822
|
update: {
|
|
828
|
-
after(user: User & WithStripeCustomerId, ctx:
|
|
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:
|
|
930
|
-
INVALID_REQUEST_BODY:
|
|
931
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
932
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
933
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
934
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
935
|
-
CUSTOMER_NOT_FOUND:
|
|
936
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
937
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
938
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
939
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
940
|
-
STRIPE_WEBHOOK_ERROR:
|
|
941
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
942
|
-
FAILED_TO_FETCH_PLANS:
|
|
943
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
944
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
945
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
946
|
-
SUBSCRIPTION_NOT_PENDING_CHANGE:
|
|
947
|
-
ORGANIZATION_NOT_FOUND:
|
|
948
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
949
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
950
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
951
|
-
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-
|
|
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-DdrRRo4X.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-
|
|
1
|
+
import { n as STRIPE_ERROR_CODES, t as PACKAGE_VERSION } from "./version-7VSXgqRo.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,
|
|
@@ -540,20 +552,65 @@ async function retrieveStripeSubscription(client, ctx, stripeSubscriptionId) {
|
|
|
540
552
|
});
|
|
541
553
|
}
|
|
542
554
|
const upgradeSubscriptionBodySchema = z.object({
|
|
555
|
+
/**
|
|
556
|
+
* The name of the plan to subscribe
|
|
557
|
+
*/
|
|
543
558
|
plan: z.string().meta({ description: "The name of the plan to upgrade to. Eg: \"pro\"" }),
|
|
559
|
+
/**
|
|
560
|
+
* If annual plan should be applied.
|
|
561
|
+
*/
|
|
544
562
|
annual: z.boolean().meta({ description: "Whether to upgrade to an annual plan. Eg: true" }).optional(),
|
|
563
|
+
/**
|
|
564
|
+
* Reference ID for the subscription based on customerType:
|
|
565
|
+
* - `user`: defaults to `user.id`
|
|
566
|
+
* - `organization`: defaults to `session.activeOrganizationId`
|
|
567
|
+
*/
|
|
545
568
|
referenceId: z.string().meta({ description: "Reference ID for the subscription. Eg: \"org_123\"" }).optional(),
|
|
569
|
+
/**
|
|
570
|
+
* The Stripe subscription ID to upgrade.
|
|
571
|
+
* If provided and not found, it'll throw an error.
|
|
572
|
+
*/
|
|
546
573
|
subscriptionId: z.string().meta({ description: "The Stripe subscription ID to upgrade. Eg: \"sub_1ABC2DEF3GHI4JKL\"" }).optional(),
|
|
574
|
+
/**
|
|
575
|
+
* Customer type for the subscription.
|
|
576
|
+
* - `user`: User owns the subscription (default)
|
|
577
|
+
* - `organization`: Organization owns the subscription (requires referenceId)
|
|
578
|
+
*/
|
|
547
579
|
customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional(),
|
|
580
|
+
/**
|
|
581
|
+
* Additional metadata to store with the subscription.
|
|
582
|
+
*/
|
|
548
583
|
metadata: z.record(z.string(), z.any()).optional(),
|
|
584
|
+
/**
|
|
585
|
+
* Number of seats for subscriptions.
|
|
586
|
+
*/
|
|
549
587
|
seats: z.number().meta({ description: "Number of seats to upgrade to (if applicable). Eg: 1" }).optional(),
|
|
588
|
+
/**
|
|
589
|
+
* The IETF language tag of the locale Checkout is displayed in.
|
|
590
|
+
* If not provided or set to `auto`, the browser's locale is used.
|
|
591
|
+
*/
|
|
550
592
|
locale: z.custom((localization) => {
|
|
551
593
|
return typeof localization === "string";
|
|
552
594
|
}).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(),
|
|
595
|
+
/**
|
|
596
|
+
* The URL to which Stripe should send customers when payment or setup is complete.
|
|
597
|
+
*/
|
|
553
598
|
successUrl: z.string().meta({ description: "Callback URL to redirect back after successful subscription. Eg: \"https://example.com/success\"" }).default("/"),
|
|
599
|
+
/**
|
|
600
|
+
* If set, checkout shows a back button and customers will be directed here if they cancel payment.
|
|
601
|
+
*/
|
|
554
602
|
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("/"),
|
|
603
|
+
/**
|
|
604
|
+
* The URL to return to from the Billing Portal (used when upgrading existing subscriptions)
|
|
605
|
+
*/
|
|
555
606
|
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(),
|
|
607
|
+
/**
|
|
608
|
+
* Schedule the plan change at the end of the current billing period instead of applying immediately.
|
|
609
|
+
*/
|
|
556
610
|
scheduleAtPeriodEnd: z.boolean().meta({ description: "Schedule the plan change at the end of the current billing period instead of applying immediately." }).default(false),
|
|
611
|
+
/**
|
|
612
|
+
* Disable Redirect
|
|
613
|
+
*/
|
|
557
614
|
disableRedirect: z.boolean().meta({ description: "Disable redirect after successful subscription. Eg: true" }).default(false)
|
|
558
615
|
});
|
|
559
616
|
/**
|
|
@@ -727,7 +784,8 @@ const upgradeSubscription = (options) => {
|
|
|
727
784
|
const stripeSubscriptionPriceId = planItem?.price.id;
|
|
728
785
|
const incompleteSubscription = subscriptions.find((sub) => sub.status === "incomplete");
|
|
729
786
|
const priceId = ctx.body.annual ? plan.annualDiscountPriceId : plan.priceId;
|
|
730
|
-
const
|
|
787
|
+
const lookupKey = ctx.body.annual ? plan.annualDiscountLookupKey : plan.lookupKey;
|
|
788
|
+
const resolvedPrice = await resolveStripePrice(client, priceId, lookupKey);
|
|
731
789
|
const priceIdToUse = resolvedPrice?.id ?? priceId;
|
|
732
790
|
if (!priceIdToUse) throw ctx.error("BAD_REQUEST", { message: "Price ID not found for the selected plan" });
|
|
733
791
|
const isMetered = isMeteredPrice(resolvedPrice);
|
|
@@ -1064,8 +1122,16 @@ const upgradeSubscription = (options) => {
|
|
|
1064
1122
|
const cancelSubscriptionBodySchema = z.object({
|
|
1065
1123
|
referenceId: z.string().meta({ description: "Reference id of the subscription to cancel. Eg: '123'" }).optional(),
|
|
1066
1124
|
subscriptionId: z.string().meta({ description: "The Stripe subscription ID to cancel. Eg: 'sub_1ABC2DEF3GHI4JKL'" }).optional(),
|
|
1125
|
+
/**
|
|
1126
|
+
* Customer type for the subscription.
|
|
1127
|
+
* - `user`: User owns the subscription (default)
|
|
1128
|
+
* - `organization`: Organization owns the subscription
|
|
1129
|
+
*/
|
|
1067
1130
|
customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional(),
|
|
1068
1131
|
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\"" }),
|
|
1132
|
+
/**
|
|
1133
|
+
* Disable Redirect
|
|
1134
|
+
*/
|
|
1069
1135
|
disableRedirect: z.boolean().meta({ description: "Disable redirect after successful subscription cancellation. Eg: true" }).default(false)
|
|
1070
1136
|
});
|
|
1071
1137
|
/**
|
|
@@ -1166,6 +1232,11 @@ const cancelSubscription = (options) => {
|
|
|
1166
1232
|
const restoreSubscriptionBodySchema = z.object({
|
|
1167
1233
|
referenceId: z.string().meta({ description: "Reference id of the subscription to restore. Eg: '123'" }).optional(),
|
|
1168
1234
|
subscriptionId: z.string().meta({ description: "The Stripe subscription ID to restore. Eg: 'sub_1ABC2DEF3GHI4JKL'" }).optional(),
|
|
1235
|
+
/**
|
|
1236
|
+
* Customer type for the subscription.
|
|
1237
|
+
* - `user`: User owns the subscription (default)
|
|
1238
|
+
* - `organization`: Organization owns the subscription
|
|
1239
|
+
*/
|
|
1169
1240
|
customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional()
|
|
1170
1241
|
});
|
|
1171
1242
|
const restoreSubscription = (options) => {
|
|
@@ -1253,6 +1324,11 @@ const restoreSubscription = (options) => {
|
|
|
1253
1324
|
};
|
|
1254
1325
|
const listActiveSubscriptionsQuerySchema = z.optional(z.object({
|
|
1255
1326
|
referenceId: z.string().meta({ description: "Reference id of the subscription to list. Eg: '123'" }).optional(),
|
|
1327
|
+
/**
|
|
1328
|
+
* Customer type for the subscription.
|
|
1329
|
+
* - `user`: User owns the subscription (default)
|
|
1330
|
+
* - `organization`: Organization owns the subscription
|
|
1331
|
+
*/
|
|
1256
1332
|
customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional()
|
|
1257
1333
|
}));
|
|
1258
1334
|
/**
|
|
@@ -1384,12 +1460,24 @@ const subscriptionSuccess = (options) => {
|
|
|
1384
1460
|
});
|
|
1385
1461
|
};
|
|
1386
1462
|
const createBillingPortalBodySchema = z.object({
|
|
1463
|
+
/**
|
|
1464
|
+
* The IETF language tag of the locale Customer Portal is displayed in.
|
|
1465
|
+
* If not provided or set to `auto`, the browser's locale is used.
|
|
1466
|
+
*/
|
|
1387
1467
|
locale: z.custom((localization) => {
|
|
1388
1468
|
return typeof localization === "string";
|
|
1389
1469
|
}).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(),
|
|
1390
1470
|
referenceId: z.string().optional(),
|
|
1471
|
+
/**
|
|
1472
|
+
* Customer type for the subscription.
|
|
1473
|
+
* - `user`: User owns the subscription (default)
|
|
1474
|
+
* - `organization`: Organization owns the subscription
|
|
1475
|
+
*/
|
|
1391
1476
|
customerType: z.enum(["user", "organization"]).meta({ description: "Customer type for the subscription. Eg: \"user\" or \"organization\"" }).optional(),
|
|
1392
1477
|
returnUrl: z.string().default("/"),
|
|
1478
|
+
/**
|
|
1479
|
+
* Disable Redirect
|
|
1480
|
+
*/
|
|
1393
1481
|
disableRedirect: z.boolean().meta({ description: "Disable redirect after creating billing portal session. Eg: true" }).default(false)
|
|
1394
1482
|
});
|
|
1395
1483
|
const createBillingPortal = (options) => {
|
|
@@ -1734,8 +1822,8 @@ const stripe = (options) => {
|
|
|
1734
1822
|
await existingHooks.afterUpdateOrganization(data);
|
|
1735
1823
|
await afterUpdateStripeOrg(data);
|
|
1736
1824
|
} : afterUpdateStripeOrg,
|
|
1737
|
-
beforeDeleteOrganization: existingHooks.beforeDeleteOrganization ? async (data) => {
|
|
1738
|
-
await existingHooks.beforeDeleteOrganization(data);
|
|
1825
|
+
beforeDeleteOrganization: existingHooks.beforeDeleteOrganization ? async (data, ctx) => {
|
|
1826
|
+
await existingHooks.beforeDeleteOrganization(data, ctx);
|
|
1739
1827
|
await beforeDeleteStripeOrg(data);
|
|
1740
1828
|
} : beforeDeleteStripeOrg,
|
|
1741
1829
|
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.7.0-rc.
|
|
33
|
+
const PACKAGE_VERSION = "1.7.0-rc.2";
|
|
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.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.2",
|
|
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.
|
|
61
|
-
"@better-auth/core": "1.7.0-rc.
|
|
62
|
-
"better-auth": "1.7.0-rc.
|
|
60
|
+
"tsdown": "0.22.7",
|
|
61
|
+
"@better-auth/core": "1.7.0-rc.2",
|
|
62
|
+
"better-auth": "1.7.0-rc.2"
|
|
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.7.0-rc.
|
|
68
|
-
"better-auth": "^1.7.0-rc.
|
|
67
|
+
"@better-auth/core": "^1.7.0-rc.2",
|
|
68
|
+
"better-auth": "^1.7.0-rc.2"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown",
|