@better-auth/stripe 1.3.13 → 1.3.15
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 +23 -45
- package/dist/index.mjs +23 -45
- package/package.json +5 -5
- package/src/hooks.ts +9 -9
- package/src/index.ts +29 -62
- package/tsconfig.json +9 -15
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/stripe@1.3.
|
|
2
|
+
> @better-auth/stripe@1.3.15 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:
|
|
8
|
+
[log] dist/index.cjs (total size: 44.6 kB, chunk size: 44.6 kB, exports: stripe)
|
|
9
9
|
|
|
10
10
|
[log] dist/client.cjs (total size: 270 B, chunk size: 270 B, exports: stripeClient)
|
|
11
11
|
|
|
12
|
-
[log] dist/index.mjs (total size:
|
|
12
|
+
[log] dist/index.mjs (total size: 43.8 kB, chunk size: 43.8 kB, exports: stripe)
|
|
13
13
|
|
|
14
14
|
[log] dist/client.mjs (total size: 243 B, chunk size: 243 B, exports: stripeClient)
|
|
15
15
|
|
|
16
|
-
Σ Total dist size (byte size):
|
|
16
|
+
Σ Total dist size (byte size): 226 kB
|
|
17
17
|
[log]
|
package/dist/index.cjs
CHANGED
|
@@ -406,31 +406,23 @@ const stripe = (options) => {
|
|
|
406
406
|
/**
|
|
407
407
|
* The name of the plan to subscribe
|
|
408
408
|
*/
|
|
409
|
-
plan: z__namespace.string().
|
|
410
|
-
description: 'The name of the plan to upgrade to. Eg: "pro"'
|
|
411
|
-
}),
|
|
409
|
+
plan: z__namespace.string().describe("The name of the plan to upgrade to"),
|
|
412
410
|
/**
|
|
413
411
|
* If annual plan should be applied.
|
|
414
412
|
*/
|
|
415
|
-
annual: z__namespace.boolean().
|
|
416
|
-
description: "Whether to upgrade to an annual plan. Eg: true"
|
|
417
|
-
}).optional(),
|
|
413
|
+
annual: z__namespace.boolean().describe("Whether to upgrade to an annual plan").optional(),
|
|
418
414
|
/**
|
|
419
415
|
* Reference id of the subscription to upgrade
|
|
420
416
|
* This is used to identify the subscription to upgrade
|
|
421
417
|
* If not provided, the user's id will be used
|
|
422
418
|
*/
|
|
423
|
-
referenceId: z__namespace.string().
|
|
424
|
-
description: 'Reference id of the subscription to upgrade. Eg: "123"'
|
|
425
|
-
}).optional(),
|
|
419
|
+
referenceId: z__namespace.string().describe("Reference id of the subscription to upgrade").optional(),
|
|
426
420
|
/**
|
|
427
421
|
* This is to allow a specific subscription to be upgrade.
|
|
428
422
|
* If subscription id is provided, and subscription isn't found,
|
|
429
423
|
* it'll throw an error.
|
|
430
424
|
*/
|
|
431
|
-
subscriptionId: z__namespace.string().
|
|
432
|
-
description: 'The id of the subscription to upgrade. Eg: "sub_123"'
|
|
433
|
-
}).optional(),
|
|
425
|
+
subscriptionId: z__namespace.string().describe("The id of the subscription to upgrade").optional(),
|
|
434
426
|
/**
|
|
435
427
|
* Any additional data you want to store in your database
|
|
436
428
|
* subscriptions
|
|
@@ -439,33 +431,29 @@ const stripe = (options) => {
|
|
|
439
431
|
/**
|
|
440
432
|
* If a subscription
|
|
441
433
|
*/
|
|
442
|
-
seats: z__namespace.number().
|
|
443
|
-
description: "Number of seats to upgrade to (if applicable). Eg: 1"
|
|
444
|
-
}).optional(),
|
|
434
|
+
seats: z__namespace.number().describe("Number of seats to upgrade to (if applicable)").optional(),
|
|
445
435
|
/**
|
|
446
436
|
* Success URL to redirect back after successful subscription
|
|
447
437
|
*/
|
|
448
|
-
successUrl: z__namespace.string().
|
|
449
|
-
|
|
450
|
-
|
|
438
|
+
successUrl: z__namespace.string().describe(
|
|
439
|
+
"Callback URL to redirect back after successful subscription"
|
|
440
|
+
).default("/"),
|
|
451
441
|
/**
|
|
452
442
|
* Cancel URL
|
|
453
443
|
*/
|
|
454
|
-
cancelUrl: z__namespace.string().
|
|
455
|
-
|
|
456
|
-
|
|
444
|
+
cancelUrl: z__namespace.string().describe(
|
|
445
|
+
"If set, checkout shows a back button and customers will be directed here if they cancel payment"
|
|
446
|
+
).default("/"),
|
|
457
447
|
/**
|
|
458
448
|
* Return URL
|
|
459
449
|
*/
|
|
460
|
-
returnUrl: z__namespace.string().
|
|
461
|
-
|
|
462
|
-
|
|
450
|
+
returnUrl: z__namespace.string().describe(
|
|
451
|
+
"URL to take customers to when they click on the billing portal\u2019s link to return to your website"
|
|
452
|
+
).optional(),
|
|
463
453
|
/**
|
|
464
454
|
* Disable Redirect
|
|
465
455
|
*/
|
|
466
|
-
disableRedirect: z__namespace.boolean().
|
|
467
|
-
description: "Disable redirect after successful subscription. Eg: true"
|
|
468
|
-
}).default(false)
|
|
456
|
+
disableRedirect: z__namespace.boolean().describe("Disable redirect after successful subscription").default(false)
|
|
469
457
|
}),
|
|
470
458
|
use: [
|
|
471
459
|
api.sessionMiddleware,
|
|
@@ -823,15 +811,11 @@ const stripe = (options) => {
|
|
|
823
811
|
{
|
|
824
812
|
method: "POST",
|
|
825
813
|
body: z__namespace.object({
|
|
826
|
-
referenceId: z__namespace.string().
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
}).optional(),
|
|
832
|
-
returnUrl: z__namespace.string().meta({
|
|
833
|
-
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"'
|
|
834
|
-
})
|
|
814
|
+
referenceId: z__namespace.string().describe("Reference id of the subscription to cancel").optional(),
|
|
815
|
+
subscriptionId: z__namespace.string().describe("The id of the subscription to cancel").optional(),
|
|
816
|
+
returnUrl: z__namespace.string().describe(
|
|
817
|
+
"URL to take customers to when they click on the billing portal\u2019s link to return to your website"
|
|
818
|
+
)
|
|
835
819
|
}),
|
|
836
820
|
use: [
|
|
837
821
|
api.sessionMiddleware,
|
|
@@ -938,12 +922,8 @@ const stripe = (options) => {
|
|
|
938
922
|
{
|
|
939
923
|
method: "POST",
|
|
940
924
|
body: z__namespace.object({
|
|
941
|
-
referenceId: z__namespace.string().
|
|
942
|
-
|
|
943
|
-
}).optional(),
|
|
944
|
-
subscriptionId: z__namespace.string().meta({
|
|
945
|
-
description: "The id of the subscription to restore. Eg: 'sub_123'"
|
|
946
|
-
}).optional()
|
|
925
|
+
referenceId: z__namespace.string().describe("Reference id of the subscription to restore").optional(),
|
|
926
|
+
subscriptionId: z__namespace.string().describe("The id of the subscription to restore").optional()
|
|
947
927
|
}),
|
|
948
928
|
use: [api.sessionMiddleware, referenceMiddleware("restore-subscription")]
|
|
949
929
|
},
|
|
@@ -1047,9 +1027,7 @@ const stripe = (options) => {
|
|
|
1047
1027
|
method: "GET",
|
|
1048
1028
|
query: z__namespace.optional(
|
|
1049
1029
|
z__namespace.object({
|
|
1050
|
-
referenceId: z__namespace.string().
|
|
1051
|
-
description: "Reference id of the subscription to list. Eg: '123'"
|
|
1052
|
-
}).optional()
|
|
1030
|
+
referenceId: z__namespace.string().describe("Reference id of the subscription to list").optional()
|
|
1053
1031
|
})
|
|
1054
1032
|
),
|
|
1055
1033
|
use: [api.sessionMiddleware, referenceMiddleware("list-subscription")]
|
package/dist/index.mjs
CHANGED
|
@@ -390,31 +390,23 @@ const stripe = (options) => {
|
|
|
390
390
|
/**
|
|
391
391
|
* The name of the plan to subscribe
|
|
392
392
|
*/
|
|
393
|
-
plan: z.string().
|
|
394
|
-
description: 'The name of the plan to upgrade to. Eg: "pro"'
|
|
395
|
-
}),
|
|
393
|
+
plan: z.string().describe("The name of the plan to upgrade to"),
|
|
396
394
|
/**
|
|
397
395
|
* If annual plan should be applied.
|
|
398
396
|
*/
|
|
399
|
-
annual: z.boolean().
|
|
400
|
-
description: "Whether to upgrade to an annual plan. Eg: true"
|
|
401
|
-
}).optional(),
|
|
397
|
+
annual: z.boolean().describe("Whether to upgrade to an annual plan").optional(),
|
|
402
398
|
/**
|
|
403
399
|
* Reference id of the subscription to upgrade
|
|
404
400
|
* This is used to identify the subscription to upgrade
|
|
405
401
|
* If not provided, the user's id will be used
|
|
406
402
|
*/
|
|
407
|
-
referenceId: z.string().
|
|
408
|
-
description: 'Reference id of the subscription to upgrade. Eg: "123"'
|
|
409
|
-
}).optional(),
|
|
403
|
+
referenceId: z.string().describe("Reference id of the subscription to upgrade").optional(),
|
|
410
404
|
/**
|
|
411
405
|
* This is to allow a specific subscription to be upgrade.
|
|
412
406
|
* If subscription id is provided, and subscription isn't found,
|
|
413
407
|
* it'll throw an error.
|
|
414
408
|
*/
|
|
415
|
-
subscriptionId: z.string().
|
|
416
|
-
description: 'The id of the subscription to upgrade. Eg: "sub_123"'
|
|
417
|
-
}).optional(),
|
|
409
|
+
subscriptionId: z.string().describe("The id of the subscription to upgrade").optional(),
|
|
418
410
|
/**
|
|
419
411
|
* Any additional data you want to store in your database
|
|
420
412
|
* subscriptions
|
|
@@ -423,33 +415,29 @@ const stripe = (options) => {
|
|
|
423
415
|
/**
|
|
424
416
|
* If a subscription
|
|
425
417
|
*/
|
|
426
|
-
seats: z.number().
|
|
427
|
-
description: "Number of seats to upgrade to (if applicable). Eg: 1"
|
|
428
|
-
}).optional(),
|
|
418
|
+
seats: z.number().describe("Number of seats to upgrade to (if applicable)").optional(),
|
|
429
419
|
/**
|
|
430
420
|
* Success URL to redirect back after successful subscription
|
|
431
421
|
*/
|
|
432
|
-
successUrl: z.string().
|
|
433
|
-
|
|
434
|
-
|
|
422
|
+
successUrl: z.string().describe(
|
|
423
|
+
"Callback URL to redirect back after successful subscription"
|
|
424
|
+
).default("/"),
|
|
435
425
|
/**
|
|
436
426
|
* Cancel URL
|
|
437
427
|
*/
|
|
438
|
-
cancelUrl: z.string().
|
|
439
|
-
|
|
440
|
-
|
|
428
|
+
cancelUrl: z.string().describe(
|
|
429
|
+
"If set, checkout shows a back button and customers will be directed here if they cancel payment"
|
|
430
|
+
).default("/"),
|
|
441
431
|
/**
|
|
442
432
|
* Return URL
|
|
443
433
|
*/
|
|
444
|
-
returnUrl: z.string().
|
|
445
|
-
|
|
446
|
-
|
|
434
|
+
returnUrl: z.string().describe(
|
|
435
|
+
"URL to take customers to when they click on the billing portal\u2019s link to return to your website"
|
|
436
|
+
).optional(),
|
|
447
437
|
/**
|
|
448
438
|
* Disable Redirect
|
|
449
439
|
*/
|
|
450
|
-
disableRedirect: z.boolean().
|
|
451
|
-
description: "Disable redirect after successful subscription. Eg: true"
|
|
452
|
-
}).default(false)
|
|
440
|
+
disableRedirect: z.boolean().describe("Disable redirect after successful subscription").default(false)
|
|
453
441
|
}),
|
|
454
442
|
use: [
|
|
455
443
|
sessionMiddleware,
|
|
@@ -807,15 +795,11 @@ const stripe = (options) => {
|
|
|
807
795
|
{
|
|
808
796
|
method: "POST",
|
|
809
797
|
body: z.object({
|
|
810
|
-
referenceId: z.string().
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}).optional(),
|
|
816
|
-
returnUrl: z.string().meta({
|
|
817
|
-
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"'
|
|
818
|
-
})
|
|
798
|
+
referenceId: z.string().describe("Reference id of the subscription to cancel").optional(),
|
|
799
|
+
subscriptionId: z.string().describe("The id of the subscription to cancel").optional(),
|
|
800
|
+
returnUrl: z.string().describe(
|
|
801
|
+
"URL to take customers to when they click on the billing portal\u2019s link to return to your website"
|
|
802
|
+
)
|
|
819
803
|
}),
|
|
820
804
|
use: [
|
|
821
805
|
sessionMiddleware,
|
|
@@ -922,12 +906,8 @@ const stripe = (options) => {
|
|
|
922
906
|
{
|
|
923
907
|
method: "POST",
|
|
924
908
|
body: z.object({
|
|
925
|
-
referenceId: z.string().
|
|
926
|
-
|
|
927
|
-
}).optional(),
|
|
928
|
-
subscriptionId: z.string().meta({
|
|
929
|
-
description: "The id of the subscription to restore. Eg: 'sub_123'"
|
|
930
|
-
}).optional()
|
|
909
|
+
referenceId: z.string().describe("Reference id of the subscription to restore").optional(),
|
|
910
|
+
subscriptionId: z.string().describe("The id of the subscription to restore").optional()
|
|
931
911
|
}),
|
|
932
912
|
use: [sessionMiddleware, referenceMiddleware("restore-subscription")]
|
|
933
913
|
},
|
|
@@ -1031,9 +1011,7 @@ const stripe = (options) => {
|
|
|
1031
1011
|
method: "GET",
|
|
1032
1012
|
query: z.optional(
|
|
1033
1013
|
z.object({
|
|
1034
|
-
referenceId: z.string().
|
|
1035
|
-
description: "Reference id of the subscription to list. Eg: '123'"
|
|
1036
|
-
}).optional()
|
|
1014
|
+
referenceId: z.string().describe("Reference id of the subscription to list").optional()
|
|
1037
1015
|
})
|
|
1038
1016
|
),
|
|
1039
1017
|
use: [sessionMiddleware, referenceMiddleware("list-subscription")]
|
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.15",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"stripe": "^18",
|
|
44
|
-
"better-auth": "1.3.
|
|
44
|
+
"better-auth": "1.3.15"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"better-call": "1.0.19",
|
|
48
48
|
"stripe": "^18.5.0",
|
|
49
49
|
"unbuild": "3.6.1",
|
|
50
|
-
"better-auth": "1.3.
|
|
50
|
+
"better-auth": "1.3.15"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"test": "vitest",
|
|
54
54
|
"build": "unbuild",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
55
|
+
"dev": "unbuild --watch",
|
|
56
|
+
"typecheck": "tsc --project tsconfig.json"
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/hooks.ts
CHANGED
|
@@ -29,7 +29,7 @@ export async function onCheckoutSessionCompleted(
|
|
|
29
29
|
checkoutSession?.client_reference_id ||
|
|
30
30
|
checkoutSession?.metadata?.referenceId;
|
|
31
31
|
const subscriptionId = checkoutSession?.metadata?.subscriptionId;
|
|
32
|
-
const seats = subscription.items.data[0]
|
|
32
|
+
const seats = subscription.items.data[0]!.quantity;
|
|
33
33
|
if (referenceId && subscriptionId) {
|
|
34
34
|
const trial =
|
|
35
35
|
subscription.trial_start && subscription.trial_end
|
|
@@ -47,10 +47,10 @@ export async function onCheckoutSessionCompleted(
|
|
|
47
47
|
status: subscription.status,
|
|
48
48
|
updatedAt: new Date(),
|
|
49
49
|
periodStart: new Date(
|
|
50
|
-
subscription.items.data[0]
|
|
50
|
+
subscription.items.data[0]!.current_period_start * 1000,
|
|
51
51
|
),
|
|
52
52
|
periodEnd: new Date(
|
|
53
|
-
subscription.items.data[0]
|
|
53
|
+
subscription.items.data[0]!.current_period_end * 1000,
|
|
54
54
|
),
|
|
55
55
|
stripeSubscriptionId: checkoutSession.subscription as string,
|
|
56
56
|
seats,
|
|
@@ -106,9 +106,9 @@ export async function onSubscriptionUpdated(
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
const subscriptionUpdated = event.data.object as Stripe.Subscription;
|
|
109
|
-
const priceId = subscriptionUpdated.items.data[0]
|
|
109
|
+
const priceId = subscriptionUpdated.items.data[0]!.price.id;
|
|
110
110
|
const priceLookupKey =
|
|
111
|
-
subscriptionUpdated.items.data[0]
|
|
111
|
+
subscriptionUpdated.items.data[0]!.price.lookup_key || null;
|
|
112
112
|
const plan = await getPlanByPriceInfo(options, priceId, priceLookupKey);
|
|
113
113
|
|
|
114
114
|
const subscriptionId = subscriptionUpdated.metadata?.subscriptionId;
|
|
@@ -137,11 +137,11 @@ export async function onSubscriptionUpdated(
|
|
|
137
137
|
}
|
|
138
138
|
subscription = activeSub;
|
|
139
139
|
} else {
|
|
140
|
-
subscription = subs[0]
|
|
140
|
+
subscription = subs[0]!;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
const seats = subscriptionUpdated.items.data[0]
|
|
144
|
+
const seats = subscriptionUpdated.items.data[0]!.quantity;
|
|
145
145
|
await ctx.context.adapter.update({
|
|
146
146
|
model: "subscription",
|
|
147
147
|
update: {
|
|
@@ -154,10 +154,10 @@ export async function onSubscriptionUpdated(
|
|
|
154
154
|
updatedAt: new Date(),
|
|
155
155
|
status: subscriptionUpdated.status,
|
|
156
156
|
periodStart: new Date(
|
|
157
|
-
subscriptionUpdated.items.data[0]
|
|
157
|
+
subscriptionUpdated.items.data[0]!.current_period_start * 1000,
|
|
158
158
|
),
|
|
159
159
|
periodEnd: new Date(
|
|
160
|
-
subscriptionUpdated.items.data[0]
|
|
160
|
+
subscriptionUpdated.items.data[0]!.current_period_end * 1000,
|
|
161
161
|
),
|
|
162
162
|
cancelAtPeriodEnd: subscriptionUpdated.cancel_at_period_end,
|
|
163
163
|
seats,
|
package/src/index.ts
CHANGED
|
@@ -132,17 +132,13 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
132
132
|
/**
|
|
133
133
|
* The name of the plan to subscribe
|
|
134
134
|
*/
|
|
135
|
-
plan: z.string().
|
|
136
|
-
description: 'The name of the plan to upgrade to. Eg: "pro"',
|
|
137
|
-
}),
|
|
135
|
+
plan: z.string().describe("The name of the plan to upgrade to"),
|
|
138
136
|
/**
|
|
139
137
|
* If annual plan should be applied.
|
|
140
138
|
*/
|
|
141
139
|
annual: z
|
|
142
140
|
.boolean()
|
|
143
|
-
.
|
|
144
|
-
description: "Whether to upgrade to an annual plan. Eg: true",
|
|
145
|
-
})
|
|
141
|
+
.describe("Whether to upgrade to an annual plan")
|
|
146
142
|
.optional(),
|
|
147
143
|
/**
|
|
148
144
|
* Reference id of the subscription to upgrade
|
|
@@ -151,10 +147,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
151
147
|
*/
|
|
152
148
|
referenceId: z
|
|
153
149
|
.string()
|
|
154
|
-
.
|
|
155
|
-
description:
|
|
156
|
-
'Reference id of the subscription to upgrade. Eg: "123"',
|
|
157
|
-
})
|
|
150
|
+
.describe("Reference id of the subscription to upgrade")
|
|
158
151
|
.optional(),
|
|
159
152
|
/**
|
|
160
153
|
* This is to allow a specific subscription to be upgrade.
|
|
@@ -163,10 +156,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
163
156
|
*/
|
|
164
157
|
subscriptionId: z
|
|
165
158
|
.string()
|
|
166
|
-
.
|
|
167
|
-
description:
|
|
168
|
-
'The id of the subscription to upgrade. Eg: "sub_123"',
|
|
169
|
-
})
|
|
159
|
+
.describe("The id of the subscription to upgrade")
|
|
170
160
|
.optional(),
|
|
171
161
|
/**
|
|
172
162
|
* Any additional data you want to store in your database
|
|
@@ -178,50 +168,41 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
178
168
|
*/
|
|
179
169
|
seats: z
|
|
180
170
|
.number()
|
|
181
|
-
.
|
|
182
|
-
description:
|
|
183
|
-
"Number of seats to upgrade to (if applicable). Eg: 1",
|
|
184
|
-
})
|
|
171
|
+
.describe("Number of seats to upgrade to (if applicable)")
|
|
185
172
|
.optional(),
|
|
186
173
|
/**
|
|
187
174
|
* Success URL to redirect back after successful subscription
|
|
188
175
|
*/
|
|
189
176
|
successUrl: z
|
|
190
177
|
.string()
|
|
191
|
-
.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
})
|
|
178
|
+
.describe(
|
|
179
|
+
"Callback URL to redirect back after successful subscription",
|
|
180
|
+
)
|
|
195
181
|
.default("/"),
|
|
196
182
|
/**
|
|
197
183
|
* Cancel URL
|
|
198
184
|
*/
|
|
199
185
|
cancelUrl: z
|
|
200
186
|
.string()
|
|
201
|
-
.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
})
|
|
187
|
+
.describe(
|
|
188
|
+
"If set, checkout shows a back button and customers will be directed here if they cancel payment",
|
|
189
|
+
)
|
|
205
190
|
.default("/"),
|
|
206
191
|
/**
|
|
207
192
|
* Return URL
|
|
208
193
|
*/
|
|
209
194
|
returnUrl: z
|
|
210
195
|
.string()
|
|
211
|
-
.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
})
|
|
196
|
+
.describe(
|
|
197
|
+
"URL to take customers to when they click on the billing portal’s link to return to your website",
|
|
198
|
+
)
|
|
215
199
|
.optional(),
|
|
216
200
|
/**
|
|
217
201
|
* Disable Redirect
|
|
218
202
|
*/
|
|
219
203
|
disableRedirect: z
|
|
220
204
|
.boolean()
|
|
221
|
-
.
|
|
222
|
-
description:
|
|
223
|
-
"Disable redirect after successful subscription. Eg: true",
|
|
224
|
-
})
|
|
205
|
+
.describe("Disable redirect after successful subscription")
|
|
225
206
|
.default(false),
|
|
226
207
|
}),
|
|
227
208
|
use: [
|
|
@@ -654,22 +635,17 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
654
635
|
body: z.object({
|
|
655
636
|
referenceId: z
|
|
656
637
|
.string()
|
|
657
|
-
.
|
|
658
|
-
description:
|
|
659
|
-
"Reference id of the subscription to cancel. Eg: '123'",
|
|
660
|
-
})
|
|
638
|
+
.describe("Reference id of the subscription to cancel")
|
|
661
639
|
.optional(),
|
|
662
640
|
subscriptionId: z
|
|
663
641
|
.string()
|
|
664
|
-
.
|
|
665
|
-
description:
|
|
666
|
-
"The id of the subscription to cancel. Eg: 'sub_123'",
|
|
667
|
-
})
|
|
642
|
+
.describe("The id of the subscription to cancel")
|
|
668
643
|
.optional(),
|
|
669
|
-
returnUrl: z
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
644
|
+
returnUrl: z
|
|
645
|
+
.string()
|
|
646
|
+
.describe(
|
|
647
|
+
"URL to take customers to when they click on the billing portal’s link to return to your website",
|
|
648
|
+
),
|
|
673
649
|
}),
|
|
674
650
|
use: [
|
|
675
651
|
sessionMiddleware,
|
|
@@ -798,17 +774,11 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
798
774
|
body: z.object({
|
|
799
775
|
referenceId: z
|
|
800
776
|
.string()
|
|
801
|
-
.
|
|
802
|
-
description:
|
|
803
|
-
"Reference id of the subscription to restore. Eg: '123'",
|
|
804
|
-
})
|
|
777
|
+
.describe("Reference id of the subscription to restore")
|
|
805
778
|
.optional(),
|
|
806
779
|
subscriptionId: z
|
|
807
780
|
.string()
|
|
808
|
-
.
|
|
809
|
-
description:
|
|
810
|
-
"The id of the subscription to restore. Eg: 'sub_123'",
|
|
811
|
-
})
|
|
781
|
+
.describe("The id of the subscription to restore")
|
|
812
782
|
.optional(),
|
|
813
783
|
}),
|
|
814
784
|
use: [sessionMiddleware, referenceMiddleware("restore-subscription")],
|
|
@@ -932,10 +902,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
932
902
|
z.object({
|
|
933
903
|
referenceId: z
|
|
934
904
|
.string()
|
|
935
|
-
.
|
|
936
|
-
description:
|
|
937
|
-
"Reference id of the subscription to list. Eg: '123'",
|
|
938
|
-
})
|
|
905
|
+
.describe("Reference id of the subscription to list")
|
|
939
906
|
.optional(),
|
|
940
907
|
}),
|
|
941
908
|
),
|
|
@@ -1026,8 +993,8 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
1026
993
|
if (stripeSubscription) {
|
|
1027
994
|
const plan = await getPlanByPriceInfo(
|
|
1028
995
|
options,
|
|
1029
|
-
stripeSubscription.items.data[0]?.price.id
|
|
1030
|
-
stripeSubscription.items.data[0]?.price.lookup_key
|
|
996
|
+
stripeSubscription.items.data[0]?.price.id!,
|
|
997
|
+
stripeSubscription.items.data[0]?.price.lookup_key!,
|
|
1031
998
|
);
|
|
1032
999
|
|
|
1033
1000
|
if (plan && subscription) {
|
|
@@ -1038,11 +1005,11 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
1038
1005
|
seats: stripeSubscription.items.data[0]?.quantity || 1,
|
|
1039
1006
|
plan: plan.name.toLowerCase(),
|
|
1040
1007
|
periodEnd: new Date(
|
|
1041
|
-
stripeSubscription.items.data[0]?.current_period_end *
|
|
1008
|
+
stripeSubscription.items.data[0]?.current_period_end! *
|
|
1042
1009
|
1000,
|
|
1043
1010
|
),
|
|
1044
1011
|
periodStart: new Date(
|
|
1045
|
-
stripeSubscription.items.data[0]?.current_period_start *
|
|
1012
|
+
stripeSubscription.items.data[0]?.current_period_start! *
|
|
1046
1013
|
1000,
|
|
1047
1014
|
),
|
|
1048
1015
|
stripeSubscriptionId: stripeSubscription.id,
|
package/tsconfig.json
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"resolveJsonModule": true,
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
"noEmit": true,
|
|
10
|
-
"moduleResolution": "Bundler",
|
|
11
|
-
"moduleDetection": "force",
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"verbatimModuleSyntax": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"noImplicitOverride": true,
|
|
16
|
-
"noFallthroughCasesInSwitch": true
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"lib": ["esnext", "dom", "dom.iterable"]
|
|
17
7
|
},
|
|
18
|
-
"
|
|
8
|
+
"references": [
|
|
9
|
+
{
|
|
10
|
+
"path": "../better-auth/tsconfig.json"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
19
13
|
"include": ["src"]
|
|
20
14
|
}
|