@better-auth/stripe 1.5.0-beta.8 → 1.5.0

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/index.d.mts CHANGED
@@ -1,2 +1,519 @@
1
- import { a as SubscriptionOptions, i as Subscription, n as stripe, r as StripePlan, t as StripePlugin } from "./index-BqGWQFAv.mjs";
2
- export { StripePlan, StripePlugin, Subscription, SubscriptionOptions, stripe };
1
+ import { a as StripePlan, c as WithActiveOrganizationId, i as StripeOptions, l as WithStripeCustomerId, n as CustomerType, o as Subscription, r as StripeCtxSession, s as SubscriptionOptions, t as AuthorizeReferenceAction } from "./types-OT6L84x4.mjs";
2
+ import * as better_auth0 from "better-auth";
3
+ import { User } from "better-auth";
4
+ import * as better_call0 from "better-call";
5
+ import * as zod from "zod";
6
+ import Stripe from "stripe";
7
+
8
+ //#region src/index.d.ts
9
+ declare module "@better-auth/core" {
10
+ interface BetterAuthPluginRegistry<AuthOptions, Options> {
11
+ stripe: {
12
+ creator: typeof stripe;
13
+ };
14
+ }
15
+ }
16
+ declare const stripe: <O extends StripeOptions>(options: O) => {
17
+ id: "stripe";
18
+ endpoints: {
19
+ stripeWebhook: better_call0.StrictEndpoint<"/stripe/webhook", {
20
+ method: "POST";
21
+ metadata: {
22
+ openapi: {
23
+ operationId: string;
24
+ };
25
+ scope: "server";
26
+ };
27
+ cloneRequest: true;
28
+ disableBody: true;
29
+ }, {
30
+ success: boolean;
31
+ }>;
32
+ } & (O["subscription"] extends {
33
+ enabled: true;
34
+ } ? {
35
+ upgradeSubscription: better_call0.StrictEndpoint<"/subscription/upgrade", {
36
+ method: "POST";
37
+ body: zod.ZodObject<{
38
+ plan: zod.ZodString;
39
+ annual: zod.ZodOptional<zod.ZodBoolean>;
40
+ referenceId: zod.ZodOptional<zod.ZodString>;
41
+ subscriptionId: zod.ZodOptional<zod.ZodString>;
42
+ customerType: zod.ZodOptional<zod.ZodEnum<{
43
+ user: "user";
44
+ organization: "organization";
45
+ }>>;
46
+ metadata: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
47
+ seats: zod.ZodOptional<zod.ZodNumber>;
48
+ locale: zod.ZodOptional<zod.ZodCustom<Stripe.Checkout.Session.Locale, Stripe.Checkout.Session.Locale>>;
49
+ successUrl: zod.ZodDefault<zod.ZodString>;
50
+ cancelUrl: zod.ZodDefault<zod.ZodString>;
51
+ returnUrl: zod.ZodOptional<zod.ZodString>;
52
+ scheduleAtPeriodEnd: zod.ZodDefault<zod.ZodBoolean>;
53
+ disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
54
+ }, better_auth0.$strip>;
55
+ metadata: {
56
+ openapi: {
57
+ operationId: string;
58
+ };
59
+ };
60
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
61
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
62
+ session: {
63
+ session: Record<string, any> & {
64
+ id: string;
65
+ createdAt: Date;
66
+ updatedAt: Date;
67
+ userId: string;
68
+ expiresAt: Date;
69
+ token: string;
70
+ ipAddress?: string | null | undefined;
71
+ userAgent?: string | null | undefined;
72
+ };
73
+ user: Record<string, any> & {
74
+ id: string;
75
+ createdAt: Date;
76
+ updatedAt: Date;
77
+ email: string;
78
+ emailVerified: boolean;
79
+ name: string;
80
+ image?: string | null | undefined;
81
+ };
82
+ };
83
+ }>)[];
84
+ }>) => Promise<{
85
+ session: StripeCtxSession;
86
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
87
+ }, {
88
+ url: string;
89
+ redirect: boolean;
90
+ } | {
91
+ redirect: boolean;
92
+ id: string;
93
+ object: "checkout.session";
94
+ adaptive_pricing: Stripe.Checkout.Session.AdaptivePricing | null;
95
+ after_expiration: Stripe.Checkout.Session.AfterExpiration | null;
96
+ allow_promotion_codes: boolean | null;
97
+ amount_subtotal: number | null;
98
+ amount_total: number | null;
99
+ automatic_tax: Stripe.Checkout.Session.AutomaticTax;
100
+ billing_address_collection: Stripe.Checkout.Session.BillingAddressCollection | null;
101
+ branding_settings?: Stripe.Checkout.Session.BrandingSettings;
102
+ cancel_url: string | null;
103
+ client_reference_id: string | null;
104
+ client_secret: string | null;
105
+ collected_information: Stripe.Checkout.Session.CollectedInformation | null;
106
+ consent: Stripe.Checkout.Session.Consent | null;
107
+ consent_collection: Stripe.Checkout.Session.ConsentCollection | null;
108
+ created: number;
109
+ currency: string | null;
110
+ currency_conversion: Stripe.Checkout.Session.CurrencyConversion | null;
111
+ custom_fields: Array<Stripe.Checkout.Session.CustomField>;
112
+ custom_text: Stripe.Checkout.Session.CustomText;
113
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer | null;
114
+ customer_account: string | null;
115
+ customer_creation: Stripe.Checkout.Session.CustomerCreation | null;
116
+ customer_details: Stripe.Checkout.Session.CustomerDetails | null;
117
+ customer_email: string | null;
118
+ discounts: Array<Stripe.Checkout.Session.Discount> | null;
119
+ excluded_payment_method_types?: Array<string>;
120
+ expires_at: number;
121
+ invoice: string | Stripe.Invoice | null;
122
+ invoice_creation: Stripe.Checkout.Session.InvoiceCreation | null;
123
+ line_items?: Stripe.ApiList<Stripe.LineItem>;
124
+ livemode: boolean;
125
+ locale: Stripe.Checkout.Session.Locale | null;
126
+ metadata: Stripe.Metadata | null;
127
+ mode: Stripe.Checkout.Session.Mode;
128
+ name_collection?: Stripe.Checkout.Session.NameCollection;
129
+ optional_items?: Array<Stripe.Checkout.Session.OptionalItem> | null;
130
+ origin_context: Stripe.Checkout.Session.OriginContext | null;
131
+ payment_intent: string | Stripe.PaymentIntent | null;
132
+ payment_link: string | Stripe.PaymentLink | null;
133
+ payment_method_collection: Stripe.Checkout.Session.PaymentMethodCollection | null;
134
+ payment_method_configuration_details: Stripe.Checkout.Session.PaymentMethodConfigurationDetails | null;
135
+ payment_method_options: Stripe.Checkout.Session.PaymentMethodOptions | null;
136
+ payment_method_types: Array<string>;
137
+ payment_status: Stripe.Checkout.Session.PaymentStatus;
138
+ permissions: Stripe.Checkout.Session.Permissions | null;
139
+ phone_number_collection?: Stripe.Checkout.Session.PhoneNumberCollection;
140
+ presentment_details?: Stripe.Checkout.Session.PresentmentDetails;
141
+ recovered_from: string | null;
142
+ redirect_on_completion?: Stripe.Checkout.Session.RedirectOnCompletion;
143
+ return_url?: string;
144
+ saved_payment_method_options: Stripe.Checkout.Session.SavedPaymentMethodOptions | null;
145
+ setup_intent: string | Stripe.SetupIntent | null;
146
+ shipping_address_collection: Stripe.Checkout.Session.ShippingAddressCollection | null;
147
+ shipping_cost: Stripe.Checkout.Session.ShippingCost | null;
148
+ shipping_options: Array<Stripe.Checkout.Session.ShippingOption>;
149
+ status: Stripe.Checkout.Session.Status | null;
150
+ submit_type: Stripe.Checkout.Session.SubmitType | null;
151
+ subscription: string | Stripe.Subscription | null;
152
+ success_url: string | null;
153
+ tax_id_collection?: Stripe.Checkout.Session.TaxIdCollection;
154
+ total_details: Stripe.Checkout.Session.TotalDetails | null;
155
+ ui_mode: Stripe.Checkout.Session.UiMode | null;
156
+ url: string | null;
157
+ wallet_options: Stripe.Checkout.Session.WalletOptions | null;
158
+ lastResponse: {
159
+ headers: {
160
+ [key: string]: string;
161
+ };
162
+ requestId: string;
163
+ statusCode: number;
164
+ apiVersion?: string;
165
+ idempotencyKey?: string;
166
+ stripeAccount?: string;
167
+ };
168
+ }>;
169
+ cancelSubscription: better_call0.StrictEndpoint<"/subscription/cancel", {
170
+ method: "POST";
171
+ body: zod.ZodObject<{
172
+ referenceId: zod.ZodOptional<zod.ZodString>;
173
+ subscriptionId: zod.ZodOptional<zod.ZodString>;
174
+ customerType: zod.ZodOptional<zod.ZodEnum<{
175
+ user: "user";
176
+ organization: "organization";
177
+ }>>;
178
+ returnUrl: zod.ZodString;
179
+ disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
180
+ }, better_auth0.$strip>;
181
+ metadata: {
182
+ openapi: {
183
+ operationId: string;
184
+ };
185
+ };
186
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
187
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
188
+ session: {
189
+ session: Record<string, any> & {
190
+ id: string;
191
+ createdAt: Date;
192
+ updatedAt: Date;
193
+ userId: string;
194
+ expiresAt: Date;
195
+ token: string;
196
+ ipAddress?: string | null | undefined;
197
+ userAgent?: string | null | undefined;
198
+ };
199
+ user: Record<string, any> & {
200
+ id: string;
201
+ createdAt: Date;
202
+ updatedAt: Date;
203
+ email: string;
204
+ emailVerified: boolean;
205
+ name: string;
206
+ image?: string | null | undefined;
207
+ };
208
+ };
209
+ }>)[];
210
+ }>) => Promise<{
211
+ session: StripeCtxSession;
212
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
213
+ }, {
214
+ url: string;
215
+ redirect: boolean;
216
+ }>;
217
+ restoreSubscription: better_call0.StrictEndpoint<"/subscription/restore", {
218
+ method: "POST";
219
+ body: zod.ZodObject<{
220
+ referenceId: zod.ZodOptional<zod.ZodString>;
221
+ subscriptionId: zod.ZodOptional<zod.ZodString>;
222
+ customerType: zod.ZodOptional<zod.ZodEnum<{
223
+ user: "user";
224
+ organization: "organization";
225
+ }>>;
226
+ }, better_auth0.$strip>;
227
+ metadata: {
228
+ openapi: {
229
+ operationId: string;
230
+ };
231
+ };
232
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
233
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
234
+ session: {
235
+ session: Record<string, any> & {
236
+ id: string;
237
+ createdAt: Date;
238
+ updatedAt: Date;
239
+ userId: string;
240
+ expiresAt: Date;
241
+ token: string;
242
+ ipAddress?: string | null | undefined;
243
+ userAgent?: string | null | undefined;
244
+ };
245
+ user: Record<string, any> & {
246
+ id: string;
247
+ createdAt: Date;
248
+ updatedAt: Date;
249
+ email: string;
250
+ emailVerified: boolean;
251
+ name: string;
252
+ image?: string | null | undefined;
253
+ };
254
+ };
255
+ }>)[];
256
+ }>) => Promise<{
257
+ session: StripeCtxSession;
258
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
259
+ }, Stripe.Response<Stripe.Subscription>>;
260
+ listActiveSubscriptions: better_call0.StrictEndpoint<"/subscription/list", {
261
+ method: "GET";
262
+ query: zod.ZodOptional<zod.ZodObject<{
263
+ referenceId: zod.ZodOptional<zod.ZodString>;
264
+ customerType: zod.ZodOptional<zod.ZodEnum<{
265
+ user: "user";
266
+ organization: "organization";
267
+ }>>;
268
+ }, better_auth0.$strip>>;
269
+ metadata: {
270
+ openapi: {
271
+ operationId: string;
272
+ };
273
+ };
274
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
275
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
276
+ session: {
277
+ session: Record<string, any> & {
278
+ id: string;
279
+ createdAt: Date;
280
+ updatedAt: Date;
281
+ userId: string;
282
+ expiresAt: Date;
283
+ token: string;
284
+ ipAddress?: string | null | undefined;
285
+ userAgent?: string | null | undefined;
286
+ };
287
+ user: Record<string, any> & {
288
+ id: string;
289
+ createdAt: Date;
290
+ updatedAt: Date;
291
+ email: string;
292
+ emailVerified: boolean;
293
+ name: string;
294
+ image?: string | null | undefined;
295
+ };
296
+ };
297
+ }>)[];
298
+ }>) => Promise<{
299
+ session: StripeCtxSession;
300
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
301
+ }, {
302
+ limits: Record<string, unknown> | undefined;
303
+ priceId: string | undefined;
304
+ id: string;
305
+ plan: string;
306
+ stripeCustomerId?: string | undefined;
307
+ stripeSubscriptionId?: string | undefined;
308
+ trialStart?: Date | undefined;
309
+ trialEnd?: Date | undefined;
310
+ referenceId: string;
311
+ status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "trialing" | "unpaid";
312
+ periodStart?: Date | undefined;
313
+ periodEnd?: Date | undefined;
314
+ cancelAtPeriodEnd?: boolean | undefined;
315
+ cancelAt?: Date | undefined;
316
+ canceledAt?: Date | undefined;
317
+ endedAt?: Date | undefined;
318
+ groupId?: string | undefined;
319
+ seats?: number | undefined;
320
+ billingInterval?: "day" | "week" | "month" | "year" | undefined;
321
+ stripeScheduleId?: string | undefined;
322
+ }[]>;
323
+ subscriptionSuccess: better_call0.StrictEndpoint<"/subscription/success", {
324
+ method: "GET";
325
+ query: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
326
+ metadata: {
327
+ openapi: {
328
+ operationId: string;
329
+ };
330
+ };
331
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>)[];
332
+ }, never>;
333
+ createBillingPortal: better_call0.StrictEndpoint<"/subscription/billing-portal", {
334
+ method: "POST";
335
+ body: zod.ZodObject<{
336
+ locale: zod.ZodOptional<zod.ZodCustom<Stripe.Checkout.Session.Locale, Stripe.Checkout.Session.Locale>>;
337
+ referenceId: zod.ZodOptional<zod.ZodString>;
338
+ customerType: zod.ZodOptional<zod.ZodEnum<{
339
+ user: "user";
340
+ organization: "organization";
341
+ }>>;
342
+ returnUrl: zod.ZodDefault<zod.ZodString>;
343
+ disableRedirect: zod.ZodDefault<zod.ZodBoolean>;
344
+ }, better_auth0.$strip>;
345
+ metadata: {
346
+ openapi: {
347
+ operationId: string;
348
+ };
349
+ };
350
+ use: (((inputContext: better_call0.MiddlewareInputContext<{
351
+ use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
352
+ session: {
353
+ session: Record<string, any> & {
354
+ id: string;
355
+ createdAt: Date;
356
+ updatedAt: Date;
357
+ userId: string;
358
+ expiresAt: Date;
359
+ token: string;
360
+ ipAddress?: string | null | undefined;
361
+ userAgent?: string | null | undefined;
362
+ };
363
+ user: Record<string, any> & {
364
+ id: string;
365
+ createdAt: Date;
366
+ updatedAt: Date;
367
+ email: string;
368
+ emailVerified: boolean;
369
+ name: string;
370
+ image?: string | null | undefined;
371
+ };
372
+ };
373
+ }>)[];
374
+ }>) => Promise<{
375
+ session: StripeCtxSession;
376
+ }>) | ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<void>))[];
377
+ }, {
378
+ url: string;
379
+ redirect: boolean;
380
+ }>;
381
+ } : {});
382
+ init(ctx: better_auth0.AuthContext): {
383
+ options: {
384
+ databaseHooks: {
385
+ user: {
386
+ create: {
387
+ after(user: User & WithStripeCustomerId, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
388
+ };
389
+ update: {
390
+ after(user: User & WithStripeCustomerId, ctx: better_auth0.GenericEndpointContext | null): Promise<void>;
391
+ };
392
+ };
393
+ };
394
+ };
395
+ } | undefined;
396
+ schema: {
397
+ user: {
398
+ fields: {
399
+ stripeCustomerId: {
400
+ type: "string";
401
+ required: false;
402
+ };
403
+ };
404
+ };
405
+ } & (O["subscription"] extends {
406
+ enabled: true;
407
+ } ? {
408
+ subscription: {
409
+ fields: {
410
+ plan: {
411
+ type: "string";
412
+ required: true;
413
+ };
414
+ referenceId: {
415
+ type: "string";
416
+ required: true;
417
+ };
418
+ stripeCustomerId: {
419
+ type: "string";
420
+ required: false;
421
+ };
422
+ stripeSubscriptionId: {
423
+ type: "string";
424
+ required: false;
425
+ };
426
+ status: {
427
+ type: "string";
428
+ defaultValue: string;
429
+ };
430
+ periodStart: {
431
+ type: "date";
432
+ required: false;
433
+ };
434
+ periodEnd: {
435
+ type: "date";
436
+ required: false;
437
+ };
438
+ trialStart: {
439
+ type: "date";
440
+ required: false;
441
+ };
442
+ trialEnd: {
443
+ type: "date";
444
+ required: false;
445
+ };
446
+ cancelAtPeriodEnd: {
447
+ type: "boolean";
448
+ required: false;
449
+ defaultValue: false;
450
+ };
451
+ cancelAt: {
452
+ type: "date";
453
+ required: false;
454
+ };
455
+ canceledAt: {
456
+ type: "date";
457
+ required: false;
458
+ };
459
+ endedAt: {
460
+ type: "date";
461
+ required: false;
462
+ };
463
+ seats: {
464
+ type: "number";
465
+ required: false;
466
+ };
467
+ billingInterval: {
468
+ type: "string";
469
+ required: false;
470
+ };
471
+ stripeScheduleId: {
472
+ type: "string";
473
+ required: false;
474
+ };
475
+ };
476
+ };
477
+ } : {}) & (O["organization"] extends {
478
+ enabled: true;
479
+ } ? {
480
+ organization: {
481
+ fields: {
482
+ stripeCustomerId: {
483
+ type: "string";
484
+ required: false;
485
+ };
486
+ };
487
+ };
488
+ } : {});
489
+ options: NoInfer<O>;
490
+ $ERROR_CODES: {
491
+ UNAUTHORIZED: better_auth0.RawError<"UNAUTHORIZED">;
492
+ INVALID_REQUEST_BODY: better_auth0.RawError<"INVALID_REQUEST_BODY">;
493
+ SUBSCRIPTION_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
494
+ SUBSCRIPTION_PLAN_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
495
+ ALREADY_SUBSCRIBED_PLAN: better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
496
+ REFERENCE_ID_NOT_ALLOWED: better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
497
+ CUSTOMER_NOT_FOUND: better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
498
+ UNABLE_TO_CREATE_CUSTOMER: better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
499
+ UNABLE_TO_CREATE_BILLING_PORTAL: better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
500
+ STRIPE_SIGNATURE_NOT_FOUND: better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
501
+ STRIPE_WEBHOOK_SECRET_NOT_FOUND: better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
502
+ STRIPE_WEBHOOK_ERROR: better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
503
+ FAILED_TO_CONSTRUCT_STRIPE_EVENT: better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
504
+ FAILED_TO_FETCH_PLANS: better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
505
+ EMAIL_VERIFICATION_REQUIRED: better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
506
+ SUBSCRIPTION_NOT_ACTIVE: better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
507
+ SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
508
+ SUBSCRIPTION_NOT_PENDING_CHANGE: better_auth0.RawError<"SUBSCRIPTION_NOT_PENDING_CHANGE">;
509
+ ORGANIZATION_NOT_FOUND: better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
510
+ ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
511
+ AUTHORIZE_REFERENCE_REQUIRED: better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
512
+ ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
513
+ ORGANIZATION_REFERENCE_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
514
+ };
515
+ };
516
+ type StripePlugin<O extends StripeOptions> = ReturnType<typeof stripe<O>>;
517
+ //#endregion
518
+ export { AuthorizeReferenceAction, CustomerType, StripeCtxSession, StripeOptions, StripePlan, StripePlugin, Subscription, SubscriptionOptions, WithActiveOrganizationId, WithStripeCustomerId, stripe };
519
+ //# sourceMappingURL=index.d.mts.map