@better-auth/stripe 1.2.7 → 1.2.8-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 +17 -9
- package/dist/index.d.cts +10 -6
- package/dist/index.d.mts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.mjs +17 -9
- package/package.json +6 -5
- package/src/hooks.ts +15 -6
- package/src/index.ts +9 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/stripe@1.2.
|
|
2
|
+
> @better-auth/stripe@1.2.8-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: 37 kB, chunk size: 37 kB, exports: stripe)
|
|
8
|
+
[log] dist/index.cjs (total size: 37.2 kB, chunk size: 37.2 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: 36.
|
|
12
|
+
[log] dist/index.mjs (total size: 36.9 kB, chunk size: 36.9 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): 201 kB
|
|
17
17
|
[log]
|
package/dist/index.cjs
CHANGED
|
@@ -50,8 +50,12 @@ async function onCheckoutSessionCompleted(ctx, options, event) {
|
|
|
50
50
|
plan: plan.name.toLowerCase(),
|
|
51
51
|
status: subscription.status,
|
|
52
52
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
53
|
-
periodStart: new Date(
|
|
54
|
-
|
|
53
|
+
periodStart: new Date(
|
|
54
|
+
subscription.items.data[0].current_period_start * 1e3
|
|
55
|
+
),
|
|
56
|
+
periodEnd: new Date(
|
|
57
|
+
subscription.items.data[0].current_period_end * 1e3
|
|
58
|
+
),
|
|
55
59
|
stripeSubscriptionId: checkoutSession.subscription,
|
|
56
60
|
seats,
|
|
57
61
|
...trial
|
|
@@ -134,8 +138,12 @@ async function onSubscriptionUpdated(ctx, options, event) {
|
|
|
134
138
|
} : {},
|
|
135
139
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
136
140
|
status: subscriptionUpdated.status,
|
|
137
|
-
periodStart: new Date(
|
|
138
|
-
|
|
141
|
+
periodStart: new Date(
|
|
142
|
+
subscriptionUpdated.items.data[0].current_period_start * 1e3
|
|
143
|
+
),
|
|
144
|
+
periodEnd: new Date(
|
|
145
|
+
subscriptionUpdated.items.data[0].current_period_end * 1e3
|
|
146
|
+
),
|
|
139
147
|
cancelAtPeriodEnd: subscriptionUpdated.cancel_at_period_end,
|
|
140
148
|
seats,
|
|
141
149
|
stripeSubscriptionId: subscriptionUpdated.id
|
|
@@ -372,16 +380,16 @@ const stripe = (options) => {
|
|
|
372
380
|
description: "Number of seats to upgrade to (if applicable)"
|
|
373
381
|
}).optional(),
|
|
374
382
|
/**
|
|
375
|
-
* Success
|
|
383
|
+
* Success URL to redirect back after successful subscription
|
|
376
384
|
*/
|
|
377
385
|
successUrl: zod.z.string({
|
|
378
|
-
description: "
|
|
386
|
+
description: "Callback URL to redirect back after successful subscription"
|
|
379
387
|
}).default("/"),
|
|
380
388
|
/**
|
|
381
389
|
* Cancel URL
|
|
382
390
|
*/
|
|
383
391
|
cancelUrl: zod.z.string({
|
|
384
|
-
description: "
|
|
392
|
+
description: "Callback URL to redirect back after successful subscription"
|
|
385
393
|
}).default("/"),
|
|
386
394
|
/**
|
|
387
395
|
* Return URL
|
|
@@ -950,10 +958,10 @@ const stripe = (options) => {
|
|
|
950
958
|
seats: stripeSubscription.items.data[0]?.quantity || 1,
|
|
951
959
|
plan: plan.name.toLowerCase(),
|
|
952
960
|
periodEnd: new Date(
|
|
953
|
-
stripeSubscription.current_period_end * 1e3
|
|
961
|
+
stripeSubscription.items.data[0]?.current_period_end * 1e3
|
|
954
962
|
),
|
|
955
963
|
periodStart: new Date(
|
|
956
|
-
stripeSubscription.current_period_start * 1e3
|
|
964
|
+
stripeSubscription.items.data[0]?.current_period_start * 1e3
|
|
957
965
|
),
|
|
958
966
|
stripeSubscriptionId: stripeSubscription.id,
|
|
959
967
|
...stripeSubscription.trial_start && stripeSubscription.trial_end ? {
|
package/dist/index.d.cts
CHANGED
|
@@ -444,7 +444,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
444
444
|
cancel_url: string | null;
|
|
445
445
|
client_reference_id: string | null;
|
|
446
446
|
client_secret: string | null;
|
|
447
|
-
collected_information
|
|
447
|
+
collected_information: Stripe.Checkout.Session.CollectedInformation | null;
|
|
448
448
|
consent: Stripe.Checkout.Session.Consent | null;
|
|
449
449
|
consent_collection: Stripe.Checkout.Session.ConsentCollection | null;
|
|
450
450
|
created: number;
|
|
@@ -465,6 +465,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
465
465
|
locale: Stripe.Checkout.Session.Locale | null;
|
|
466
466
|
metadata: Stripe.Metadata | null;
|
|
467
467
|
mode: Stripe.Checkout.Session.Mode;
|
|
468
|
+
optional_items?: Array<Stripe.Checkout.Session.OptionalItem> | null;
|
|
468
469
|
payment_intent: string | Stripe.PaymentIntent | null;
|
|
469
470
|
payment_link: string | Stripe.PaymentLink | null;
|
|
470
471
|
payment_method_collection: Stripe.Checkout.Session.PaymentMethodCollection | null;
|
|
@@ -472,7 +473,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
472
473
|
payment_method_options: Stripe.Checkout.Session.PaymentMethodOptions | null;
|
|
473
474
|
payment_method_types: Array<string>;
|
|
474
475
|
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
476
|
+
permissions: Stripe.Checkout.Session.Permissions | null;
|
|
475
477
|
phone_number_collection?: Stripe.Checkout.Session.PhoneNumberCollection;
|
|
478
|
+
presentment_details?: Stripe.Checkout.Session.PresentmentDetails;
|
|
476
479
|
recovered_from: string | null;
|
|
477
480
|
redirect_on_completion?: Stripe.Checkout.Session.RedirectOnCompletion;
|
|
478
481
|
return_url?: string;
|
|
@@ -480,7 +483,6 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
480
483
|
setup_intent: string | Stripe.SetupIntent | null;
|
|
481
484
|
shipping_address_collection: Stripe.Checkout.Session.ShippingAddressCollection | null;
|
|
482
485
|
shipping_cost: Stripe.Checkout.Session.ShippingCost | null;
|
|
483
|
-
shipping_details: Stripe.Checkout.Session.ShippingDetails | null;
|
|
484
486
|
shipping_options: Array<Stripe.Checkout.Session.ShippingOption>;
|
|
485
487
|
status: Stripe.Checkout.Session.Status | null;
|
|
486
488
|
submit_type: Stripe.Checkout.Session.SubmitType | null;
|
|
@@ -518,7 +520,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
518
520
|
cancel_url: string | null;
|
|
519
521
|
client_reference_id: string | null;
|
|
520
522
|
client_secret: string | null;
|
|
521
|
-
collected_information
|
|
523
|
+
collected_information: Stripe.Checkout.Session.CollectedInformation | null;
|
|
522
524
|
consent: Stripe.Checkout.Session.Consent | null;
|
|
523
525
|
consent_collection: Stripe.Checkout.Session.ConsentCollection | null;
|
|
524
526
|
created: number;
|
|
@@ -539,6 +541,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
539
541
|
locale: Stripe.Checkout.Session.Locale | null;
|
|
540
542
|
metadata: Stripe.Metadata | null;
|
|
541
543
|
mode: Stripe.Checkout.Session.Mode;
|
|
544
|
+
optional_items?: Array<Stripe.Checkout.Session.OptionalItem> | null;
|
|
542
545
|
payment_intent: string | Stripe.PaymentIntent | null;
|
|
543
546
|
payment_link: string | Stripe.PaymentLink | null;
|
|
544
547
|
payment_method_collection: Stripe.Checkout.Session.PaymentMethodCollection | null;
|
|
@@ -546,7 +549,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
546
549
|
payment_method_options: Stripe.Checkout.Session.PaymentMethodOptions | null;
|
|
547
550
|
payment_method_types: Array<string>;
|
|
548
551
|
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
552
|
+
permissions: Stripe.Checkout.Session.Permissions | null;
|
|
549
553
|
phone_number_collection?: Stripe.Checkout.Session.PhoneNumberCollection;
|
|
554
|
+
presentment_details?: Stripe.Checkout.Session.PresentmentDetails;
|
|
550
555
|
recovered_from: string | null;
|
|
551
556
|
redirect_on_completion?: Stripe.Checkout.Session.RedirectOnCompletion;
|
|
552
557
|
return_url?: string;
|
|
@@ -554,7 +559,6 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
554
559
|
setup_intent: string | Stripe.SetupIntent | null;
|
|
555
560
|
shipping_address_collection: Stripe.Checkout.Session.ShippingAddressCollection | null;
|
|
556
561
|
shipping_cost: Stripe.Checkout.Session.ShippingCost | null;
|
|
557
|
-
shipping_details: Stripe.Checkout.Session.ShippingDetails | null;
|
|
558
562
|
shipping_options: Array<Stripe.Checkout.Session.ShippingOption>;
|
|
559
563
|
status: Stripe.Checkout.Session.Status | null;
|
|
560
564
|
submit_type: Stripe.Checkout.Session.SubmitType | null;
|
|
@@ -608,7 +612,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
608
612
|
*/
|
|
609
613
|
seats: z.ZodOptional<z.ZodNumber>;
|
|
610
614
|
/**
|
|
611
|
-
* Success
|
|
615
|
+
* Success URL to redirect back after successful subscription
|
|
612
616
|
*/
|
|
613
617
|
successUrl: z.ZodDefault<z.ZodString>;
|
|
614
618
|
/**
|
|
@@ -1057,4 +1061,4 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
1057
1061
|
};
|
|
1058
1062
|
};
|
|
1059
1063
|
|
|
1060
|
-
export { type Subscription, stripe };
|
|
1064
|
+
export { type StripePlan, type Subscription, stripe };
|
package/dist/index.d.mts
CHANGED
|
@@ -444,7 +444,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
444
444
|
cancel_url: string | null;
|
|
445
445
|
client_reference_id: string | null;
|
|
446
446
|
client_secret: string | null;
|
|
447
|
-
collected_information
|
|
447
|
+
collected_information: Stripe.Checkout.Session.CollectedInformation | null;
|
|
448
448
|
consent: Stripe.Checkout.Session.Consent | null;
|
|
449
449
|
consent_collection: Stripe.Checkout.Session.ConsentCollection | null;
|
|
450
450
|
created: number;
|
|
@@ -465,6 +465,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
465
465
|
locale: Stripe.Checkout.Session.Locale | null;
|
|
466
466
|
metadata: Stripe.Metadata | null;
|
|
467
467
|
mode: Stripe.Checkout.Session.Mode;
|
|
468
|
+
optional_items?: Array<Stripe.Checkout.Session.OptionalItem> | null;
|
|
468
469
|
payment_intent: string | Stripe.PaymentIntent | null;
|
|
469
470
|
payment_link: string | Stripe.PaymentLink | null;
|
|
470
471
|
payment_method_collection: Stripe.Checkout.Session.PaymentMethodCollection | null;
|
|
@@ -472,7 +473,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
472
473
|
payment_method_options: Stripe.Checkout.Session.PaymentMethodOptions | null;
|
|
473
474
|
payment_method_types: Array<string>;
|
|
474
475
|
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
476
|
+
permissions: Stripe.Checkout.Session.Permissions | null;
|
|
475
477
|
phone_number_collection?: Stripe.Checkout.Session.PhoneNumberCollection;
|
|
478
|
+
presentment_details?: Stripe.Checkout.Session.PresentmentDetails;
|
|
476
479
|
recovered_from: string | null;
|
|
477
480
|
redirect_on_completion?: Stripe.Checkout.Session.RedirectOnCompletion;
|
|
478
481
|
return_url?: string;
|
|
@@ -480,7 +483,6 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
480
483
|
setup_intent: string | Stripe.SetupIntent | null;
|
|
481
484
|
shipping_address_collection: Stripe.Checkout.Session.ShippingAddressCollection | null;
|
|
482
485
|
shipping_cost: Stripe.Checkout.Session.ShippingCost | null;
|
|
483
|
-
shipping_details: Stripe.Checkout.Session.ShippingDetails | null;
|
|
484
486
|
shipping_options: Array<Stripe.Checkout.Session.ShippingOption>;
|
|
485
487
|
status: Stripe.Checkout.Session.Status | null;
|
|
486
488
|
submit_type: Stripe.Checkout.Session.SubmitType | null;
|
|
@@ -518,7 +520,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
518
520
|
cancel_url: string | null;
|
|
519
521
|
client_reference_id: string | null;
|
|
520
522
|
client_secret: string | null;
|
|
521
|
-
collected_information
|
|
523
|
+
collected_information: Stripe.Checkout.Session.CollectedInformation | null;
|
|
522
524
|
consent: Stripe.Checkout.Session.Consent | null;
|
|
523
525
|
consent_collection: Stripe.Checkout.Session.ConsentCollection | null;
|
|
524
526
|
created: number;
|
|
@@ -539,6 +541,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
539
541
|
locale: Stripe.Checkout.Session.Locale | null;
|
|
540
542
|
metadata: Stripe.Metadata | null;
|
|
541
543
|
mode: Stripe.Checkout.Session.Mode;
|
|
544
|
+
optional_items?: Array<Stripe.Checkout.Session.OptionalItem> | null;
|
|
542
545
|
payment_intent: string | Stripe.PaymentIntent | null;
|
|
543
546
|
payment_link: string | Stripe.PaymentLink | null;
|
|
544
547
|
payment_method_collection: Stripe.Checkout.Session.PaymentMethodCollection | null;
|
|
@@ -546,7 +549,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
546
549
|
payment_method_options: Stripe.Checkout.Session.PaymentMethodOptions | null;
|
|
547
550
|
payment_method_types: Array<string>;
|
|
548
551
|
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
552
|
+
permissions: Stripe.Checkout.Session.Permissions | null;
|
|
549
553
|
phone_number_collection?: Stripe.Checkout.Session.PhoneNumberCollection;
|
|
554
|
+
presentment_details?: Stripe.Checkout.Session.PresentmentDetails;
|
|
550
555
|
recovered_from: string | null;
|
|
551
556
|
redirect_on_completion?: Stripe.Checkout.Session.RedirectOnCompletion;
|
|
552
557
|
return_url?: string;
|
|
@@ -554,7 +559,6 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
554
559
|
setup_intent: string | Stripe.SetupIntent | null;
|
|
555
560
|
shipping_address_collection: Stripe.Checkout.Session.ShippingAddressCollection | null;
|
|
556
561
|
shipping_cost: Stripe.Checkout.Session.ShippingCost | null;
|
|
557
|
-
shipping_details: Stripe.Checkout.Session.ShippingDetails | null;
|
|
558
562
|
shipping_options: Array<Stripe.Checkout.Session.ShippingOption>;
|
|
559
563
|
status: Stripe.Checkout.Session.Status | null;
|
|
560
564
|
submit_type: Stripe.Checkout.Session.SubmitType | null;
|
|
@@ -608,7 +612,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
608
612
|
*/
|
|
609
613
|
seats: z.ZodOptional<z.ZodNumber>;
|
|
610
614
|
/**
|
|
611
|
-
* Success
|
|
615
|
+
* Success URL to redirect back after successful subscription
|
|
612
616
|
*/
|
|
613
617
|
successUrl: z.ZodDefault<z.ZodString>;
|
|
614
618
|
/**
|
|
@@ -1057,4 +1061,4 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
1057
1061
|
};
|
|
1058
1062
|
};
|
|
1059
1063
|
|
|
1060
|
-
export { type Subscription, stripe };
|
|
1064
|
+
export { type StripePlan, type Subscription, stripe };
|
package/dist/index.d.ts
CHANGED
|
@@ -444,7 +444,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
444
444
|
cancel_url: string | null;
|
|
445
445
|
client_reference_id: string | null;
|
|
446
446
|
client_secret: string | null;
|
|
447
|
-
collected_information
|
|
447
|
+
collected_information: Stripe.Checkout.Session.CollectedInformation | null;
|
|
448
448
|
consent: Stripe.Checkout.Session.Consent | null;
|
|
449
449
|
consent_collection: Stripe.Checkout.Session.ConsentCollection | null;
|
|
450
450
|
created: number;
|
|
@@ -465,6 +465,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
465
465
|
locale: Stripe.Checkout.Session.Locale | null;
|
|
466
466
|
metadata: Stripe.Metadata | null;
|
|
467
467
|
mode: Stripe.Checkout.Session.Mode;
|
|
468
|
+
optional_items?: Array<Stripe.Checkout.Session.OptionalItem> | null;
|
|
468
469
|
payment_intent: string | Stripe.PaymentIntent | null;
|
|
469
470
|
payment_link: string | Stripe.PaymentLink | null;
|
|
470
471
|
payment_method_collection: Stripe.Checkout.Session.PaymentMethodCollection | null;
|
|
@@ -472,7 +473,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
472
473
|
payment_method_options: Stripe.Checkout.Session.PaymentMethodOptions | null;
|
|
473
474
|
payment_method_types: Array<string>;
|
|
474
475
|
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
476
|
+
permissions: Stripe.Checkout.Session.Permissions | null;
|
|
475
477
|
phone_number_collection?: Stripe.Checkout.Session.PhoneNumberCollection;
|
|
478
|
+
presentment_details?: Stripe.Checkout.Session.PresentmentDetails;
|
|
476
479
|
recovered_from: string | null;
|
|
477
480
|
redirect_on_completion?: Stripe.Checkout.Session.RedirectOnCompletion;
|
|
478
481
|
return_url?: string;
|
|
@@ -480,7 +483,6 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
480
483
|
setup_intent: string | Stripe.SetupIntent | null;
|
|
481
484
|
shipping_address_collection: Stripe.Checkout.Session.ShippingAddressCollection | null;
|
|
482
485
|
shipping_cost: Stripe.Checkout.Session.ShippingCost | null;
|
|
483
|
-
shipping_details: Stripe.Checkout.Session.ShippingDetails | null;
|
|
484
486
|
shipping_options: Array<Stripe.Checkout.Session.ShippingOption>;
|
|
485
487
|
status: Stripe.Checkout.Session.Status | null;
|
|
486
488
|
submit_type: Stripe.Checkout.Session.SubmitType | null;
|
|
@@ -518,7 +520,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
518
520
|
cancel_url: string | null;
|
|
519
521
|
client_reference_id: string | null;
|
|
520
522
|
client_secret: string | null;
|
|
521
|
-
collected_information
|
|
523
|
+
collected_information: Stripe.Checkout.Session.CollectedInformation | null;
|
|
522
524
|
consent: Stripe.Checkout.Session.Consent | null;
|
|
523
525
|
consent_collection: Stripe.Checkout.Session.ConsentCollection | null;
|
|
524
526
|
created: number;
|
|
@@ -539,6 +541,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
539
541
|
locale: Stripe.Checkout.Session.Locale | null;
|
|
540
542
|
metadata: Stripe.Metadata | null;
|
|
541
543
|
mode: Stripe.Checkout.Session.Mode;
|
|
544
|
+
optional_items?: Array<Stripe.Checkout.Session.OptionalItem> | null;
|
|
542
545
|
payment_intent: string | Stripe.PaymentIntent | null;
|
|
543
546
|
payment_link: string | Stripe.PaymentLink | null;
|
|
544
547
|
payment_method_collection: Stripe.Checkout.Session.PaymentMethodCollection | null;
|
|
@@ -546,7 +549,9 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
546
549
|
payment_method_options: Stripe.Checkout.Session.PaymentMethodOptions | null;
|
|
547
550
|
payment_method_types: Array<string>;
|
|
548
551
|
payment_status: Stripe.Checkout.Session.PaymentStatus;
|
|
552
|
+
permissions: Stripe.Checkout.Session.Permissions | null;
|
|
549
553
|
phone_number_collection?: Stripe.Checkout.Session.PhoneNumberCollection;
|
|
554
|
+
presentment_details?: Stripe.Checkout.Session.PresentmentDetails;
|
|
550
555
|
recovered_from: string | null;
|
|
551
556
|
redirect_on_completion?: Stripe.Checkout.Session.RedirectOnCompletion;
|
|
552
557
|
return_url?: string;
|
|
@@ -554,7 +559,6 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
554
559
|
setup_intent: string | Stripe.SetupIntent | null;
|
|
555
560
|
shipping_address_collection: Stripe.Checkout.Session.ShippingAddressCollection | null;
|
|
556
561
|
shipping_cost: Stripe.Checkout.Session.ShippingCost | null;
|
|
557
|
-
shipping_details: Stripe.Checkout.Session.ShippingDetails | null;
|
|
558
562
|
shipping_options: Array<Stripe.Checkout.Session.ShippingOption>;
|
|
559
563
|
status: Stripe.Checkout.Session.Status | null;
|
|
560
564
|
submit_type: Stripe.Checkout.Session.SubmitType | null;
|
|
@@ -608,7 +612,7 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
608
612
|
*/
|
|
609
613
|
seats: z.ZodOptional<z.ZodNumber>;
|
|
610
614
|
/**
|
|
611
|
-
* Success
|
|
615
|
+
* Success URL to redirect back after successful subscription
|
|
612
616
|
*/
|
|
613
617
|
successUrl: z.ZodDefault<z.ZodString>;
|
|
614
618
|
/**
|
|
@@ -1057,4 +1061,4 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
|
|
|
1057
1061
|
};
|
|
1058
1062
|
};
|
|
1059
1063
|
|
|
1060
|
-
export { type Subscription, stripe };
|
|
1064
|
+
export { type StripePlan, type Subscription, stripe };
|
package/dist/index.mjs
CHANGED
|
@@ -48,8 +48,12 @@ async function onCheckoutSessionCompleted(ctx, options, event) {
|
|
|
48
48
|
plan: plan.name.toLowerCase(),
|
|
49
49
|
status: subscription.status,
|
|
50
50
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
51
|
-
periodStart: new Date(
|
|
52
|
-
|
|
51
|
+
periodStart: new Date(
|
|
52
|
+
subscription.items.data[0].current_period_start * 1e3
|
|
53
|
+
),
|
|
54
|
+
periodEnd: new Date(
|
|
55
|
+
subscription.items.data[0].current_period_end * 1e3
|
|
56
|
+
),
|
|
53
57
|
stripeSubscriptionId: checkoutSession.subscription,
|
|
54
58
|
seats,
|
|
55
59
|
...trial
|
|
@@ -132,8 +136,12 @@ async function onSubscriptionUpdated(ctx, options, event) {
|
|
|
132
136
|
} : {},
|
|
133
137
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
134
138
|
status: subscriptionUpdated.status,
|
|
135
|
-
periodStart: new Date(
|
|
136
|
-
|
|
139
|
+
periodStart: new Date(
|
|
140
|
+
subscriptionUpdated.items.data[0].current_period_start * 1e3
|
|
141
|
+
),
|
|
142
|
+
periodEnd: new Date(
|
|
143
|
+
subscriptionUpdated.items.data[0].current_period_end * 1e3
|
|
144
|
+
),
|
|
137
145
|
cancelAtPeriodEnd: subscriptionUpdated.cancel_at_period_end,
|
|
138
146
|
seats,
|
|
139
147
|
stripeSubscriptionId: subscriptionUpdated.id
|
|
@@ -370,16 +378,16 @@ const stripe = (options) => {
|
|
|
370
378
|
description: "Number of seats to upgrade to (if applicable)"
|
|
371
379
|
}).optional(),
|
|
372
380
|
/**
|
|
373
|
-
* Success
|
|
381
|
+
* Success URL to redirect back after successful subscription
|
|
374
382
|
*/
|
|
375
383
|
successUrl: z.string({
|
|
376
|
-
description: "
|
|
384
|
+
description: "Callback URL to redirect back after successful subscription"
|
|
377
385
|
}).default("/"),
|
|
378
386
|
/**
|
|
379
387
|
* Cancel URL
|
|
380
388
|
*/
|
|
381
389
|
cancelUrl: z.string({
|
|
382
|
-
description: "
|
|
390
|
+
description: "Callback URL to redirect back after successful subscription"
|
|
383
391
|
}).default("/"),
|
|
384
392
|
/**
|
|
385
393
|
* Return URL
|
|
@@ -948,10 +956,10 @@ const stripe = (options) => {
|
|
|
948
956
|
seats: stripeSubscription.items.data[0]?.quantity || 1,
|
|
949
957
|
plan: plan.name.toLowerCase(),
|
|
950
958
|
periodEnd: new Date(
|
|
951
|
-
stripeSubscription.current_period_end * 1e3
|
|
959
|
+
stripeSubscription.items.data[0]?.current_period_end * 1e3
|
|
952
960
|
),
|
|
953
961
|
periodStart: new Date(
|
|
954
|
-
stripeSubscription.current_period_start * 1e3
|
|
962
|
+
stripeSubscription.items.data[0]?.current_period_start * 1e3
|
|
955
963
|
),
|
|
956
964
|
stripeSubscriptionId: stripeSubscription.id,
|
|
957
965
|
...stripeSubscription.trial_start && stripeSubscription.trial_end ? {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/stripe",
|
|
3
3
|
"author": "Bereket Engida",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.8-beta.2",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -35,18 +35,19 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"zod": "^3.24.1",
|
|
38
|
-
"better-auth": "^1.2.
|
|
38
|
+
"better-auth": "^1.2.8-beta.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/better-sqlite3": "^7.6.12",
|
|
42
|
+
"better-call": "^1.0.8",
|
|
42
43
|
"better-sqlite3": "^11.6.0",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"better-call": "^1.0.8"
|
|
44
|
+
"stripe": "^18.0.0",
|
|
45
|
+
"vitest": "^1.6.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "vitest",
|
|
49
49
|
"build": "unbuild",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
50
51
|
"dev": "unbuild --watch"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/src/hooks.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type GenericEndpointContext, logger } from "better-auth";
|
|
2
2
|
import type Stripe from "stripe";
|
|
3
3
|
import type { InputSubscription, StripeOptions, Subscription } from "./types";
|
|
4
4
|
import { getPlanByPriceId } from "./utils";
|
|
@@ -41,8 +41,12 @@ export async function onCheckoutSessionCompleted(
|
|
|
41
41
|
plan: plan.name.toLowerCase(),
|
|
42
42
|
status: subscription.status,
|
|
43
43
|
updatedAt: new Date(),
|
|
44
|
-
periodStart: new Date(
|
|
45
|
-
|
|
44
|
+
periodStart: new Date(
|
|
45
|
+
subscription.items.data[0].current_period_start * 1000,
|
|
46
|
+
),
|
|
47
|
+
periodEnd: new Date(
|
|
48
|
+
subscription.items.data[0].current_period_end * 1000,
|
|
49
|
+
),
|
|
46
50
|
stripeSubscriptionId: checkoutSession.subscription as string,
|
|
47
51
|
seats,
|
|
48
52
|
...trial,
|
|
@@ -112,7 +116,8 @@ export async function onSubscriptionUpdated(
|
|
|
112
116
|
});
|
|
113
117
|
if (subs.length > 1) {
|
|
114
118
|
const activeSub = subs.find(
|
|
115
|
-
(sub) =>
|
|
119
|
+
(sub: Subscription) =>
|
|
120
|
+
sub.status === "active" || sub.status === "trialing",
|
|
116
121
|
);
|
|
117
122
|
if (!activeSub) {
|
|
118
123
|
logger.warn(
|
|
@@ -138,8 +143,12 @@ export async function onSubscriptionUpdated(
|
|
|
138
143
|
: {}),
|
|
139
144
|
updatedAt: new Date(),
|
|
140
145
|
status: subscriptionUpdated.status,
|
|
141
|
-
periodStart: new Date(
|
|
142
|
-
|
|
146
|
+
periodStart: new Date(
|
|
147
|
+
subscriptionUpdated.items.data[0].current_period_start * 1000,
|
|
148
|
+
),
|
|
149
|
+
periodEnd: new Date(
|
|
150
|
+
subscriptionUpdated.items.data[0].current_period_end * 1000,
|
|
151
|
+
),
|
|
143
152
|
cancelAtPeriodEnd: subscriptionUpdated.cancel_at_period_end,
|
|
144
153
|
seats,
|
|
145
154
|
stripeSubscriptionId: subscriptionUpdated.id,
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import type {
|
|
|
22
22
|
Customer,
|
|
23
23
|
InputSubscription,
|
|
24
24
|
StripeOptions,
|
|
25
|
+
StripePlan,
|
|
25
26
|
Subscription,
|
|
26
27
|
} from "./types";
|
|
27
28
|
import { getPlanByName, getPlanByPriceId, getPlans } from "./utils";
|
|
@@ -145,12 +146,12 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
145
146
|
})
|
|
146
147
|
.optional(),
|
|
147
148
|
/**
|
|
148
|
-
* Success
|
|
149
|
+
* Success URL to redirect back after successful subscription
|
|
149
150
|
*/
|
|
150
151
|
successUrl: z
|
|
151
152
|
.string({
|
|
152
153
|
description:
|
|
153
|
-
"
|
|
154
|
+
"Callback URL to redirect back after successful subscription",
|
|
154
155
|
})
|
|
155
156
|
.default("/"),
|
|
156
157
|
/**
|
|
@@ -159,7 +160,7 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
159
160
|
cancelUrl: z
|
|
160
161
|
.string({
|
|
161
162
|
description:
|
|
162
|
-
"
|
|
163
|
+
"Callback URL to redirect back after successful subscription",
|
|
163
164
|
})
|
|
164
165
|
.default("/"),
|
|
165
166
|
/**
|
|
@@ -831,10 +832,12 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
831
832
|
seats: stripeSubscription.items.data[0]?.quantity || 1,
|
|
832
833
|
plan: plan.name.toLowerCase(),
|
|
833
834
|
periodEnd: new Date(
|
|
834
|
-
stripeSubscription.current_period_end *
|
|
835
|
+
stripeSubscription.items.data[0]?.current_period_end *
|
|
836
|
+
1000,
|
|
835
837
|
),
|
|
836
838
|
periodStart: new Date(
|
|
837
|
-
stripeSubscription.current_period_start *
|
|
839
|
+
stripeSubscription.items.data[0]?.current_period_start *
|
|
840
|
+
1000,
|
|
838
841
|
),
|
|
839
842
|
stripeSubscriptionId: stripeSubscription.id,
|
|
840
843
|
...(stripeSubscription.trial_start &&
|
|
@@ -993,4 +996,4 @@ export const stripe = <O extends StripeOptions>(options: O) => {
|
|
|
993
996
|
} satisfies BetterAuthPlugin;
|
|
994
997
|
};
|
|
995
998
|
|
|
996
|
-
export type { Subscription };
|
|
999
|
+
export type { Subscription, StripePlan };
|