@better-auth/stripe 1.5.0-beta.2 → 1.5.0-beta.3
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +15 -13
- package/LICENSE.md +15 -12
- package/dist/client.d.mts +105 -1
- package/dist/client.mjs +1 -1
- package/dist/error-codes-Bkj5yJMT.mjs +29 -0
- package/dist/{index-SbT5j9k6.d.mts → index-BnHmwMru.d.mts} +269 -154
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +449 -194
- package/package.json +6 -6
- package/src/error-codes.ts +16 -0
- package/src/hooks.ts +98 -71
- package/src/index.ts +142 -45
- package/src/middleware.ts +89 -42
- package/src/routes.ts +502 -224
- package/src/schema.ts +18 -0
- package/src/types.ts +75 -19
- package/src/utils.ts +11 -0
- package/test/stripe-organization.test.ts +1993 -0
- package/{src → test}/stripe.test.ts +821 -18
- package/dist/error-codes-qqooUh6R.mjs +0 -16
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/stripe@1.5.0-beta.
|
|
2
|
+
> @better-auth/stripe@1.5.0-beta.3 build /home/runner/work/better-auth/better-auth/packages/stripe
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.17.2[22m powered by rolldown [2mv1.0.0-beta.53[22m
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
[34mℹ[39m entry: [34msrc/index.ts, src/client.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[1mclient.mjs[22m [2m 0.39 kB[22m [2m│ gzip:
|
|
12
|
-
[34mℹ[39m [2mdist/[22merror-codes-
|
|
13
|
-
[34mℹ[39m [2mdist/[22m[32m[1mclient.d.mts[22m[39m [2m
|
|
14
|
-
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 0.21 kB[22m [2m│ gzip:
|
|
15
|
-
[34mℹ[39m [2mdist/[22m[32mindex-
|
|
16
|
-
[34mℹ[39m 6 files, total:
|
|
17
|
-
[32m✔[39m Build complete in [
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m55.90 kB[22m [2m│ gzip: 10.02 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mclient.mjs[22m [2m 0.39 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22merror-codes-Bkj5yJMT.mjs [2m 1.61 kB[22m [2m│ gzip: 0.75 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22m[32m[1mclient.d.mts[22m[39m [2m 6.71 kB[22m [2m│ gzip: 1.32 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 0.21 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
15
|
+
[34mℹ[39m [2mdist/[22m[32mindex-BnHmwMru.d.mts[39m [2m30.07 kB[22m [2m│ gzip: 5.20 kB[22m
|
|
16
|
+
[34mℹ[39m 6 files, total: 94.89 kB
|
|
17
|
+
[32m✔[39m Build complete in [32m22202ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# [**@better-auth/stripe**](https://github.com/better-auth/stripe)
|
|
2
2
|
|
|
3
3
|
## 1.3.4
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
7
|
+
* [`ac6baba`](https://github.com/better-auth/better-auth/commit/ac6baba): chore: fix typo on `freeTrial`
|
|
8
|
+
|
|
9
|
+
* [`c2fb1aa`](https://github.com/better-auth/better-auth/commit/c2fb1aa): Fix duplicate trials when switching plans
|
|
10
|
+
|
|
11
|
+
* [`2bd2fa9`](https://github.com/better-auth/better-auth/commit/2bd2fa9): Added support for listing organization members with pagination, sorting, and filtering, and improved client inference for additional organization fields. Also fixed date handling in rate limits and tokens, improved Notion OAuth user extraction, and ensured session is always set in context.
|
|
10
12
|
|
|
11
13
|
Organization
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
* Added listMembers API with pagination, sorting, and filtering.
|
|
16
|
+
* Added membersLimit param to getFullOrganization.
|
|
17
|
+
* Improved client inference for additional fields in organization schemas.
|
|
18
|
+
* Bug Fixes
|
|
19
|
+
* Fixed date handling by casting DB values to Date objects before using date methods.
|
|
20
|
+
* Fixed Notion OAuth to extract user info correctly.
|
|
21
|
+
* Ensured session is set in context when reading from cookie cache
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
* Updated dependencies \[[`2bd2fa9`](https://github.com/better-auth/better-auth/commit/2bd2fa9)]
|
|
24
|
+
* better-auth\@1.3.4
|
package/LICENSE.md
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
Copyright (c) 2024 - present, Bereket Engida
|
|
3
3
|
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
-
and associated documentation files (the
|
|
6
|
-
including without limitation the rights to
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
6
|
+
the Software without restriction, including without limitation the rights to
|
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
subject to the following conditions:
|
|
9
10
|
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
|
11
|
-
substantial portions of the Software.
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
12
13
|
|
|
13
|
-
THE SOFTWARE IS PROVIDED
|
|
14
|
-
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
DEALINGS IN THE SOFTWARE.
|
package/dist/client.d.mts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { n as stripe } from "./index-
|
|
1
|
+
import { n as stripe } from "./index-BnHmwMru.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/error-codes.d.ts
|
|
4
4
|
declare const STRIPE_ERROR_CODES: {
|
|
5
|
+
readonly UNAUTHORIZED: {
|
|
6
|
+
code: "UNAUTHORIZED";
|
|
7
|
+
message: "Unauthorized access";
|
|
8
|
+
};
|
|
9
|
+
readonly INVALID_REQUEST_BODY: {
|
|
10
|
+
code: "INVALID_REQUEST_BODY";
|
|
11
|
+
message: "Invalid request body";
|
|
12
|
+
};
|
|
5
13
|
readonly SUBSCRIPTION_NOT_FOUND: {
|
|
6
14
|
code: "SUBSCRIPTION_NOT_FOUND";
|
|
7
15
|
message: "Subscription not found";
|
|
@@ -14,10 +22,38 @@ declare const STRIPE_ERROR_CODES: {
|
|
|
14
22
|
code: "ALREADY_SUBSCRIBED_PLAN";
|
|
15
23
|
message: "You're already subscribed to this plan";
|
|
16
24
|
};
|
|
25
|
+
readonly REFERENCE_ID_NOT_ALLOWED: {
|
|
26
|
+
code: "REFERENCE_ID_NOT_ALLOWED";
|
|
27
|
+
message: "Reference id is not allowed";
|
|
28
|
+
};
|
|
29
|
+
readonly CUSTOMER_NOT_FOUND: {
|
|
30
|
+
code: "CUSTOMER_NOT_FOUND";
|
|
31
|
+
message: "Stripe customer not found for this user";
|
|
32
|
+
};
|
|
17
33
|
readonly UNABLE_TO_CREATE_CUSTOMER: {
|
|
18
34
|
code: "UNABLE_TO_CREATE_CUSTOMER";
|
|
19
35
|
message: "Unable to create customer";
|
|
20
36
|
};
|
|
37
|
+
readonly UNABLE_TO_CREATE_BILLING_PORTAL: {
|
|
38
|
+
code: "UNABLE_TO_CREATE_BILLING_PORTAL";
|
|
39
|
+
message: "Unable to create billing portal session";
|
|
40
|
+
};
|
|
41
|
+
readonly STRIPE_SIGNATURE_NOT_FOUND: {
|
|
42
|
+
code: "STRIPE_SIGNATURE_NOT_FOUND";
|
|
43
|
+
message: "Stripe signature not found";
|
|
44
|
+
};
|
|
45
|
+
readonly STRIPE_WEBHOOK_SECRET_NOT_FOUND: {
|
|
46
|
+
code: "STRIPE_WEBHOOK_SECRET_NOT_FOUND";
|
|
47
|
+
message: "Stripe webhook secret not found";
|
|
48
|
+
};
|
|
49
|
+
readonly STRIPE_WEBHOOK_ERROR: {
|
|
50
|
+
code: "STRIPE_WEBHOOK_ERROR";
|
|
51
|
+
message: "Stripe webhook error";
|
|
52
|
+
};
|
|
53
|
+
readonly FAILED_TO_CONSTRUCT_STRIPE_EVENT: {
|
|
54
|
+
code: "FAILED_TO_CONSTRUCT_STRIPE_EVENT";
|
|
55
|
+
message: "Failed to construct Stripe event";
|
|
56
|
+
};
|
|
21
57
|
readonly FAILED_TO_FETCH_PLANS: {
|
|
22
58
|
code: "FAILED_TO_FETCH_PLANS";
|
|
23
59
|
message: "Failed to fetch plans";
|
|
@@ -34,6 +70,22 @@ declare const STRIPE_ERROR_CODES: {
|
|
|
34
70
|
code: "SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION";
|
|
35
71
|
message: "Subscription is not scheduled for cancellation";
|
|
36
72
|
};
|
|
73
|
+
readonly ORGANIZATION_NOT_FOUND: {
|
|
74
|
+
code: "ORGANIZATION_NOT_FOUND";
|
|
75
|
+
message: "Organization not found";
|
|
76
|
+
};
|
|
77
|
+
readonly ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: {
|
|
78
|
+
code: "ORGANIZATION_SUBSCRIPTION_NOT_ENABLED";
|
|
79
|
+
message: "Organization subscription is not enabled";
|
|
80
|
+
};
|
|
81
|
+
readonly ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: {
|
|
82
|
+
code: "ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION";
|
|
83
|
+
message: "Cannot delete organization with active subscription";
|
|
84
|
+
};
|
|
85
|
+
readonly ORGANIZATION_REFERENCE_ID_REQUIRED: {
|
|
86
|
+
code: "ORGANIZATION_REFERENCE_ID_REQUIRED";
|
|
87
|
+
message: "Reference ID is required. Provide referenceId or set activeOrganizationId in session";
|
|
88
|
+
};
|
|
37
89
|
};
|
|
38
90
|
//#endregion
|
|
39
91
|
//#region src/client.d.ts
|
|
@@ -57,6 +109,14 @@ declare const stripeClient: <O extends {
|
|
|
57
109
|
"/subscription/restore": "POST";
|
|
58
110
|
};
|
|
59
111
|
$ERROR_CODES: {
|
|
112
|
+
readonly UNAUTHORIZED: {
|
|
113
|
+
code: "UNAUTHORIZED";
|
|
114
|
+
message: "Unauthorized access";
|
|
115
|
+
};
|
|
116
|
+
readonly INVALID_REQUEST_BODY: {
|
|
117
|
+
code: "INVALID_REQUEST_BODY";
|
|
118
|
+
message: "Invalid request body";
|
|
119
|
+
};
|
|
60
120
|
readonly SUBSCRIPTION_NOT_FOUND: {
|
|
61
121
|
code: "SUBSCRIPTION_NOT_FOUND";
|
|
62
122
|
message: "Subscription not found";
|
|
@@ -69,10 +129,38 @@ declare const stripeClient: <O extends {
|
|
|
69
129
|
code: "ALREADY_SUBSCRIBED_PLAN";
|
|
70
130
|
message: "You're already subscribed to this plan";
|
|
71
131
|
};
|
|
132
|
+
readonly REFERENCE_ID_NOT_ALLOWED: {
|
|
133
|
+
code: "REFERENCE_ID_NOT_ALLOWED";
|
|
134
|
+
message: "Reference id is not allowed";
|
|
135
|
+
};
|
|
136
|
+
readonly CUSTOMER_NOT_FOUND: {
|
|
137
|
+
code: "CUSTOMER_NOT_FOUND";
|
|
138
|
+
message: "Stripe customer not found for this user";
|
|
139
|
+
};
|
|
72
140
|
readonly UNABLE_TO_CREATE_CUSTOMER: {
|
|
73
141
|
code: "UNABLE_TO_CREATE_CUSTOMER";
|
|
74
142
|
message: "Unable to create customer";
|
|
75
143
|
};
|
|
144
|
+
readonly UNABLE_TO_CREATE_BILLING_PORTAL: {
|
|
145
|
+
code: "UNABLE_TO_CREATE_BILLING_PORTAL";
|
|
146
|
+
message: "Unable to create billing portal session";
|
|
147
|
+
};
|
|
148
|
+
readonly STRIPE_SIGNATURE_NOT_FOUND: {
|
|
149
|
+
code: "STRIPE_SIGNATURE_NOT_FOUND";
|
|
150
|
+
message: "Stripe signature not found";
|
|
151
|
+
};
|
|
152
|
+
readonly STRIPE_WEBHOOK_SECRET_NOT_FOUND: {
|
|
153
|
+
code: "STRIPE_WEBHOOK_SECRET_NOT_FOUND";
|
|
154
|
+
message: "Stripe webhook secret not found";
|
|
155
|
+
};
|
|
156
|
+
readonly STRIPE_WEBHOOK_ERROR: {
|
|
157
|
+
code: "STRIPE_WEBHOOK_ERROR";
|
|
158
|
+
message: "Stripe webhook error";
|
|
159
|
+
};
|
|
160
|
+
readonly FAILED_TO_CONSTRUCT_STRIPE_EVENT: {
|
|
161
|
+
code: "FAILED_TO_CONSTRUCT_STRIPE_EVENT";
|
|
162
|
+
message: "Failed to construct Stripe event";
|
|
163
|
+
};
|
|
76
164
|
readonly FAILED_TO_FETCH_PLANS: {
|
|
77
165
|
code: "FAILED_TO_FETCH_PLANS";
|
|
78
166
|
message: "Failed to fetch plans";
|
|
@@ -89,6 +177,22 @@ declare const stripeClient: <O extends {
|
|
|
89
177
|
code: "SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION";
|
|
90
178
|
message: "Subscription is not scheduled for cancellation";
|
|
91
179
|
};
|
|
180
|
+
readonly ORGANIZATION_NOT_FOUND: {
|
|
181
|
+
code: "ORGANIZATION_NOT_FOUND";
|
|
182
|
+
message: "Organization not found";
|
|
183
|
+
};
|
|
184
|
+
readonly ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: {
|
|
185
|
+
code: "ORGANIZATION_SUBSCRIPTION_NOT_ENABLED";
|
|
186
|
+
message: "Organization subscription is not enabled";
|
|
187
|
+
};
|
|
188
|
+
readonly ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: {
|
|
189
|
+
code: "ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION";
|
|
190
|
+
message: "Cannot delete organization with active subscription";
|
|
191
|
+
};
|
|
192
|
+
readonly ORGANIZATION_REFERENCE_ID_REQUIRED: {
|
|
193
|
+
code: "ORGANIZATION_REFERENCE_ID_REQUIRED";
|
|
194
|
+
message: "Reference ID is required. Provide referenceId or set activeOrganizationId in session";
|
|
195
|
+
};
|
|
92
196
|
};
|
|
93
197
|
};
|
|
94
198
|
//#endregion
|
package/dist/client.mjs
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineErrorCodes } from "@better-auth/core/utils";
|
|
2
|
+
|
|
3
|
+
//#region src/error-codes.ts
|
|
4
|
+
const STRIPE_ERROR_CODES = defineErrorCodes({
|
|
5
|
+
UNAUTHORIZED: "Unauthorized access",
|
|
6
|
+
INVALID_REQUEST_BODY: "Invalid request body",
|
|
7
|
+
SUBSCRIPTION_NOT_FOUND: "Subscription not found",
|
|
8
|
+
SUBSCRIPTION_PLAN_NOT_FOUND: "Subscription plan not found",
|
|
9
|
+
ALREADY_SUBSCRIBED_PLAN: "You're already subscribed to this plan",
|
|
10
|
+
REFERENCE_ID_NOT_ALLOWED: "Reference id is not allowed",
|
|
11
|
+
CUSTOMER_NOT_FOUND: "Stripe customer not found for this user",
|
|
12
|
+
UNABLE_TO_CREATE_CUSTOMER: "Unable to create customer",
|
|
13
|
+
UNABLE_TO_CREATE_BILLING_PORTAL: "Unable to create billing portal session",
|
|
14
|
+
STRIPE_SIGNATURE_NOT_FOUND: "Stripe signature not found",
|
|
15
|
+
STRIPE_WEBHOOK_SECRET_NOT_FOUND: "Stripe webhook secret not found",
|
|
16
|
+
STRIPE_WEBHOOK_ERROR: "Stripe webhook error",
|
|
17
|
+
FAILED_TO_CONSTRUCT_STRIPE_EVENT: "Failed to construct Stripe event",
|
|
18
|
+
FAILED_TO_FETCH_PLANS: "Failed to fetch plans",
|
|
19
|
+
EMAIL_VERIFICATION_REQUIRED: "Email verification is required before you can subscribe to a plan",
|
|
20
|
+
SUBSCRIPTION_NOT_ACTIVE: "Subscription is not active",
|
|
21
|
+
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: "Subscription is not scheduled for cancellation",
|
|
22
|
+
ORGANIZATION_NOT_FOUND: "Organization not found",
|
|
23
|
+
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: "Organization subscription is not enabled",
|
|
24
|
+
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: "Cannot delete organization with active subscription",
|
|
25
|
+
ORGANIZATION_REFERENCE_ID_REQUIRED: "Reference ID is required. Provide referenceId or set activeOrganizationId in session"
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { STRIPE_ERROR_CODES as t };
|