@better-auth/stripe 1.7.11 → 1.7.13
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 +50 -53
- package/dist/client.mjs +1 -1
- package/dist/{index-FnTfZ_t2.d.mts → index-BDmSmcUM.d.mts} +101 -106
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +13 -10
- package/dist/{version-ClqjSGW-.mjs → version-KaE2hXSv.mjs} +1 -1
- package/package.json +10 -10
package/dist/client.d.mts
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
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-BDmSmcUM.mjs";
|
|
4
2
|
//#region src/error-codes.d.ts
|
|
5
|
-
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:
|
|
3
|
+
export declare const STRIPE_ERROR_CODES: {
|
|
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
|
|
32
|
-
declare const stripeClient: <O extends {
|
|
30
|
+
export declare const stripeClient: <O extends {
|
|
33
31
|
subscription: boolean;
|
|
34
32
|
}>(options?: O | undefined) => {
|
|
35
33
|
id: "stripe-client";
|
|
@@ -50,30 +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
|
-
//#endregion
|
|
79
|
-
export { STRIPE_ERROR_CODES, stripeClient };
|
|
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:
|
|
531
|
-
plan:
|
|
532
|
-
annual:
|
|
533
|
-
referenceId:
|
|
534
|
-
subscriptionId:
|
|
535
|
-
customerType:
|
|
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:
|
|
540
|
-
seats:
|
|
541
|
-
locale:
|
|
542
|
-
successUrl:
|
|
543
|
-
cancelUrl:
|
|
544
|
-
returnUrl:
|
|
545
|
-
scheduleAtPeriodEnd:
|
|
546
|
-
disableRedirect:
|
|
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: (
|
|
554
|
-
use:
|
|
548
|
+
use: (import("better-call").Middleware<{
|
|
549
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
555
550
|
session: {
|
|
556
551
|
session: Record<string, any> & {
|
|
557
552
|
id: string;
|
|
@@ -574,8 +569,8 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
574
569
|
};
|
|
575
570
|
};
|
|
576
571
|
}>>[];
|
|
577
|
-
}, (inputContext:
|
|
578
|
-
use:
|
|
572
|
+
}, (inputContext: import("better-call").MiddlewareInputContext<{
|
|
573
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
579
574
|
session: {
|
|
580
575
|
session: Record<string, any> & {
|
|
581
576
|
id: string;
|
|
@@ -600,9 +595,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
600
595
|
}>>[];
|
|
601
596
|
}>) => Promise<{
|
|
602
597
|
session: StripeCtxSession;
|
|
603
|
-
}>> |
|
|
598
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
604
599
|
referenceId: string;
|
|
605
|
-
}>> |
|
|
600
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>)[];
|
|
606
601
|
}, {
|
|
607
602
|
url: string;
|
|
608
603
|
redirect: boolean;
|
|
@@ -620,25 +615,25 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
620
615
|
} & {
|
|
621
616
|
redirect: boolean;
|
|
622
617
|
})>;
|
|
623
|
-
cancelSubscription:
|
|
618
|
+
cancelSubscription: import("better-call").StrictEndpoint<"/subscription/cancel", {
|
|
624
619
|
method: "POST";
|
|
625
|
-
body:
|
|
626
|
-
referenceId:
|
|
627
|
-
subscriptionId:
|
|
628
|
-
customerType:
|
|
620
|
+
body: import("zod").ZodObject<{
|
|
621
|
+
referenceId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
622
|
+
subscriptionId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
623
|
+
customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
629
624
|
user: "user";
|
|
630
625
|
organization: "organization";
|
|
631
626
|
}>>;
|
|
632
|
-
returnUrl:
|
|
633
|
-
disableRedirect:
|
|
634
|
-
},
|
|
627
|
+
returnUrl: import("zod").ZodString;
|
|
628
|
+
disableRedirect: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
629
|
+
}, import("zod/v4/core").$strip>;
|
|
635
630
|
metadata: {
|
|
636
631
|
openapi: {
|
|
637
632
|
operationId: string;
|
|
638
633
|
};
|
|
639
634
|
};
|
|
640
|
-
use: (
|
|
641
|
-
use:
|
|
635
|
+
use: (import("better-call").Middleware<{
|
|
636
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
642
637
|
session: {
|
|
643
638
|
session: Record<string, any> & {
|
|
644
639
|
id: string;
|
|
@@ -661,8 +656,8 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
661
656
|
};
|
|
662
657
|
};
|
|
663
658
|
}>>[];
|
|
664
|
-
}, (inputContext:
|
|
665
|
-
use:
|
|
659
|
+
}, (inputContext: import("better-call").MiddlewareInputContext<{
|
|
660
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
666
661
|
session: {
|
|
667
662
|
session: Record<string, any> & {
|
|
668
663
|
id: string;
|
|
@@ -687,30 +682,30 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
687
682
|
}>>[];
|
|
688
683
|
}>) => Promise<{
|
|
689
684
|
session: StripeCtxSession;
|
|
690
|
-
}>> |
|
|
685
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
691
686
|
referenceId: string;
|
|
692
|
-
}>> |
|
|
687
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>)[];
|
|
693
688
|
}, {
|
|
694
689
|
url: string;
|
|
695
690
|
redirect: boolean;
|
|
696
691
|
}>;
|
|
697
|
-
restoreSubscription:
|
|
692
|
+
restoreSubscription: import("better-call").StrictEndpoint<"/subscription/restore", {
|
|
698
693
|
method: "POST";
|
|
699
|
-
body:
|
|
700
|
-
referenceId:
|
|
701
|
-
subscriptionId:
|
|
702
|
-
customerType:
|
|
694
|
+
body: import("zod").ZodObject<{
|
|
695
|
+
referenceId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
696
|
+
subscriptionId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
697
|
+
customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
703
698
|
user: "user";
|
|
704
699
|
organization: "organization";
|
|
705
700
|
}>>;
|
|
706
|
-
},
|
|
701
|
+
}, import("zod/v4/core").$strip>;
|
|
707
702
|
metadata: {
|
|
708
703
|
openapi: {
|
|
709
704
|
operationId: string;
|
|
710
705
|
};
|
|
711
706
|
};
|
|
712
|
-
use: (
|
|
713
|
-
use:
|
|
707
|
+
use: (import("better-call").Middleware<{
|
|
708
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
714
709
|
session: {
|
|
715
710
|
session: Record<string, any> & {
|
|
716
711
|
id: string;
|
|
@@ -733,8 +728,8 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
733
728
|
};
|
|
734
729
|
};
|
|
735
730
|
}>>[];
|
|
736
|
-
}, (inputContext:
|
|
737
|
-
use:
|
|
731
|
+
}, (inputContext: import("better-call").MiddlewareInputContext<{
|
|
732
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
738
733
|
session: {
|
|
739
734
|
session: Record<string, any> & {
|
|
740
735
|
id: string;
|
|
@@ -759,26 +754,26 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
759
754
|
}>>[];
|
|
760
755
|
}>) => Promise<{
|
|
761
756
|
session: StripeCtxSession;
|
|
762
|
-
}>> |
|
|
757
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
763
758
|
referenceId: string;
|
|
764
759
|
}>>)[];
|
|
765
760
|
}, Stripe.Response<Stripe.Subscription>>;
|
|
766
|
-
listActiveSubscriptions:
|
|
761
|
+
listActiveSubscriptions: import("better-call").StrictEndpoint<"/subscription/list", {
|
|
767
762
|
method: "GET";
|
|
768
|
-
query:
|
|
769
|
-
referenceId:
|
|
770
|
-
customerType:
|
|
763
|
+
query: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
764
|
+
referenceId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
765
|
+
customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
771
766
|
user: "user";
|
|
772
767
|
organization: "organization";
|
|
773
768
|
}>>;
|
|
774
|
-
},
|
|
769
|
+
}, import("zod/v4/core").$strip>>;
|
|
775
770
|
metadata: {
|
|
776
771
|
openapi: {
|
|
777
772
|
operationId: string;
|
|
778
773
|
};
|
|
779
774
|
};
|
|
780
|
-
use: (
|
|
781
|
-
use:
|
|
775
|
+
use: (import("better-call").Middleware<{
|
|
776
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
782
777
|
session: {
|
|
783
778
|
session: Record<string, any> & {
|
|
784
779
|
id: string;
|
|
@@ -801,8 +796,8 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
801
796
|
};
|
|
802
797
|
};
|
|
803
798
|
}>>[];
|
|
804
|
-
}, (inputContext:
|
|
805
|
-
use:
|
|
799
|
+
}, (inputContext: import("better-call").MiddlewareInputContext<{
|
|
800
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
806
801
|
session: {
|
|
807
802
|
session: Record<string, any> & {
|
|
808
803
|
id: string;
|
|
@@ -827,7 +822,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
827
822
|
}>>[];
|
|
828
823
|
}>) => Promise<{
|
|
829
824
|
session: StripeCtxSession;
|
|
830
|
-
}>> |
|
|
825
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
831
826
|
referenceId: string;
|
|
832
827
|
}>>)[];
|
|
833
828
|
}, {
|
|
@@ -852,35 +847,35 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
852
847
|
billingInterval?: "day" | "week" | "month" | "year" | undefined;
|
|
853
848
|
stripeScheduleId?: string | undefined;
|
|
854
849
|
}[]>;
|
|
855
|
-
subscriptionSuccess:
|
|
850
|
+
subscriptionSuccess: import("better-call").StrictEndpoint<"/subscription/success", {
|
|
856
851
|
method: "GET";
|
|
857
|
-
query:
|
|
852
|
+
query: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
858
853
|
metadata: {
|
|
859
854
|
openapi: {
|
|
860
855
|
operationId: string;
|
|
861
856
|
};
|
|
862
857
|
};
|
|
863
|
-
use:
|
|
858
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>[];
|
|
864
859
|
}, never>;
|
|
865
|
-
createBillingPortal:
|
|
860
|
+
createBillingPortal: import("better-call").StrictEndpoint<"/subscription/billing-portal", {
|
|
866
861
|
method: "POST";
|
|
867
|
-
body:
|
|
868
|
-
locale:
|
|
869
|
-
referenceId:
|
|
870
|
-
customerType:
|
|
862
|
+
body: import("zod").ZodObject<{
|
|
863
|
+
locale: import("zod").ZodOptional<import("zod").ZodCustom<CheckoutSessionLocale, CheckoutSessionLocale>>;
|
|
864
|
+
referenceId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
865
|
+
customerType: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
871
866
|
user: "user";
|
|
872
867
|
organization: "organization";
|
|
873
868
|
}>>;
|
|
874
|
-
returnUrl:
|
|
875
|
-
disableRedirect:
|
|
876
|
-
},
|
|
869
|
+
returnUrl: import("zod").ZodDefault<import("zod").ZodString>;
|
|
870
|
+
disableRedirect: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
871
|
+
}, import("zod/v4/core").$strip>;
|
|
877
872
|
metadata: {
|
|
878
873
|
openapi: {
|
|
879
874
|
operationId: string;
|
|
880
875
|
};
|
|
881
876
|
};
|
|
882
|
-
use: (
|
|
883
|
-
use:
|
|
877
|
+
use: (import("better-call").Middleware<{
|
|
878
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
884
879
|
session: {
|
|
885
880
|
session: Record<string, any> & {
|
|
886
881
|
id: string;
|
|
@@ -903,8 +898,8 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
903
898
|
};
|
|
904
899
|
};
|
|
905
900
|
}>>[];
|
|
906
|
-
}, (inputContext:
|
|
907
|
-
use:
|
|
901
|
+
}, (inputContext: import("better-call").MiddlewareInputContext<{
|
|
902
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
908
903
|
session: {
|
|
909
904
|
session: Record<string, any> & {
|
|
910
905
|
id: string;
|
|
@@ -929,23 +924,23 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
929
924
|
}>>[];
|
|
930
925
|
}>) => Promise<{
|
|
931
926
|
session: StripeCtxSession;
|
|
932
|
-
}>> |
|
|
927
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
933
928
|
referenceId: string;
|
|
934
|
-
}>> |
|
|
929
|
+
}>> | import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>)[];
|
|
935
930
|
}, {
|
|
936
931
|
url: string;
|
|
937
932
|
redirect: boolean;
|
|
938
933
|
}>;
|
|
939
934
|
} : {});
|
|
940
|
-
init(ctx:
|
|
935
|
+
init(ctx: import("better-auth").AuthContext): {
|
|
941
936
|
options: {
|
|
942
937
|
databaseHooks: {
|
|
943
938
|
user: {
|
|
944
939
|
create: {
|
|
945
|
-
after(user: User & WithStripeCustomerId, ctx:
|
|
940
|
+
after(user: User & WithStripeCustomerId, ctx: import("better-auth").GenericEndpointContext | null): Promise<void>;
|
|
946
941
|
};
|
|
947
942
|
update: {
|
|
948
|
-
after(user: User & WithStripeCustomerId, ctx:
|
|
943
|
+
after(user: User & WithStripeCustomerId, ctx: import("better-auth").GenericEndpointContext | null): Promise<void>;
|
|
949
944
|
};
|
|
950
945
|
};
|
|
951
946
|
};
|
|
@@ -1046,29 +1041,29 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
1046
1041
|
} : {});
|
|
1047
1042
|
options: NoInfer<O>;
|
|
1048
1043
|
$ERROR_CODES: {
|
|
1049
|
-
UNAUTHORIZED:
|
|
1050
|
-
INVALID_REQUEST_BODY:
|
|
1051
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
1052
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
1053
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
1054
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
1055
|
-
CUSTOMER_NOT_FOUND:
|
|
1056
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
1057
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
1058
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
1059
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
1060
|
-
STRIPE_WEBHOOK_ERROR:
|
|
1061
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
1062
|
-
FAILED_TO_FETCH_PLANS:
|
|
1063
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
1064
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
1065
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
1066
|
-
SUBSCRIPTION_NOT_PENDING_CHANGE:
|
|
1067
|
-
ORGANIZATION_NOT_FOUND:
|
|
1068
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
1069
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
1070
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
1071
|
-
ORGANIZATION_REFERENCE_ID_REQUIRED:
|
|
1044
|
+
UNAUTHORIZED: import("better-auth").RawError<"UNAUTHORIZED">;
|
|
1045
|
+
INVALID_REQUEST_BODY: import("better-auth").RawError<"INVALID_REQUEST_BODY">;
|
|
1046
|
+
SUBSCRIPTION_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_NOT_FOUND">;
|
|
1047
|
+
SUBSCRIPTION_PLAN_NOT_FOUND: import("better-auth").RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
|
|
1048
|
+
ALREADY_SUBSCRIBED_PLAN: import("better-auth").RawError<"ALREADY_SUBSCRIBED_PLAN">;
|
|
1049
|
+
REFERENCE_ID_NOT_ALLOWED: import("better-auth").RawError<"REFERENCE_ID_NOT_ALLOWED">;
|
|
1050
|
+
CUSTOMER_NOT_FOUND: import("better-auth").RawError<"CUSTOMER_NOT_FOUND">;
|
|
1051
|
+
UNABLE_TO_CREATE_CUSTOMER: import("better-auth").RawError<"UNABLE_TO_CREATE_CUSTOMER">;
|
|
1052
|
+
UNABLE_TO_CREATE_BILLING_PORTAL: import("better-auth").RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
|
|
1053
|
+
STRIPE_SIGNATURE_NOT_FOUND: import("better-auth").RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
|
|
1054
|
+
STRIPE_WEBHOOK_SECRET_NOT_FOUND: import("better-auth").RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
|
|
1055
|
+
STRIPE_WEBHOOK_ERROR: import("better-auth").RawError<"STRIPE_WEBHOOK_ERROR">;
|
|
1056
|
+
FAILED_TO_CONSTRUCT_STRIPE_EVENT: import("better-auth").RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
|
|
1057
|
+
FAILED_TO_FETCH_PLANS: import("better-auth").RawError<"FAILED_TO_FETCH_PLANS">;
|
|
1058
|
+
EMAIL_VERIFICATION_REQUIRED: import("better-auth").RawError<"EMAIL_VERIFICATION_REQUIRED">;
|
|
1059
|
+
SUBSCRIPTION_NOT_ACTIVE: import("better-auth").RawError<"SUBSCRIPTION_NOT_ACTIVE">;
|
|
1060
|
+
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: import("better-auth").RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
|
|
1061
|
+
SUBSCRIPTION_NOT_PENDING_CHANGE: import("better-auth").RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
|
|
1062
|
+
ORGANIZATION_NOT_FOUND: import("better-auth").RawError<"ORGANIZATION_NOT_FOUND">;
|
|
1063
|
+
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: import("better-auth").RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
|
|
1064
|
+
AUTHORIZE_REFERENCE_REQUIRED: import("better-auth").RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
|
|
1065
|
+
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: import("better-auth").RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
|
|
1066
|
+
ORGANIZATION_REFERENCE_ID_REQUIRED: import("better-auth").RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
|
|
1072
1067
|
};
|
|
1073
1068
|
};
|
|
1074
1069
|
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-BDmSmcUM.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-KaE2hXSv.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"
|
|
@@ -788,7 +788,8 @@ const upgradeSubscription = (options) => {
|
|
|
788
788
|
const stripeSubscriptionPriceId = planItem?.price.id;
|
|
789
789
|
const incompleteSubscription = subscriptions.find((sub) => sub.status === "incomplete");
|
|
790
790
|
const priceId = ctx.body.annual ? plan.annualDiscountPriceId : plan.priceId;
|
|
791
|
-
const
|
|
791
|
+
const lookupKey = ctx.body.annual ? plan.annualDiscountLookupKey : plan.lookupKey;
|
|
792
|
+
const resolvedPrice = await resolveStripePrice(client, priceId, lookupKey);
|
|
792
793
|
const priceIdToUse = resolvedPrice?.id ?? priceId;
|
|
793
794
|
if (!priceIdToUse) throw ctx.error("BAD_REQUEST", { message: "Price ID not found for the selected plan" });
|
|
794
795
|
const isMetered = isMeteredPrice(resolvedPrice);
|
|
@@ -900,8 +901,10 @@ const upgradeSubscription = (options) => {
|
|
|
900
901
|
quantity: item.quantity
|
|
901
902
|
});
|
|
902
903
|
const d = lineItemDelta.get(itemPriceId);
|
|
903
|
-
if (d !== void 0 && d > 0)
|
|
904
|
-
|
|
904
|
+
if (d !== void 0 && d > 0) {
|
|
905
|
+
if (d === 1) lineItemDelta.delete(itemPriceId);
|
|
906
|
+
else lineItemDelta.set(itemPriceId, d - 1);
|
|
907
|
+
}
|
|
905
908
|
}
|
|
906
909
|
for (const [price, delta] of lineItemDelta) for (let i = 0; i < delta; i++) newPhaseItems.push({ price });
|
|
907
910
|
await client.subscriptionSchedules.update(schedule.id, {
|
|
@@ -969,8 +972,10 @@ const upgradeSubscription = (options) => {
|
|
|
969
972
|
continue;
|
|
970
973
|
}
|
|
971
974
|
const d = lineItemDelta.get(si.price.id);
|
|
972
|
-
if (d !== void 0 && d > 0)
|
|
973
|
-
|
|
975
|
+
if (d !== void 0 && d > 0) {
|
|
976
|
+
if (d === 1) lineItemDelta.delete(si.price.id);
|
|
977
|
+
else lineItemDelta.set(si.price.id, d - 1);
|
|
978
|
+
}
|
|
974
979
|
}
|
|
975
980
|
for (const [price, delta] of lineItemDelta) for (let i = 0; i < delta; i++) itemUpdates.push({ price });
|
|
976
981
|
await client.subscriptions.update(activeSubscription.id, {
|
|
@@ -1585,9 +1590,7 @@ const stripeWebhook = (options) => {
|
|
|
1585
1590
|
await onSubscriptionDeleted(ctx, options, event);
|
|
1586
1591
|
await options.onEvent?.(event);
|
|
1587
1592
|
break;
|
|
1588
|
-
default:
|
|
1589
|
-
await options.onEvent?.(event);
|
|
1590
|
-
break;
|
|
1593
|
+
default: await options.onEvent?.(event);
|
|
1591
1594
|
}
|
|
1592
1595
|
} catch (e) {
|
|
1593
1596
|
ctx.context.logger.error(`Stripe webhook failed. Error: ${e.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/stripe",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13",
|
|
4
4
|
"description": "Stripe plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,17 +55,17 @@
|
|
|
55
55
|
"zod": "^4.5.4"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"better-call": "1.4.
|
|
59
|
-
"stripe": "^
|
|
60
|
-
"tsdown": "0.
|
|
61
|
-
"@better-auth/core": "1.7.
|
|
62
|
-
"better-auth": "1.7.
|
|
58
|
+
"better-call": "1.4.4",
|
|
59
|
+
"stripe": "^23.0.0",
|
|
60
|
+
"tsdown": "0.23.1",
|
|
61
|
+
"@better-auth/core": "1.7.13",
|
|
62
|
+
"better-auth": "1.7.13"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"better-call": "1.4.
|
|
66
|
-
"stripe": "^18 || ^19 || ^20 || ^21 || ^22",
|
|
67
|
-
"@better-auth/core": "^1.7.
|
|
68
|
-
"better-auth": "^1.7.
|
|
65
|
+
"better-call": "1.4.4",
|
|
66
|
+
"stripe": "^18 || ^19 || ^20 || ^21 || ^22 || ^23",
|
|
67
|
+
"@better-auth/core": "^1.7.13",
|
|
68
|
+
"better-auth": "^1.7.13"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown",
|