@better-auth/stripe 1.6.26 → 1.6.28
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,29 +1,31 @@
|
|
|
1
|
-
import { l as StripePlan, n as stripe } from "./index-
|
|
1
|
+
import { l as StripePlan, n as stripe } from "./index-Dkb8cZck.mjs";
|
|
2
|
+
import * as _$better_auth0 from "better-auth";
|
|
3
|
+
|
|
2
4
|
//#region src/error-codes.d.ts
|
|
3
5
|
declare const STRIPE_ERROR_CODES: {
|
|
4
|
-
UNAUTHORIZED:
|
|
5
|
-
INVALID_REQUEST_BODY:
|
|
6
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
7
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
8
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
9
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
10
|
-
CUSTOMER_NOT_FOUND:
|
|
11
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
12
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
13
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
14
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
15
|
-
STRIPE_WEBHOOK_ERROR:
|
|
16
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
17
|
-
FAILED_TO_FETCH_PLANS:
|
|
18
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
19
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
20
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
21
|
-
SUBSCRIPTION_NOT_PENDING_CHANGE:
|
|
22
|
-
ORGANIZATION_NOT_FOUND:
|
|
23
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
24
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
25
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
26
|
-
ORGANIZATION_REFERENCE_ID_REQUIRED:
|
|
6
|
+
UNAUTHORIZED: _$better_auth0.RawError<"UNAUTHORIZED">;
|
|
7
|
+
INVALID_REQUEST_BODY: _$better_auth0.RawError<"INVALID_REQUEST_BODY">;
|
|
8
|
+
SUBSCRIPTION_NOT_FOUND: _$better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
|
|
9
|
+
SUBSCRIPTION_PLAN_NOT_FOUND: _$better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
|
|
10
|
+
ALREADY_SUBSCRIBED_PLAN: _$better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
|
|
11
|
+
REFERENCE_ID_NOT_ALLOWED: _$better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
|
|
12
|
+
CUSTOMER_NOT_FOUND: _$better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
|
|
13
|
+
UNABLE_TO_CREATE_CUSTOMER: _$better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
|
|
14
|
+
UNABLE_TO_CREATE_BILLING_PORTAL: _$better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
|
|
15
|
+
STRIPE_SIGNATURE_NOT_FOUND: _$better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
|
|
16
|
+
STRIPE_WEBHOOK_SECRET_NOT_FOUND: _$better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
|
|
17
|
+
STRIPE_WEBHOOK_ERROR: _$better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
|
|
18
|
+
FAILED_TO_CONSTRUCT_STRIPE_EVENT: _$better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
|
|
19
|
+
FAILED_TO_FETCH_PLANS: _$better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
|
|
20
|
+
EMAIL_VERIFICATION_REQUIRED: _$better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
|
|
21
|
+
SUBSCRIPTION_NOT_ACTIVE: _$better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
|
|
22
|
+
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: _$better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
|
|
23
|
+
SUBSCRIPTION_NOT_PENDING_CHANGE: _$better_auth0.RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
|
|
24
|
+
ORGANIZATION_NOT_FOUND: _$better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
|
|
25
|
+
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: _$better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
|
|
26
|
+
AUTHORIZE_REFERENCE_REQUIRED: _$better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
|
|
27
|
+
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: _$better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
|
|
28
|
+
ORGANIZATION_REFERENCE_ID_REQUIRED: _$better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
|
|
27
29
|
};
|
|
28
30
|
//#endregion
|
|
29
31
|
//#region src/client.d.ts
|
|
@@ -48,29 +50,29 @@ declare const stripeClient: <O extends {
|
|
|
48
50
|
"/subscription/restore": "POST";
|
|
49
51
|
};
|
|
50
52
|
$ERROR_CODES: {
|
|
51
|
-
UNAUTHORIZED:
|
|
52
|
-
INVALID_REQUEST_BODY:
|
|
53
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
54
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
55
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
56
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
57
|
-
CUSTOMER_NOT_FOUND:
|
|
58
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
59
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
60
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
61
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
62
|
-
STRIPE_WEBHOOK_ERROR:
|
|
63
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
64
|
-
FAILED_TO_FETCH_PLANS:
|
|
65
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
66
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
67
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
68
|
-
SUBSCRIPTION_NOT_PENDING_CHANGE:
|
|
69
|
-
ORGANIZATION_NOT_FOUND:
|
|
70
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
71
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
72
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
73
|
-
ORGANIZATION_REFERENCE_ID_REQUIRED:
|
|
53
|
+
UNAUTHORIZED: _$better_auth0.RawError<"UNAUTHORIZED">;
|
|
54
|
+
INVALID_REQUEST_BODY: _$better_auth0.RawError<"INVALID_REQUEST_BODY">;
|
|
55
|
+
SUBSCRIPTION_NOT_FOUND: _$better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
|
|
56
|
+
SUBSCRIPTION_PLAN_NOT_FOUND: _$better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
|
|
57
|
+
ALREADY_SUBSCRIBED_PLAN: _$better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
|
|
58
|
+
REFERENCE_ID_NOT_ALLOWED: _$better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
|
|
59
|
+
CUSTOMER_NOT_FOUND: _$better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
|
|
60
|
+
UNABLE_TO_CREATE_CUSTOMER: _$better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
|
|
61
|
+
UNABLE_TO_CREATE_BILLING_PORTAL: _$better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
|
|
62
|
+
STRIPE_SIGNATURE_NOT_FOUND: _$better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
|
|
63
|
+
STRIPE_WEBHOOK_SECRET_NOT_FOUND: _$better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
|
|
64
|
+
STRIPE_WEBHOOK_ERROR: _$better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
|
|
65
|
+
FAILED_TO_CONSTRUCT_STRIPE_EVENT: _$better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
|
|
66
|
+
FAILED_TO_FETCH_PLANS: _$better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
|
|
67
|
+
EMAIL_VERIFICATION_REQUIRED: _$better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
|
|
68
|
+
SUBSCRIPTION_NOT_ACTIVE: _$better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
|
|
69
|
+
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: _$better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
|
|
70
|
+
SUBSCRIPTION_NOT_PENDING_CHANGE: _$better_auth0.RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
|
|
71
|
+
ORGANIZATION_NOT_FOUND: _$better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
|
|
72
|
+
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: _$better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
|
|
73
|
+
AUTHORIZE_REFERENCE_REQUIRED: _$better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
|
|
74
|
+
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: _$better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
|
|
75
|
+
ORGANIZATION_REFERENCE_ID_REQUIRED: _$better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
|
|
74
76
|
};
|
|
75
77
|
};
|
|
76
78
|
//#endregion
|
package/dist/client.mjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import * as _$better_auth0 from "better-auth";
|
|
1
2
|
import { GenericEndpointContext, InferOptionSchema, Session, User } from "better-auth";
|
|
3
|
+
import * as _$zod from "zod";
|
|
4
|
+
import * as _$better_call0 from "better-call";
|
|
2
5
|
import { Organization } from "better-auth/plugins/organization";
|
|
3
6
|
import Stripe from "stripe";
|
|
7
|
+
import * as _$zod_v4_core0 from "zod/v4/core";
|
|
8
|
+
|
|
4
9
|
//#region src/schema.d.ts
|
|
5
10
|
declare const subscriptions: {
|
|
6
11
|
subscription: {
|
|
@@ -504,7 +509,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
504
509
|
id: "stripe";
|
|
505
510
|
version: string;
|
|
506
511
|
endpoints: {
|
|
507
|
-
stripeWebhook:
|
|
512
|
+
stripeWebhook: _$better_call0.StrictEndpoint<"/stripe/webhook", {
|
|
508
513
|
method: "POST";
|
|
509
514
|
metadata: {
|
|
510
515
|
openapi: {
|
|
@@ -520,33 +525,33 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
520
525
|
} & (O["subscription"] extends {
|
|
521
526
|
enabled: true;
|
|
522
527
|
} ? {
|
|
523
|
-
upgradeSubscription:
|
|
528
|
+
upgradeSubscription: _$better_call0.StrictEndpoint<"/subscription/upgrade", {
|
|
524
529
|
method: "POST";
|
|
525
|
-
body:
|
|
526
|
-
plan:
|
|
527
|
-
annual:
|
|
528
|
-
referenceId:
|
|
529
|
-
subscriptionId:
|
|
530
|
-
customerType:
|
|
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<{
|
|
531
536
|
user: "user";
|
|
532
537
|
organization: "organization";
|
|
533
538
|
}>>;
|
|
534
|
-
metadata:
|
|
535
|
-
seats:
|
|
536
|
-
locale:
|
|
537
|
-
successUrl:
|
|
538
|
-
cancelUrl:
|
|
539
|
-
returnUrl:
|
|
540
|
-
scheduleAtPeriodEnd:
|
|
541
|
-
disableRedirect:
|
|
542
|
-
},
|
|
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
|
+
}, _$zod_v4_core0.$strip>;
|
|
543
548
|
metadata: {
|
|
544
549
|
openapi: {
|
|
545
550
|
operationId: string;
|
|
546
551
|
};
|
|
547
552
|
};
|
|
548
|
-
use: (
|
|
549
|
-
use: (
|
|
553
|
+
use: (_$better_call0.Middleware<{
|
|
554
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
550
555
|
session: {
|
|
551
556
|
session: Record<string, any> & {
|
|
552
557
|
id: string;
|
|
@@ -568,12 +573,36 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
568
573
|
image?: string | null | undefined;
|
|
569
574
|
};
|
|
570
575
|
};
|
|
571
|
-
}
|
|
576
|
+
}>>[];
|
|
577
|
+
}, (inputContext: _$better_call0.MiddlewareInputContext<{
|
|
578
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
579
|
+
session: {
|
|
580
|
+
session: Record<string, any> & {
|
|
581
|
+
id: string;
|
|
582
|
+
createdAt: Date;
|
|
583
|
+
updatedAt: Date;
|
|
584
|
+
userId: string;
|
|
585
|
+
expiresAt: Date;
|
|
586
|
+
token: string;
|
|
587
|
+
ipAddress?: string | null | undefined;
|
|
588
|
+
userAgent?: string | null | undefined;
|
|
589
|
+
};
|
|
590
|
+
user: Record<string, any> & {
|
|
591
|
+
id: string;
|
|
592
|
+
createdAt: Date;
|
|
593
|
+
updatedAt: Date;
|
|
594
|
+
email: string;
|
|
595
|
+
emailVerified: boolean;
|
|
596
|
+
name: string;
|
|
597
|
+
image?: string | null | undefined;
|
|
598
|
+
};
|
|
599
|
+
};
|
|
600
|
+
}>>[];
|
|
572
601
|
}>) => Promise<{
|
|
573
602
|
session: StripeCtxSession;
|
|
574
|
-
}
|
|
603
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
575
604
|
referenceId: string;
|
|
576
|
-
}
|
|
605
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>)[];
|
|
577
606
|
}, {
|
|
578
607
|
url: string;
|
|
579
608
|
redirect: boolean;
|
|
@@ -591,25 +620,25 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
591
620
|
} & {
|
|
592
621
|
redirect: boolean;
|
|
593
622
|
})>;
|
|
594
|
-
cancelSubscription:
|
|
623
|
+
cancelSubscription: _$better_call0.StrictEndpoint<"/subscription/cancel", {
|
|
595
624
|
method: "POST";
|
|
596
|
-
body:
|
|
597
|
-
referenceId:
|
|
598
|
-
subscriptionId:
|
|
599
|
-
customerType:
|
|
625
|
+
body: _$zod.ZodObject<{
|
|
626
|
+
referenceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
627
|
+
subscriptionId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
628
|
+
customerType: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
600
629
|
user: "user";
|
|
601
630
|
organization: "organization";
|
|
602
631
|
}>>;
|
|
603
|
-
returnUrl:
|
|
604
|
-
disableRedirect:
|
|
605
|
-
},
|
|
632
|
+
returnUrl: _$zod.ZodString;
|
|
633
|
+
disableRedirect: _$zod.ZodDefault<_$zod.ZodBoolean>;
|
|
634
|
+
}, _$zod_v4_core0.$strip>;
|
|
606
635
|
metadata: {
|
|
607
636
|
openapi: {
|
|
608
637
|
operationId: string;
|
|
609
638
|
};
|
|
610
639
|
};
|
|
611
|
-
use: (
|
|
612
|
-
use: (
|
|
640
|
+
use: (_$better_call0.Middleware<{
|
|
641
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
613
642
|
session: {
|
|
614
643
|
session: Record<string, any> & {
|
|
615
644
|
id: string;
|
|
@@ -631,33 +660,57 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
631
660
|
image?: string | null | undefined;
|
|
632
661
|
};
|
|
633
662
|
};
|
|
634
|
-
}
|
|
663
|
+
}>>[];
|
|
664
|
+
}, (inputContext: _$better_call0.MiddlewareInputContext<{
|
|
665
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
666
|
+
session: {
|
|
667
|
+
session: Record<string, any> & {
|
|
668
|
+
id: string;
|
|
669
|
+
createdAt: Date;
|
|
670
|
+
updatedAt: Date;
|
|
671
|
+
userId: string;
|
|
672
|
+
expiresAt: Date;
|
|
673
|
+
token: string;
|
|
674
|
+
ipAddress?: string | null | undefined;
|
|
675
|
+
userAgent?: string | null | undefined;
|
|
676
|
+
};
|
|
677
|
+
user: Record<string, any> & {
|
|
678
|
+
id: string;
|
|
679
|
+
createdAt: Date;
|
|
680
|
+
updatedAt: Date;
|
|
681
|
+
email: string;
|
|
682
|
+
emailVerified: boolean;
|
|
683
|
+
name: string;
|
|
684
|
+
image?: string | null | undefined;
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
}>>[];
|
|
635
688
|
}>) => Promise<{
|
|
636
689
|
session: StripeCtxSession;
|
|
637
|
-
}
|
|
690
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
638
691
|
referenceId: string;
|
|
639
|
-
}
|
|
692
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>)[];
|
|
640
693
|
}, {
|
|
641
694
|
url: string;
|
|
642
695
|
redirect: boolean;
|
|
643
696
|
}>;
|
|
644
|
-
restoreSubscription:
|
|
697
|
+
restoreSubscription: _$better_call0.StrictEndpoint<"/subscription/restore", {
|
|
645
698
|
method: "POST";
|
|
646
|
-
body:
|
|
647
|
-
referenceId:
|
|
648
|
-
subscriptionId:
|
|
649
|
-
customerType:
|
|
699
|
+
body: _$zod.ZodObject<{
|
|
700
|
+
referenceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
701
|
+
subscriptionId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
702
|
+
customerType: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
650
703
|
user: "user";
|
|
651
704
|
organization: "organization";
|
|
652
705
|
}>>;
|
|
653
|
-
},
|
|
706
|
+
}, _$zod_v4_core0.$strip>;
|
|
654
707
|
metadata: {
|
|
655
708
|
openapi: {
|
|
656
709
|
operationId: string;
|
|
657
710
|
};
|
|
658
711
|
};
|
|
659
|
-
use: (
|
|
660
|
-
use: (
|
|
712
|
+
use: (_$better_call0.Middleware<{
|
|
713
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
661
714
|
session: {
|
|
662
715
|
session: Record<string, any> & {
|
|
663
716
|
id: string;
|
|
@@ -679,29 +732,77 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
679
732
|
image?: string | null | undefined;
|
|
680
733
|
};
|
|
681
734
|
};
|
|
682
|
-
}
|
|
735
|
+
}>>[];
|
|
736
|
+
}, (inputContext: _$better_call0.MiddlewareInputContext<{
|
|
737
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
738
|
+
session: {
|
|
739
|
+
session: Record<string, any> & {
|
|
740
|
+
id: string;
|
|
741
|
+
createdAt: Date;
|
|
742
|
+
updatedAt: Date;
|
|
743
|
+
userId: string;
|
|
744
|
+
expiresAt: Date;
|
|
745
|
+
token: string;
|
|
746
|
+
ipAddress?: string | null | undefined;
|
|
747
|
+
userAgent?: string | null | undefined;
|
|
748
|
+
};
|
|
749
|
+
user: Record<string, any> & {
|
|
750
|
+
id: string;
|
|
751
|
+
createdAt: Date;
|
|
752
|
+
updatedAt: Date;
|
|
753
|
+
email: string;
|
|
754
|
+
emailVerified: boolean;
|
|
755
|
+
name: string;
|
|
756
|
+
image?: string | null | undefined;
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
}>>[];
|
|
683
760
|
}>) => Promise<{
|
|
684
761
|
session: StripeCtxSession;
|
|
685
|
-
}
|
|
762
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
686
763
|
referenceId: string;
|
|
687
|
-
}
|
|
764
|
+
}>>)[];
|
|
688
765
|
}, Stripe.Response<Stripe.Subscription>>;
|
|
689
|
-
listActiveSubscriptions:
|
|
766
|
+
listActiveSubscriptions: _$better_call0.StrictEndpoint<"/subscription/list", {
|
|
690
767
|
method: "GET";
|
|
691
|
-
query:
|
|
692
|
-
referenceId:
|
|
693
|
-
customerType:
|
|
768
|
+
query: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
769
|
+
referenceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
770
|
+
customerType: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
694
771
|
user: "user";
|
|
695
772
|
organization: "organization";
|
|
696
773
|
}>>;
|
|
697
|
-
},
|
|
774
|
+
}, _$zod_v4_core0.$strip>>;
|
|
698
775
|
metadata: {
|
|
699
776
|
openapi: {
|
|
700
777
|
operationId: string;
|
|
701
778
|
};
|
|
702
779
|
};
|
|
703
|
-
use: (
|
|
704
|
-
use: (
|
|
780
|
+
use: (_$better_call0.Middleware<{
|
|
781
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
782
|
+
session: {
|
|
783
|
+
session: Record<string, any> & {
|
|
784
|
+
id: string;
|
|
785
|
+
createdAt: Date;
|
|
786
|
+
updatedAt: Date;
|
|
787
|
+
userId: string;
|
|
788
|
+
expiresAt: Date;
|
|
789
|
+
token: string;
|
|
790
|
+
ipAddress?: string | null | undefined;
|
|
791
|
+
userAgent?: string | null | undefined;
|
|
792
|
+
};
|
|
793
|
+
user: Record<string, any> & {
|
|
794
|
+
id: string;
|
|
795
|
+
createdAt: Date;
|
|
796
|
+
updatedAt: Date;
|
|
797
|
+
email: string;
|
|
798
|
+
emailVerified: boolean;
|
|
799
|
+
name: string;
|
|
800
|
+
image?: string | null | undefined;
|
|
801
|
+
};
|
|
802
|
+
};
|
|
803
|
+
}>>[];
|
|
804
|
+
}, (inputContext: _$better_call0.MiddlewareInputContext<{
|
|
805
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
705
806
|
session: {
|
|
706
807
|
session: Record<string, any> & {
|
|
707
808
|
id: string;
|
|
@@ -723,12 +824,12 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
723
824
|
image?: string | null | undefined;
|
|
724
825
|
};
|
|
725
826
|
};
|
|
726
|
-
}
|
|
827
|
+
}>>[];
|
|
727
828
|
}>) => Promise<{
|
|
728
829
|
session: StripeCtxSession;
|
|
729
|
-
}
|
|
830
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
730
831
|
referenceId: string;
|
|
731
|
-
}
|
|
832
|
+
}>>)[];
|
|
732
833
|
}, {
|
|
733
834
|
limits: Record<string, unknown> | undefined;
|
|
734
835
|
priceId: string | undefined;
|
|
@@ -751,35 +852,59 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
751
852
|
billingInterval?: "day" | "week" | "month" | "year" | undefined;
|
|
752
853
|
stripeScheduleId?: string | undefined;
|
|
753
854
|
}[]>;
|
|
754
|
-
subscriptionSuccess:
|
|
855
|
+
subscriptionSuccess: _$better_call0.StrictEndpoint<"/subscription/success", {
|
|
755
856
|
method: "GET";
|
|
756
|
-
query:
|
|
857
|
+
query: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodAny>>;
|
|
757
858
|
metadata: {
|
|
758
859
|
openapi: {
|
|
759
860
|
operationId: string;
|
|
760
861
|
};
|
|
761
862
|
};
|
|
762
|
-
use: (
|
|
863
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>[];
|
|
763
864
|
}, never>;
|
|
764
|
-
createBillingPortal:
|
|
865
|
+
createBillingPortal: _$better_call0.StrictEndpoint<"/subscription/billing-portal", {
|
|
765
866
|
method: "POST";
|
|
766
|
-
body:
|
|
767
|
-
locale:
|
|
768
|
-
referenceId:
|
|
769
|
-
customerType:
|
|
867
|
+
body: _$zod.ZodObject<{
|
|
868
|
+
locale: _$zod.ZodOptional<_$zod.ZodCustom<CheckoutSessionLocale, CheckoutSessionLocale>>;
|
|
869
|
+
referenceId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
870
|
+
customerType: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
770
871
|
user: "user";
|
|
771
872
|
organization: "organization";
|
|
772
873
|
}>>;
|
|
773
|
-
returnUrl:
|
|
774
|
-
disableRedirect:
|
|
775
|
-
},
|
|
874
|
+
returnUrl: _$zod.ZodDefault<_$zod.ZodString>;
|
|
875
|
+
disableRedirect: _$zod.ZodDefault<_$zod.ZodBoolean>;
|
|
876
|
+
}, _$zod_v4_core0.$strip>;
|
|
776
877
|
metadata: {
|
|
777
878
|
openapi: {
|
|
778
879
|
operationId: string;
|
|
779
880
|
};
|
|
780
881
|
};
|
|
781
|
-
use: (
|
|
782
|
-
use: (
|
|
882
|
+
use: (_$better_call0.Middleware<{
|
|
883
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
884
|
+
session: {
|
|
885
|
+
session: Record<string, any> & {
|
|
886
|
+
id: string;
|
|
887
|
+
createdAt: Date;
|
|
888
|
+
updatedAt: Date;
|
|
889
|
+
userId: string;
|
|
890
|
+
expiresAt: Date;
|
|
891
|
+
token: string;
|
|
892
|
+
ipAddress?: string | null | undefined;
|
|
893
|
+
userAgent?: string | null | undefined;
|
|
894
|
+
};
|
|
895
|
+
user: Record<string, any> & {
|
|
896
|
+
id: string;
|
|
897
|
+
createdAt: Date;
|
|
898
|
+
updatedAt: Date;
|
|
899
|
+
email: string;
|
|
900
|
+
emailVerified: boolean;
|
|
901
|
+
name: string;
|
|
902
|
+
image?: string | null | undefined;
|
|
903
|
+
};
|
|
904
|
+
};
|
|
905
|
+
}>>[];
|
|
906
|
+
}, (inputContext: _$better_call0.MiddlewareInputContext<{
|
|
907
|
+
use: _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
783
908
|
session: {
|
|
784
909
|
session: Record<string, any> & {
|
|
785
910
|
id: string;
|
|
@@ -801,26 +926,26 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
801
926
|
image?: string | null | undefined;
|
|
802
927
|
};
|
|
803
928
|
};
|
|
804
|
-
}
|
|
929
|
+
}>>[];
|
|
805
930
|
}>) => Promise<{
|
|
806
931
|
session: StripeCtxSession;
|
|
807
|
-
}
|
|
932
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<{
|
|
808
933
|
referenceId: string;
|
|
809
|
-
}
|
|
934
|
+
}>> | _$better_call0.Middleware<_$better_call0.MiddlewareOptions, (inputContext: _$better_call0.MiddlewareInputContext<_$better_call0.MiddlewareOptions>) => Promise<void>>)[];
|
|
810
935
|
}, {
|
|
811
936
|
url: string;
|
|
812
937
|
redirect: boolean;
|
|
813
938
|
}>;
|
|
814
939
|
} : {});
|
|
815
|
-
init(ctx:
|
|
940
|
+
init(ctx: _$better_auth0.AuthContext): {
|
|
816
941
|
options: {
|
|
817
942
|
databaseHooks: {
|
|
818
943
|
user: {
|
|
819
944
|
create: {
|
|
820
|
-
after(user: User & WithStripeCustomerId, ctx:
|
|
945
|
+
after(user: User & WithStripeCustomerId, ctx: _$better_auth0.GenericEndpointContext | null): Promise<void>;
|
|
821
946
|
};
|
|
822
947
|
update: {
|
|
823
|
-
after(user: User & WithStripeCustomerId, ctx:
|
|
948
|
+
after(user: User & WithStripeCustomerId, ctx: _$better_auth0.GenericEndpointContext | null): Promise<void>;
|
|
824
949
|
};
|
|
825
950
|
};
|
|
826
951
|
};
|
|
@@ -921,29 +1046,29 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
921
1046
|
} : {});
|
|
922
1047
|
options: NoInfer<O>;
|
|
923
1048
|
$ERROR_CODES: {
|
|
924
|
-
UNAUTHORIZED:
|
|
925
|
-
INVALID_REQUEST_BODY:
|
|
926
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
927
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
928
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
929
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
930
|
-
CUSTOMER_NOT_FOUND:
|
|
931
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
932
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
933
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
934
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
935
|
-
STRIPE_WEBHOOK_ERROR:
|
|
936
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
937
|
-
FAILED_TO_FETCH_PLANS:
|
|
938
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
939
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
940
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
941
|
-
SUBSCRIPTION_NOT_PENDING_CHANGE:
|
|
942
|
-
ORGANIZATION_NOT_FOUND:
|
|
943
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
944
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
945
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
946
|
-
ORGANIZATION_REFERENCE_ID_REQUIRED:
|
|
1049
|
+
UNAUTHORIZED: _$better_auth0.RawError<"UNAUTHORIZED">;
|
|
1050
|
+
INVALID_REQUEST_BODY: _$better_auth0.RawError<"INVALID_REQUEST_BODY">;
|
|
1051
|
+
SUBSCRIPTION_NOT_FOUND: _$better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
|
|
1052
|
+
SUBSCRIPTION_PLAN_NOT_FOUND: _$better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
|
|
1053
|
+
ALREADY_SUBSCRIBED_PLAN: _$better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
|
|
1054
|
+
REFERENCE_ID_NOT_ALLOWED: _$better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
|
|
1055
|
+
CUSTOMER_NOT_FOUND: _$better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
|
|
1056
|
+
UNABLE_TO_CREATE_CUSTOMER: _$better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
|
|
1057
|
+
UNABLE_TO_CREATE_BILLING_PORTAL: _$better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
|
|
1058
|
+
STRIPE_SIGNATURE_NOT_FOUND: _$better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
|
|
1059
|
+
STRIPE_WEBHOOK_SECRET_NOT_FOUND: _$better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
|
|
1060
|
+
STRIPE_WEBHOOK_ERROR: _$better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
|
|
1061
|
+
FAILED_TO_CONSTRUCT_STRIPE_EVENT: _$better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
|
|
1062
|
+
FAILED_TO_FETCH_PLANS: _$better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
|
|
1063
|
+
EMAIL_VERIFICATION_REQUIRED: _$better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
|
|
1064
|
+
SUBSCRIPTION_NOT_ACTIVE: _$better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
|
|
1065
|
+
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: _$better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
|
|
1066
|
+
SUBSCRIPTION_NOT_PENDING_CHANGE: _$better_auth0.RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
|
|
1067
|
+
ORGANIZATION_NOT_FOUND: _$better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
|
|
1068
|
+
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: _$better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
|
|
1069
|
+
AUTHORIZE_REFERENCE_REQUIRED: _$better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
|
|
1070
|
+
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: _$better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
|
|
1071
|
+
ORGANIZATION_REFERENCE_ID_REQUIRED: _$better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
|
|
947
1072
|
};
|
|
948
1073
|
};
|
|
949
1074
|
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 {
|
|
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-Dkb8cZck.mjs";
|
|
2
|
+
export { AuthorizeReferenceAction, CheckoutSessionLineItem, CheckoutSessionLocale, CustomerType, StripeCtxSession, StripeOptions, StripePlan, StripePlugin, Subscription, SubscriptionOptions, WithActiveOrganizationId, 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-CqxyLDzE.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 =
|
|
10
|
+
const UNSAFE_METADATA_KEYS = new Set([
|
|
11
11
|
"__proto__",
|
|
12
12
|
"constructor",
|
|
13
13
|
"prototype"
|
|
@@ -783,8 +783,7 @@ const upgradeSubscription = (options) => {
|
|
|
783
783
|
const stripeSubscriptionPriceId = planItem?.price.id;
|
|
784
784
|
const incompleteSubscription = subscriptions.find((sub) => sub.status === "incomplete");
|
|
785
785
|
const priceId = ctx.body.annual ? plan.annualDiscountPriceId : plan.priceId;
|
|
786
|
-
const
|
|
787
|
-
const resolvedPrice = await resolveStripePrice(client, priceId, lookupKey);
|
|
786
|
+
const resolvedPrice = await resolveStripePrice(client, priceId, ctx.body.annual ? plan.annualDiscountLookupKey : plan.lookupKey);
|
|
788
787
|
const priceIdToUse = resolvedPrice?.id ?? priceId;
|
|
789
788
|
if (!priceIdToUse) throw ctx.error("BAD_REQUEST", { message: "Price ID not found for the selected plan" });
|
|
790
789
|
const isMetered = isMeteredPrice(resolvedPrice);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/stripe",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.28",
|
|
4
4
|
"description": "Stripe plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,17 +55,17 @@
|
|
|
55
55
|
"zod": "^4.3.6"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"better-call": "1.
|
|
58
|
+
"better-call": "1.4.0",
|
|
59
59
|
"stripe": "^22.0.1",
|
|
60
|
-
"tsdown": "0.
|
|
61
|
-
"@better-auth/core": "1.6.
|
|
62
|
-
"better-auth": "1.6.
|
|
60
|
+
"tsdown": "0.21.10",
|
|
61
|
+
"@better-auth/core": "1.6.28",
|
|
62
|
+
"better-auth": "1.6.28"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"better-call": "1.
|
|
65
|
+
"better-call": "1.4.0",
|
|
66
66
|
"stripe": "^18 || ^19 || ^20 || ^21 || ^22",
|
|
67
|
-
"@better-auth/core": "^1.6.
|
|
68
|
-
"better-auth": "^1.6.
|
|
67
|
+
"@better-auth/core": "^1.6.28",
|
|
68
|
+
"better-auth": "^1.6.28"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown",
|