@better-auth/stripe 1.3.4 → 1.3.5-beta.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/.turbo/turbo-build.log +4 -4
- package/dist/index.cjs +8 -20
- package/dist/index.d.cts +0 -8
- package/dist/index.d.mts +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.mjs +8 -20
- package/package.json +7 -4
- package/src/index.ts +11 -22
- package/src/types.ts +0 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/stripe@1.3.
|
|
2
|
+
> @better-auth/stripe@1.3.5-beta.2 build /home/runner/work/better-auth/better-auth/packages/stripe
|
|
3
3
|
> unbuild
|
|
4
4
|
|
|
5
5
|
[info] Automatically detected entries: src/index, src/client [esm] [cjs] [dts]
|
|
6
6
|
[info] Building stripe
|
|
7
7
|
[success] Build succeeded for stripe
|
|
8
|
-
[log] dist/index.cjs (total size: 41.
|
|
8
|
+
[log] dist/index.cjs (total size: 41.5 kB, chunk size: 41.5 kB, exports: stripe)
|
|
9
9
|
|
|
10
10
|
[log] dist/client.cjs (total size: 224 B, chunk size: 224 B, exports: stripeClient)
|
|
11
11
|
|
|
12
|
-
[log] dist/index.mjs (total size: 40.
|
|
12
|
+
[log] dist/index.mjs (total size: 40.7 kB, chunk size: 40.7 kB, exports: stripe)
|
|
13
13
|
|
|
14
14
|
[log] dist/client.mjs (total size: 197 B, chunk size: 197 B, exports: stripeClient)
|
|
15
15
|
|
|
16
|
-
Σ Total dist size (byte size):
|
|
16
|
+
Σ Total dist size (byte size): 204 kB
|
|
17
17
|
[log]
|
package/dist/index.cjs
CHANGED
|
@@ -432,13 +432,13 @@ const stripe = (options) => {
|
|
|
432
432
|
* Cancel URL
|
|
433
433
|
*/
|
|
434
434
|
cancelUrl: z__namespace.string().meta({
|
|
435
|
-
description: '
|
|
435
|
+
description: 'If set, checkout shows a back button and customers will be directed here if they cancel payment. Eg: "https://example.com/pricing"'
|
|
436
436
|
}).default("/"),
|
|
437
437
|
/**
|
|
438
438
|
* Return URL
|
|
439
439
|
*/
|
|
440
440
|
returnUrl: z__namespace.string().meta({
|
|
441
|
-
description: '
|
|
441
|
+
description: 'URL to take customers to when they click on the billing portal\u2019s link to return to your website. Eg: "https://example.com/dashboard"'
|
|
442
442
|
}).optional(),
|
|
443
443
|
/**
|
|
444
444
|
* Disable Redirect
|
|
@@ -535,7 +535,7 @@ const stripe = (options) => {
|
|
|
535
535
|
)
|
|
536
536
|
);
|
|
537
537
|
const activeSubscription = activeSubscriptions.find(
|
|
538
|
-
(sub) => subscriptionToUpdate?.stripeSubscriptionId ? sub.id === subscriptionToUpdate?.stripeSubscriptionId : true
|
|
538
|
+
(sub) => subscriptionToUpdate?.stripeSubscriptionId || ctx.body.subscriptionId ? sub.id === subscriptionToUpdate?.stripeSubscriptionId || sub.id === ctx.body.subscriptionId : true
|
|
539
539
|
);
|
|
540
540
|
const subscriptions = subscriptionToUpdate ? [subscriptionToUpdate] : await ctx.context.adapter.findMany({
|
|
541
541
|
model: "subscription",
|
|
@@ -783,7 +783,7 @@ const stripe = (options) => {
|
|
|
783
783
|
description: "The id of the subscription to cancel. Eg: 'sub_123'"
|
|
784
784
|
}).optional(),
|
|
785
785
|
returnUrl: z__namespace.string().meta({
|
|
786
|
-
description:
|
|
786
|
+
description: 'URL to take customers to when they click on the billing portal\u2019s link to return to your website. Eg: "https://example.com/dashboard"'
|
|
787
787
|
})
|
|
788
788
|
}),
|
|
789
789
|
use: [
|
|
@@ -1208,26 +1208,14 @@ const stripe = (options) => {
|
|
|
1208
1208
|
userId: user.id
|
|
1209
1209
|
}
|
|
1210
1210
|
});
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
stripeCustomerId: stripeCustomer.id
|
|
1216
|
-
},
|
|
1217
|
-
where: [
|
|
1218
|
-
{
|
|
1219
|
-
field: "id",
|
|
1220
|
-
value: user.id
|
|
1221
|
-
}
|
|
1222
|
-
]
|
|
1223
|
-
}
|
|
1224
|
-
);
|
|
1225
|
-
if (!customer) {
|
|
1211
|
+
const updatedUser = await ctx2.context.internalAdapter.updateUser(user.id, {
|
|
1212
|
+
stripeCustomerId: stripeCustomer.id
|
|
1213
|
+
});
|
|
1214
|
+
if (!updatedUser) {
|
|
1226
1215
|
betterAuth.logger.error("#BETTER_AUTH: Failed to create customer");
|
|
1227
1216
|
} else {
|
|
1228
1217
|
await options.onCustomerCreate?.(
|
|
1229
1218
|
{
|
|
1230
|
-
customer,
|
|
1231
1219
|
stripeCustomer,
|
|
1232
1220
|
user
|
|
1233
1221
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -222,7 +222,6 @@ interface StripeOptions {
|
|
|
222
222
|
* @returns
|
|
223
223
|
*/
|
|
224
224
|
onCustomerCreate?: (data: {
|
|
225
|
-
customer: Customer;
|
|
226
225
|
stripeCustomer: Stripe.Customer;
|
|
227
226
|
user: User;
|
|
228
227
|
}, ctx: GenericEndpointContext) => Promise<void>;
|
|
@@ -344,13 +343,6 @@ interface StripeOptions {
|
|
|
344
343
|
*/
|
|
345
344
|
schema?: InferOptionSchema<typeof subscriptions & typeof user>;
|
|
346
345
|
}
|
|
347
|
-
interface Customer {
|
|
348
|
-
id: string;
|
|
349
|
-
stripeCustomerId?: string;
|
|
350
|
-
userId: string;
|
|
351
|
-
createdAt: Date;
|
|
352
|
-
updatedAt: Date;
|
|
353
|
-
}
|
|
354
346
|
|
|
355
347
|
declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
356
348
|
id: "stripe";
|
package/dist/index.d.mts
CHANGED
|
@@ -222,7 +222,6 @@ interface StripeOptions {
|
|
|
222
222
|
* @returns
|
|
223
223
|
*/
|
|
224
224
|
onCustomerCreate?: (data: {
|
|
225
|
-
customer: Customer;
|
|
226
225
|
stripeCustomer: Stripe.Customer;
|
|
227
226
|
user: User;
|
|
228
227
|
}, ctx: GenericEndpointContext) => Promise<void>;
|
|
@@ -344,13 +343,6 @@ interface StripeOptions {
|
|
|
344
343
|
*/
|
|
345
344
|
schema?: InferOptionSchema<typeof subscriptions & typeof user>;
|
|
346
345
|
}
|
|
347
|
-
interface Customer {
|
|
348
|
-
id: string;
|
|
349
|
-
stripeCustomerId?: string;
|
|
350
|
-
userId: string;
|
|
351
|
-
createdAt: Date;
|
|
352
|
-
updatedAt: Date;
|
|
353
|
-
}
|
|
354
346
|
|
|
355
347
|
declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
356
348
|
id: "stripe";
|
package/dist/index.d.ts
CHANGED
|
@@ -222,7 +222,6 @@ interface StripeOptions {
|
|
|
222
222
|
* @returns
|
|
223
223
|
*/
|
|
224
224
|
onCustomerCreate?: (data: {
|
|
225
|
-
customer: Customer;
|
|
226
225
|
stripeCustomer: Stripe.Customer;
|
|
227
226
|
user: User;
|
|
228
227
|
}, ctx: GenericEndpointContext) => Promise<void>;
|
|
@@ -344,13 +343,6 @@ interface StripeOptions {
|
|
|
344
343
|
*/
|
|
345
344
|
schema?: InferOptionSchema<typeof subscriptions & typeof user>;
|
|
346
345
|
}
|
|
347
|
-
interface Customer {
|
|
348
|
-
id: string;
|
|
349
|
-
stripeCustomerId?: string;
|
|
350
|
-
userId: string;
|
|
351
|
-
createdAt: Date;
|
|
352
|
-
updatedAt: Date;
|
|
353
|
-
}
|
|
354
346
|
|
|
355
347
|
declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
356
348
|
id: "stripe";
|
package/dist/index.mjs
CHANGED
|
@@ -416,13 +416,13 @@ const stripe = (options) => {
|
|
|
416
416
|
* Cancel URL
|
|
417
417
|
*/
|
|
418
418
|
cancelUrl: z.string().meta({
|
|
419
|
-
description: '
|
|
419
|
+
description: 'If set, checkout shows a back button and customers will be directed here if they cancel payment. Eg: "https://example.com/pricing"'
|
|
420
420
|
}).default("/"),
|
|
421
421
|
/**
|
|
422
422
|
* Return URL
|
|
423
423
|
*/
|
|
424
424
|
returnUrl: z.string().meta({
|
|
425
|
-
description: '
|
|
425
|
+
description: 'URL to take customers to when they click on the billing portal\u2019s link to return to your website. Eg: "https://example.com/dashboard"'
|
|
426
426
|
}).optional(),
|
|
427
427
|
/**
|
|
428
428
|
* Disable Redirect
|
|
@@ -519,7 +519,7 @@ const stripe = (options) => {
|
|
|
519
519
|
)
|
|
520
520
|
);
|
|
521
521
|
const activeSubscription = activeSubscriptions.find(
|
|
522
|
-
(sub) => subscriptionToUpdate?.stripeSubscriptionId ? sub.id === subscriptionToUpdate?.stripeSubscriptionId : true
|
|
522
|
+
(sub) => subscriptionToUpdate?.stripeSubscriptionId || ctx.body.subscriptionId ? sub.id === subscriptionToUpdate?.stripeSubscriptionId || sub.id === ctx.body.subscriptionId : true
|
|
523
523
|
);
|
|
524
524
|
const subscriptions = subscriptionToUpdate ? [subscriptionToUpdate] : await ctx.context.adapter.findMany({
|
|
525
525
|
model: "subscription",
|
|
@@ -767,7 +767,7 @@ const stripe = (options) => {
|
|
|
767
767
|
description: "The id of the subscription to cancel. Eg: 'sub_123'"
|
|
768
768
|
}).optional(),
|
|
769
769
|
returnUrl: z.string().meta({
|
|
770
|
-
description:
|
|
770
|
+
description: 'URL to take customers to when they click on the billing portal\u2019s link to return to your website. Eg: "https://example.com/dashboard"'
|
|
771
771
|
})
|
|
772
772
|
}),
|
|
773
773
|
use: [
|
|
@@ -1192,26 +1192,14 @@ const stripe = (options) => {
|
|
|
1192
1192
|
userId: user.id
|
|
1193
1193
|
}
|
|
1194
1194
|
});
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
stripeCustomerId: stripeCustomer.id
|
|
1200
|
-
},
|
|
1201
|
-
where: [
|
|
1202
|
-
{
|
|
1203
|
-
field: "id",
|
|
1204
|
-
value: user.id
|
|
1205
|
-
}
|
|
1206
|
-
]
|
|
1207
|
-
}
|
|
1208
|
-
);
|
|
1209
|
-
if (!customer) {
|
|
1195
|
+
const updatedUser = await ctx2.context.internalAdapter.updateUser(user.id, {
|
|
1196
|
+
stripeCustomerId: stripeCustomer.id
|
|
1197
|
+
});
|
|
1198
|
+
if (!updatedUser) {
|
|
1210
1199
|
logger.error("#BETTER_AUTH: Failed to create customer");
|
|
1211
1200
|
} else {
|
|
1212
1201
|
await options.onCustomerCreate?.(
|
|
1213
1202
|
{
|
|
1214
|
-
customer,
|
|
1215
1203
|
stripeCustomer,
|
|
1216
1204
|
user
|
|
1217
1205
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/stripe",
|
|
3
3
|
"author": "Bereket Engida",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.5-beta.2",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -37,15 +37,18 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"
|
|
41
|
-
|
|
40
|
+
"better-auth": "^1.3.5-beta.2"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@types/better-sqlite3": "^7.6.12",
|
|
45
47
|
"better-call": "^1.0.12",
|
|
46
48
|
"better-sqlite3": "^11.6.0",
|
|
47
49
|
"stripe": "^18.0.0",
|
|
48
|
-
"vitest": "^1.6.0"
|
|
50
|
+
"vitest": "^1.6.0",
|
|
51
|
+
"zod": "^4.0.0"
|
|
49
52
|
},
|
|
50
53
|
"scripts": {
|
|
51
54
|
"test": "vitest",
|
package/src/index.ts
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
onSubscriptionUpdated,
|
|
19
19
|
} from "./hooks";
|
|
20
20
|
import type {
|
|
21
|
-
Customer,
|
|
22
21
|
InputSubscription,
|
|
23
22
|
StripeOptions,
|
|
24
23
|
StripePlan,
|
|
@@ -199,7 +198,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
199
198
|
.string()
|
|
200
199
|
.meta({
|
|
201
200
|
description:
|
|
202
|
-
'
|
|
201
|
+
'If set, checkout shows a back button and customers will be directed here if they cancel payment. Eg: "https://example.com/pricing"',
|
|
203
202
|
})
|
|
204
203
|
.default("/"),
|
|
205
204
|
/**
|
|
@@ -209,7 +208,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
209
208
|
.string()
|
|
210
209
|
.meta({
|
|
211
210
|
description:
|
|
212
|
-
'
|
|
211
|
+
'URL to take customers to when they click on the billing portal’s link to return to your website. Eg: "https://example.com/dashboard"',
|
|
213
212
|
})
|
|
214
213
|
.optional(),
|
|
215
214
|
/**
|
|
@@ -329,8 +328,9 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
329
328
|
),
|
|
330
329
|
);
|
|
331
330
|
const activeSubscription = activeSubscriptions.find((sub) =>
|
|
332
|
-
subscriptionToUpdate?.stripeSubscriptionId
|
|
333
|
-
? sub.id === subscriptionToUpdate?.stripeSubscriptionId
|
|
331
|
+
subscriptionToUpdate?.stripeSubscriptionId || ctx.body.subscriptionId
|
|
332
|
+
? sub.id === subscriptionToUpdate?.stripeSubscriptionId ||
|
|
333
|
+
sub.id === ctx.body.subscriptionId
|
|
334
334
|
: true,
|
|
335
335
|
);
|
|
336
336
|
const subscriptions = subscriptionToUpdate
|
|
@@ -625,7 +625,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
625
625
|
.optional(),
|
|
626
626
|
returnUrl: z.string().meta({
|
|
627
627
|
description:
|
|
628
|
-
|
|
628
|
+
'URL to take customers to when they click on the billing portal’s link to return to your website. Eg: "https://example.com/dashboard"',
|
|
629
629
|
}),
|
|
630
630
|
}),
|
|
631
631
|
use: [
|
|
@@ -1123,26 +1123,15 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
1123
1123
|
userId: user.id,
|
|
1124
1124
|
},
|
|
1125
1125
|
});
|
|
1126
|
-
const
|
|
1127
|
-
{
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
},
|
|
1132
|
-
where: [
|
|
1133
|
-
{
|
|
1134
|
-
field: "id",
|
|
1135
|
-
value: user.id,
|
|
1136
|
-
},
|
|
1137
|
-
],
|
|
1138
|
-
},
|
|
1139
|
-
);
|
|
1140
|
-
if (!customer) {
|
|
1126
|
+
const updatedUser =
|
|
1127
|
+
await ctx.context.internalAdapter.updateUser(user.id, {
|
|
1128
|
+
stripeCustomerId: stripeCustomer.id,
|
|
1129
|
+
});
|
|
1130
|
+
if (!updatedUser) {
|
|
1141
1131
|
logger.error("#BETTER_AUTH: Failed to create customer");
|
|
1142
1132
|
} else {
|
|
1143
1133
|
await options.onCustomerCreate?.(
|
|
1144
1134
|
{
|
|
1145
|
-
customer,
|
|
1146
1135
|
stripeCustomer,
|
|
1147
1136
|
user,
|
|
1148
1137
|
},
|
package/src/types.ts
CHANGED
|
@@ -187,7 +187,6 @@ export interface StripeOptions {
|
|
|
187
187
|
*/
|
|
188
188
|
onCustomerCreate?: (
|
|
189
189
|
data: {
|
|
190
|
-
customer: Customer;
|
|
191
190
|
stripeCustomer: Stripe.Customer;
|
|
192
191
|
user: User;
|
|
193
192
|
},
|
|
@@ -330,13 +329,4 @@ export interface StripeOptions {
|
|
|
330
329
|
schema?: InferOptionSchema<typeof subscriptions & typeof user>;
|
|
331
330
|
}
|
|
332
331
|
|
|
333
|
-
export interface Customer {
|
|
334
|
-
id: string;
|
|
335
|
-
stripeCustomerId?: string;
|
|
336
|
-
userId: string;
|
|
337
|
-
createdAt: Date;
|
|
338
|
-
updatedAt: Date;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
332
|
export interface InputSubscription extends Omit<Subscription, "id"> {}
|
|
342
|
-
export interface InputCustomer extends Omit<Customer, "id"> {}
|