better-auth-streampay 0.1.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.
@@ -0,0 +1,1583 @@
1
+ import * as better_auth from 'better-auth';
2
+ import { User, UnionToIntersection } from 'better-auth';
3
+ import * as zod_v4_core from 'zod/v4/core';
4
+ import * as zod from 'zod';
5
+ import { z } from 'zod';
6
+ import { ConsumerCreate, ConsumerResponse, PaginationParams, ConsumerListResponse, ConsumerUpdate, CreatePaymentLinkDto, PaymentLinkDetailed, SubscriptionListResponse, SubscriptionDetailed, SubscriptionCancel, FreezeSubscriptionCreateRequest, FreezeSubscriptionBase, InvoiceListResponse, InvoiceDetailed, PaymentListResponse, PaymentResponse } from '@streamsdk/typescript';
7
+
8
+ interface CheckoutOptions {
9
+ /**
10
+ * Optional slug → productId mapping so callers can request
11
+ * `{ slug: "pro" }` instead of hard-coding StreamPay UUIDs.
12
+ */
13
+ products?: StreamPayProduct[] | (() => Promise<StreamPayProduct[]>);
14
+ /** Absolute or site-relative URL StreamPay redirects to on success. */
15
+ successUrl?: string;
16
+ /** Absolute or site-relative URL StreamPay redirects to on failure. */
17
+ failureUrl?: string;
18
+ /** Reject unauthenticated callers and anonymous sessions. */
19
+ authenticatedUsersOnly?: boolean;
20
+ /**
21
+ * Optional static contact-information collection type passed through to
22
+ * StreamPay. Accepts any string StreamPay supports (the API evolves this
23
+ * enum, so we intentionally don't narrow it).
24
+ */
25
+ contactInformationType?: "EMAIL" | "PHONE";
26
+ /** Custom fields forwarded on every created payment link. */
27
+ customFields?: Record<string, unknown>;
28
+ }
29
+ declare const CheckoutBody: z.ZodObject<{
30
+ products: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
31
+ productId: z.ZodString;
32
+ quantity: z.ZodOptional<z.ZodNumber>;
33
+ }, z.core.$strip>>, z.ZodArray<z.ZodString>, z.ZodString]>>;
34
+ slug: z.ZodOptional<z.ZodString>;
35
+ referenceId: z.ZodOptional<z.ZodString>;
36
+ consumerId: z.ZodOptional<z.ZodString>;
37
+ name: z.ZodOptional<z.ZodString>;
38
+ description: z.ZodOptional<z.ZodString>;
39
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
40
+ successUrl: z.ZodOptional<z.ZodString>;
41
+ failureUrl: z.ZodOptional<z.ZodString>;
42
+ maxNumberOfPayments: z.ZodOptional<z.ZodNumber>;
43
+ validUntil: z.ZodOptional<z.ZodString>;
44
+ couponIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
+ redirect: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
46
+ }, z.core.$strip>;
47
+ type CheckoutParams = z.infer<typeof CheckoutBody>;
48
+ declare const checkout: (checkoutOptions?: CheckoutOptions) => (client: StreamPayClient) => {
49
+ checkout: better_auth.StrictEndpoint<"/checkout", {
50
+ method: "POST";
51
+ body: z.ZodObject<{
52
+ products: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
53
+ productId: z.ZodString;
54
+ quantity: z.ZodOptional<z.ZodNumber>;
55
+ }, z.core.$strip>>, z.ZodArray<z.ZodString>, z.ZodString]>>;
56
+ slug: z.ZodOptional<z.ZodString>;
57
+ referenceId: z.ZodOptional<z.ZodString>;
58
+ consumerId: z.ZodOptional<z.ZodString>;
59
+ name: z.ZodOptional<z.ZodString>;
60
+ description: z.ZodOptional<z.ZodString>;
61
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
62
+ successUrl: z.ZodOptional<z.ZodString>;
63
+ failureUrl: z.ZodOptional<z.ZodString>;
64
+ maxNumberOfPayments: z.ZodOptional<z.ZodNumber>;
65
+ validUntil: z.ZodOptional<z.ZodString>;
66
+ couponIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
67
+ redirect: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
68
+ }, z.core.$strip>;
69
+ }, {
70
+ url: string;
71
+ id: string | null;
72
+ redirect: boolean;
73
+ }>;
74
+ };
75
+
76
+ interface PortalOptions {
77
+ /**
78
+ * Maximum pages to scan when falling back to list-based consumer lookup
79
+ * for sessions that predate the plugin's schema extension. Keep this
80
+ * small — the common path should be the stored `streampayConsumerId`.
81
+ */
82
+ consumerLookupMaxPages?: number;
83
+ }
84
+ declare const portal: ({ consumerLookupMaxPages }?: PortalOptions) => (client: StreamPayClient) => {
85
+ state: better_auth.StrictEndpoint<"/consumer/state", {
86
+ method: "GET";
87
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
88
+ session: {
89
+ session: Record<string, any> & {
90
+ id: string;
91
+ createdAt: Date;
92
+ updatedAt: Date;
93
+ userId: string;
94
+ expiresAt: Date;
95
+ token: string;
96
+ ipAddress?: string | null | undefined;
97
+ userAgent?: string | null | undefined;
98
+ };
99
+ user: Record<string, any> & {
100
+ id: string;
101
+ createdAt: Date;
102
+ updatedAt: Date;
103
+ email: string;
104
+ emailVerified: boolean;
105
+ name: string;
106
+ image?: string | null | undefined;
107
+ };
108
+ };
109
+ }>)[];
110
+ }, {
111
+ id?: string;
112
+ name?: string;
113
+ phone_number?: string | null;
114
+ email?: string | null;
115
+ external_id?: string | null;
116
+ consumer?: {
117
+ id?: string | null;
118
+ phone_number?: string | null;
119
+ preferred_language?: string | null;
120
+ };
121
+ iban?: string | null;
122
+ is_deleted?: boolean;
123
+ alias?: string | null;
124
+ created_at?: string;
125
+ branch?: {
126
+ id?: string;
127
+ name?: string;
128
+ };
129
+ comment?: string | null;
130
+ communication_methods?: ("WHATSAPP" | "EMAIL" | "SMS")[];
131
+ preferred_language?: string;
132
+ last_invoice_activity?: {
133
+ id?: string;
134
+ org_invoice_number?: number;
135
+ subcription_id?: string | null;
136
+ };
137
+ }>;
138
+ subscriptions: better_auth.StrictEndpoint<"/consumer/subscriptions/list", {
139
+ method: "GET";
140
+ query: z.ZodOptional<z.ZodObject<{
141
+ page: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
142
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
143
+ }, z.core.$strip>>;
144
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
145
+ session: {
146
+ session: Record<string, any> & {
147
+ id: string;
148
+ createdAt: Date;
149
+ updatedAt: Date;
150
+ userId: string;
151
+ expiresAt: Date;
152
+ token: string;
153
+ ipAddress?: string | null | undefined;
154
+ userAgent?: string | null | undefined;
155
+ };
156
+ user: Record<string, any> & {
157
+ id: string;
158
+ createdAt: Date;
159
+ updatedAt: Date;
160
+ email: string;
161
+ emailVerified: boolean;
162
+ name: string;
163
+ image?: string | null | undefined;
164
+ };
165
+ };
166
+ }>)[];
167
+ }, {
168
+ data: {
169
+ created_at?: string;
170
+ updated_at?: string | null;
171
+ id?: string;
172
+ description?: string | null;
173
+ amount?: string;
174
+ original_amount?: string;
175
+ item_level_discounted_amount?: string;
176
+ coupon_calculation_metadata?: {
177
+ coupons?: {
178
+ coupon_id?: string;
179
+ name?: string;
180
+ is_percentage?: boolean;
181
+ discount_value?: string;
182
+ order?: number;
183
+ amount_before_discount?: string;
184
+ discount_amount?: string;
185
+ amount_after_discount?: string;
186
+ }[];
187
+ };
188
+ remaining_days?: number;
189
+ currency?: string;
190
+ recurring_interval?: "WEEK" | "MONTH" | "QUARTER" | "YEAR";
191
+ recurring_interval_count?: number;
192
+ status?: "INACTIVE" | "ACTIVE" | "EXPIRED" | "CANCELED" | "FROZEN";
193
+ current_period_start?: string;
194
+ current_period_end?: string;
195
+ current_cycle_number?: number;
196
+ cancel_at_period_end?: boolean;
197
+ cancel_at_cycle_number?: number | null;
198
+ started_at?: string | null;
199
+ ended_at?: string | null;
200
+ user_id?: string;
201
+ organization_consumer_id?: string;
202
+ latest_invoice_id?: string | null;
203
+ organization_consumer?: {
204
+ id?: string;
205
+ name?: string;
206
+ alias?: string | null;
207
+ email?: string | null;
208
+ };
209
+ items?: {
210
+ created_at?: string;
211
+ updated_at?: string | null;
212
+ id?: string;
213
+ product_id?: string;
214
+ subscription_id?: string;
215
+ quantity?: number;
216
+ original_amount?: string;
217
+ discounted_amount?: string;
218
+ coupon_calculation_metadata?: {
219
+ coupons?: {
220
+ coupon_id?: string;
221
+ name?: string;
222
+ is_percentage?: boolean;
223
+ discount_value?: string;
224
+ order?: number;
225
+ amount_before_discount?: string;
226
+ discount_amount?: string;
227
+ amount_after_discount?: string;
228
+ }[];
229
+ };
230
+ product?: {
231
+ created_at?: string;
232
+ updated_at?: string | null;
233
+ id?: string;
234
+ name?: string;
235
+ description?: string | null;
236
+ type?: "RECURRING" | "ONE_OFF";
237
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
238
+ recurring_interval_count?: number;
239
+ price?: string;
240
+ currency: "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHE" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VED" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XOF" | "XPF" | "XSU" | "XUA" | "YER" | "ZAR" | "ZMW" | "ZWL";
241
+ is_active?: boolean;
242
+ is_one_time?: boolean;
243
+ is_price_exempt_from_vat?: boolean;
244
+ is_price_inclusive_of_vat?: boolean;
245
+ price_excluding_vat?: string;
246
+ vat_amount?: string;
247
+ is_used_in_finalized_invoice: boolean;
248
+ };
249
+ }[] | null;
250
+ latest_invoice?: {
251
+ created_at?: string;
252
+ updated_at?: string | null;
253
+ id?: string;
254
+ user_id?: string;
255
+ organization_id?: string;
256
+ organization_consumer_id?: string;
257
+ account_id?: string;
258
+ branch_id?: string;
259
+ org_invoice_number?: number;
260
+ description?: string | null;
261
+ total_amount?: string;
262
+ original_amount?: string;
263
+ item_level_discounted_amount?: string;
264
+ total_vat_amount?: string | null;
265
+ total_price_excluding_vat?: string | null;
266
+ coupon_calculation_metadata?: {
267
+ coupons?: {
268
+ coupon_id?: string;
269
+ name?: string;
270
+ is_percentage?: boolean;
271
+ discount_value?: string;
272
+ order?: number;
273
+ amount_before_discount?: string;
274
+ discount_amount?: string;
275
+ amount_after_discount?: string;
276
+ }[];
277
+ };
278
+ currency?: string | null;
279
+ consumer_message?: string | null;
280
+ status?: "CREATED" | "ACCEPTED" | "EXPIRED" | "CANCELED" | "DRAFT" | "SENT" | "REJECTED" | "COMPLETED";
281
+ payment_method?: "OPENBANKING" | "PAYMENTGATEWAY";
282
+ allowed_payment_flow?: "ALL" | "AUTO" | "MANUAL";
283
+ current_payment_flow?: "ALL" | "AUTO" | "MANUAL";
284
+ period_start?: string | null;
285
+ period_end?: string | null;
286
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
287
+ recurring_interval_count?: number | null;
288
+ type?: "RECURRING" | "ONE_OFF" | "ONE_OFF_FUTURE" | "INSTALLMENTS";
289
+ };
290
+ latest_freeze?: {
291
+ created_at?: string;
292
+ updated_at?: string | null;
293
+ id?: string;
294
+ freeze_start_datetime?: string;
295
+ freeze_end_datetime?: string | null;
296
+ notes?: string | null;
297
+ subscription_id?: string;
298
+ invoice_id?: string;
299
+ duration?: number | null;
300
+ };
301
+ override_payment_methods?: {
302
+ visa?: boolean | null;
303
+ mastercard?: boolean | null;
304
+ amex?: boolean | null;
305
+ bank_transfer?: boolean | null;
306
+ installment?: boolean | null;
307
+ qurrah?: boolean | null;
308
+ subscription_auto_renewal?: boolean | null;
309
+ };
310
+ }[];
311
+ pagination: {
312
+ total_count?: number;
313
+ max_page?: number;
314
+ current_page?: number;
315
+ limit?: number;
316
+ has_next_page?: boolean;
317
+ has_previous_page?: boolean;
318
+ } | undefined;
319
+ }>;
320
+ invoices: better_auth.StrictEndpoint<"/consumer/invoices/list", {
321
+ method: "GET";
322
+ query: z.ZodOptional<z.ZodObject<{
323
+ page: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
324
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
325
+ }, z.core.$strip>>;
326
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
327
+ session: {
328
+ session: Record<string, any> & {
329
+ id: string;
330
+ createdAt: Date;
331
+ updatedAt: Date;
332
+ userId: string;
333
+ expiresAt: Date;
334
+ token: string;
335
+ ipAddress?: string | null | undefined;
336
+ userAgent?: string | null | undefined;
337
+ };
338
+ user: Record<string, any> & {
339
+ id: string;
340
+ createdAt: Date;
341
+ updatedAt: Date;
342
+ email: string;
343
+ emailVerified: boolean;
344
+ name: string;
345
+ image?: string | null | undefined;
346
+ };
347
+ };
348
+ }>)[];
349
+ }, {
350
+ data: {
351
+ created_at?: string;
352
+ updated_at?: string | null;
353
+ id?: string;
354
+ user_id?: string;
355
+ organization_id?: string;
356
+ organization_consumer_id?: string;
357
+ account_id?: string;
358
+ branch_id?: string;
359
+ org_invoice_number?: number;
360
+ description?: string | null;
361
+ total_amount?: string;
362
+ original_amount?: string;
363
+ item_level_discounted_amount?: string;
364
+ total_vat_amount?: string | null;
365
+ total_price_excluding_vat?: string | null;
366
+ coupon_calculation_metadata?: {
367
+ coupons?: {
368
+ coupon_id?: string;
369
+ name?: string;
370
+ is_percentage?: boolean;
371
+ discount_value?: string;
372
+ order?: number;
373
+ amount_before_discount?: string;
374
+ discount_amount?: string;
375
+ amount_after_discount?: string;
376
+ }[];
377
+ };
378
+ currency?: string | null;
379
+ consumer_message?: string | null;
380
+ status?: "CREATED" | "ACCEPTED" | "EXPIRED" | "CANCELED" | "DRAFT" | "SENT" | "REJECTED" | "COMPLETED";
381
+ payment_method?: "OPENBANKING" | "PAYMENTGATEWAY";
382
+ allowed_payment_flow?: "ALL" | "AUTO" | "MANUAL";
383
+ current_payment_flow?: "ALL" | "AUTO" | "MANUAL";
384
+ period_start?: string | null;
385
+ period_end?: string | null;
386
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
387
+ recurring_interval_count?: number | null;
388
+ type?: "RECURRING" | "ONE_OFF" | "ONE_OFF_FUTURE" | "INSTALLMENTS";
389
+ remaining_amount?: string | null;
390
+ paid_amount?: string;
391
+ organization_consumer?: {
392
+ id?: string;
393
+ name?: string;
394
+ alias?: string | null;
395
+ email?: string | null;
396
+ phone_number?: string | null;
397
+ preferred_language?: "AR" | "EN";
398
+ consumer?: {
399
+ id?: string;
400
+ phone_number?: string | null;
401
+ email?: string | null;
402
+ preferred_language?: "AR" | "EN";
403
+ };
404
+ is_deleted?: boolean | null;
405
+ communication_methods?: ("WHATSAPP" | "EMAIL" | "SMS")[] | null;
406
+ };
407
+ subscription?: {
408
+ id?: string;
409
+ recurring_interval?: "WEEK" | "MONTH" | "QUARTER" | "YEAR";
410
+ recurring_interval_count?: number;
411
+ status?: "INACTIVE" | "ACTIVE" | "EXPIRED" | "CANCELED" | "FROZEN";
412
+ current_period_start?: string;
413
+ current_period_end?: string | null;
414
+ cancel_at_period_end?: boolean;
415
+ };
416
+ payments?: {
417
+ id?: string;
418
+ amount?: string;
419
+ currency?: string;
420
+ scheduled_on?: string;
421
+ invoice_payment_number?: number;
422
+ type?: "INITIAL" | "INSTALLMENT" | "SPLIT_PREPAID";
423
+ payment_method?: "MADA" | "MASTERCARD" | "VISA" | "APPLE_PAY" | "SAMSUNG_PAY" | "AMEX" | "CASH" | "PGW_CARD_UNSPECIFIED" | "BANK_TRANSFER" | "CARD" | "QURRAH";
424
+ current_status?: "EXPIRED" | "CANCELED" | "PENDING" | "PROCESSING" | "FAILED_INITIATION" | "SUCCEEDED" | "FAILED" | "UNDER_REVIEW" | "SETTLED" | "REFUNDED";
425
+ payed_at?: string | null;
426
+ settled_at?: string | null;
427
+ refunded_at?: string | null;
428
+ pdf_link?: string | null;
429
+ paid_to_account_id?: string | null;
430
+ }[] | null;
431
+ total_number_of_payments?: number;
432
+ last_payment_paid_at?: string | null;
433
+ }[];
434
+ pagination: {
435
+ total_count?: number;
436
+ max_page?: number;
437
+ current_page?: number;
438
+ limit?: number;
439
+ has_next_page?: boolean;
440
+ has_previous_page?: boolean;
441
+ } | undefined;
442
+ }>;
443
+ payments: better_auth.StrictEndpoint<"/consumer/payments/list", {
444
+ method: "GET";
445
+ query: z.ZodOptional<z.ZodObject<{
446
+ page: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
447
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
448
+ invoiceId: z.ZodOptional<z.ZodString>;
449
+ }, z.core.$strip>>;
450
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
451
+ session: {
452
+ session: Record<string, any> & {
453
+ id: string;
454
+ createdAt: Date;
455
+ updatedAt: Date;
456
+ userId: string;
457
+ expiresAt: Date;
458
+ token: string;
459
+ ipAddress?: string | null | undefined;
460
+ userAgent?: string | null | undefined;
461
+ };
462
+ user: Record<string, any> & {
463
+ id: string;
464
+ createdAt: Date;
465
+ updatedAt: Date;
466
+ email: string;
467
+ emailVerified: boolean;
468
+ name: string;
469
+ image?: string | null | undefined;
470
+ };
471
+ };
472
+ }>)[];
473
+ }, {
474
+ data?: {
475
+ id?: string;
476
+ amount?: string;
477
+ scheduled_on?: string;
478
+ type?: "INITIAL" | "INSTALLMENT" | "SPLIT_PREPAID";
479
+ payment_method?: "MADA" | "MASTERCARD" | "VISA" | "APPLE_PAY" | "SAMSUNG_PAY" | "AMEX" | "CASH" | "PGW_CARD_UNSPECIFIED" | "BANK_TRANSFER" | "CARD" | "QURRAH";
480
+ current_status?: "EXPIRED" | "CANCELED" | "PENDING" | "PROCESSING" | "FAILED_INITIATION" | "SUCCEEDED" | "FAILED" | "UNDER_REVIEW" | "SETTLED" | "REFUNDED";
481
+ payed_at?: string | null;
482
+ refunded_at?: string | null;
483
+ refund_reason?: "REQUESTED_BY_CUSTOMER" | "DUPLICATE" | "FRAUDULENT" | "OTHER";
484
+ refund_note?: string | null;
485
+ }[];
486
+ pagination?: {
487
+ total_count?: number;
488
+ max_page?: number;
489
+ current_page?: number;
490
+ limit?: number;
491
+ has_next_page?: boolean;
492
+ has_previous_page?: boolean;
493
+ };
494
+ }>;
495
+ };
496
+
497
+ interface SubscriptionsOptions {
498
+ consumerLookupMaxPages?: number;
499
+ }
500
+ declare const subscriptions: ({ consumerLookupMaxPages }?: SubscriptionsOptions) => (client: StreamPayClient) => {
501
+ cancelSubscription: better_auth.StrictEndpoint<"/consumer/subscriptions/cancel", {
502
+ method: "POST";
503
+ body: z.ZodObject<{
504
+ subscriptionId: z.ZodString;
505
+ cancelRelatedInvoices: z.ZodOptional<z.ZodBoolean>;
506
+ }, z.core.$strip>;
507
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
508
+ session: {
509
+ session: Record<string, any> & {
510
+ id: string;
511
+ createdAt: Date;
512
+ updatedAt: Date;
513
+ userId: string;
514
+ expiresAt: Date;
515
+ token: string;
516
+ ipAddress?: string | null | undefined;
517
+ userAgent?: string | null | undefined;
518
+ };
519
+ user: Record<string, any> & {
520
+ id: string;
521
+ createdAt: Date;
522
+ updatedAt: Date;
523
+ email: string;
524
+ emailVerified: boolean;
525
+ name: string;
526
+ image?: string | null | undefined;
527
+ };
528
+ };
529
+ }>)[];
530
+ }, {
531
+ created_at?: string;
532
+ updated_at?: string | null;
533
+ id?: string;
534
+ description?: string | null;
535
+ amount?: string;
536
+ original_amount?: string;
537
+ item_level_discounted_amount?: string;
538
+ coupon_calculation_metadata?: {
539
+ coupons?: {
540
+ coupon_id?: string;
541
+ name?: string;
542
+ is_percentage?: boolean;
543
+ discount_value?: string;
544
+ order?: number;
545
+ amount_before_discount?: string;
546
+ discount_amount?: string;
547
+ amount_after_discount?: string;
548
+ }[];
549
+ };
550
+ remaining_days?: number;
551
+ currency?: string;
552
+ recurring_interval?: "WEEK" | "MONTH" | "QUARTER" | "YEAR";
553
+ recurring_interval_count?: number;
554
+ status?: "INACTIVE" | "ACTIVE" | "EXPIRED" | "CANCELED" | "FROZEN";
555
+ current_period_start?: string;
556
+ current_period_end?: string;
557
+ current_cycle_number?: number;
558
+ cancel_at_period_end?: boolean;
559
+ cancel_at_cycle_number?: number | null;
560
+ started_at?: string | null;
561
+ ended_at?: string | null;
562
+ user_id?: string;
563
+ organization_consumer_id?: string;
564
+ latest_invoice_id?: string | null;
565
+ organization_consumer?: {
566
+ id?: string;
567
+ name?: string;
568
+ alias?: string | null;
569
+ email?: string | null;
570
+ };
571
+ items?: {
572
+ created_at?: string;
573
+ updated_at?: string | null;
574
+ id?: string;
575
+ product_id?: string;
576
+ subscription_id?: string;
577
+ quantity?: number;
578
+ original_amount?: string;
579
+ discounted_amount?: string;
580
+ coupon_calculation_metadata?: {
581
+ coupons?: {
582
+ coupon_id?: string;
583
+ name?: string;
584
+ is_percentage?: boolean;
585
+ discount_value?: string;
586
+ order?: number;
587
+ amount_before_discount?: string;
588
+ discount_amount?: string;
589
+ amount_after_discount?: string;
590
+ }[];
591
+ };
592
+ product?: {
593
+ created_at?: string;
594
+ updated_at?: string | null;
595
+ id?: string;
596
+ name?: string;
597
+ description?: string | null;
598
+ type?: "RECURRING" | "ONE_OFF";
599
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
600
+ recurring_interval_count?: number;
601
+ price?: string;
602
+ currency: "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHE" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VED" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XOF" | "XPF" | "XSU" | "XUA" | "YER" | "ZAR" | "ZMW" | "ZWL";
603
+ is_active?: boolean;
604
+ is_one_time?: boolean;
605
+ is_price_exempt_from_vat?: boolean;
606
+ is_price_inclusive_of_vat?: boolean;
607
+ price_excluding_vat?: string;
608
+ vat_amount?: string;
609
+ is_used_in_finalized_invoice: boolean;
610
+ };
611
+ }[] | null;
612
+ latest_invoice?: {
613
+ created_at?: string;
614
+ updated_at?: string | null;
615
+ id?: string;
616
+ user_id?: string;
617
+ organization_id?: string;
618
+ organization_consumer_id?: string;
619
+ account_id?: string;
620
+ branch_id?: string;
621
+ org_invoice_number?: number;
622
+ description?: string | null;
623
+ total_amount?: string;
624
+ original_amount?: string;
625
+ item_level_discounted_amount?: string;
626
+ total_vat_amount?: string | null;
627
+ total_price_excluding_vat?: string | null;
628
+ coupon_calculation_metadata?: {
629
+ coupons?: {
630
+ coupon_id?: string;
631
+ name?: string;
632
+ is_percentage?: boolean;
633
+ discount_value?: string;
634
+ order?: number;
635
+ amount_before_discount?: string;
636
+ discount_amount?: string;
637
+ amount_after_discount?: string;
638
+ }[];
639
+ };
640
+ currency?: string | null;
641
+ consumer_message?: string | null;
642
+ status?: "CREATED" | "ACCEPTED" | "EXPIRED" | "CANCELED" | "DRAFT" | "SENT" | "REJECTED" | "COMPLETED";
643
+ payment_method?: "OPENBANKING" | "PAYMENTGATEWAY";
644
+ allowed_payment_flow?: "ALL" | "AUTO" | "MANUAL";
645
+ current_payment_flow?: "ALL" | "AUTO" | "MANUAL";
646
+ period_start?: string | null;
647
+ period_end?: string | null;
648
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
649
+ recurring_interval_count?: number | null;
650
+ type?: "RECURRING" | "ONE_OFF" | "ONE_OFF_FUTURE" | "INSTALLMENTS";
651
+ };
652
+ latest_freeze?: {
653
+ created_at?: string;
654
+ updated_at?: string | null;
655
+ id?: string;
656
+ freeze_start_datetime?: string;
657
+ freeze_end_datetime?: string | null;
658
+ notes?: string | null;
659
+ subscription_id?: string;
660
+ invoice_id?: string;
661
+ duration?: number | null;
662
+ };
663
+ override_payment_methods?: {
664
+ visa?: boolean | null;
665
+ mastercard?: boolean | null;
666
+ amex?: boolean | null;
667
+ bank_transfer?: boolean | null;
668
+ installment?: boolean | null;
669
+ qurrah?: boolean | null;
670
+ subscription_auto_renewal?: boolean | null;
671
+ };
672
+ }>;
673
+ freezeSubscription: better_auth.StrictEndpoint<"/consumer/subscriptions/freeze", {
674
+ method: "POST";
675
+ body: z.ZodObject<{
676
+ subscriptionId: z.ZodString;
677
+ freezeStartDatetime: z.ZodString;
678
+ freezeEndDatetime: z.ZodOptional<z.ZodNullable<z.ZodString>>;
679
+ notes: z.ZodOptional<z.ZodString>;
680
+ }, z.core.$strip>;
681
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
682
+ session: {
683
+ session: Record<string, any> & {
684
+ id: string;
685
+ createdAt: Date;
686
+ updatedAt: Date;
687
+ userId: string;
688
+ expiresAt: Date;
689
+ token: string;
690
+ ipAddress?: string | null | undefined;
691
+ userAgent?: string | null | undefined;
692
+ };
693
+ user: Record<string, any> & {
694
+ id: string;
695
+ createdAt: Date;
696
+ updatedAt: Date;
697
+ email: string;
698
+ emailVerified: boolean;
699
+ name: string;
700
+ image?: string | null | undefined;
701
+ };
702
+ };
703
+ }>)[];
704
+ }, {
705
+ created_at?: string;
706
+ updated_at?: string | null;
707
+ id?: string;
708
+ freeze_start_datetime?: string;
709
+ freeze_end_datetime?: string | null;
710
+ notes?: string | null;
711
+ subscription_id?: string;
712
+ invoice_id?: string;
713
+ duration?: number | null;
714
+ }>;
715
+ };
716
+
717
+ /**
718
+ * Canonical StreamPay webhook event type list. Kept as a string union
719
+ * rather than an enum so downstream code stays ergonomic.
720
+ *
721
+ * Source: https://docs.streampay.sa/webhooks
722
+ */
723
+ declare const STREAMPAY_EVENT_TYPES: readonly ["PAYMENT_SUCCEEDED", "PAYMENT_FAILED", "PAYMENT_CANCELED", "PAYMENT_REFUNDED", "PAYMENT_MARKED_AS_PAID", "INVOICE_CREATED", "INVOICE_SENT", "INVOICE_ACCEPTED", "INVOICE_REJECTED", "INVOICE_COMPLETED", "INVOICE_CANCELED", "INVOICE_UPDATED", "SUBSCRIPTION_CREATED", "SUBSCRIPTION_ACTIVATED", "SUBSCRIPTION_INACTIVATED", "SUBSCRIPTION_CANCELED", "SUBSCRIPTION_FROZEN", "SUBSCRIPTION_CYCLE_RENEWAL_FAILED", "SUBSCRIPTION_CANCEL_AT_PERIOD_END", "SUBSCRIPTION_FREEZE_NOW", "SUBSCRIPTION_UNFREEZE_NOW", "SUBSCRIPTION_UNFREEZE_FUTURE", "SUBSCRIPTION_FREEZE_CANCEL", "PAYMENT_LINK_PAY_ATTEMPT_FAILED"];
724
+ type StreamPayEventType = (typeof STREAMPAY_EVENT_TYPES)[number];
725
+ type StreamPayEntityType = "PAYMENT" | "INVOICE" | "SUBSCRIPTION" | "PAYMENT_LINK";
726
+ interface StreamPayWebhookPayload<T = Record<string, unknown>> {
727
+ event_type: StreamPayEventType;
728
+ entity_type: StreamPayEntityType;
729
+ entity_id: string;
730
+ entity_url: string;
731
+ status: string;
732
+ data: T;
733
+ timestamp: string;
734
+ }
735
+
736
+ type WebhookHandler<T = Record<string, unknown>> = (payload: StreamPayWebhookPayload<T>) => Promise<void> | void;
737
+ interface WebhookHandlers {
738
+ onPayload?: WebhookHandler;
739
+ onPaymentSucceeded?: WebhookHandler;
740
+ onPaymentFailed?: WebhookHandler;
741
+ onPaymentCanceled?: WebhookHandler;
742
+ onPaymentRefunded?: WebhookHandler;
743
+ onPaymentMarkedAsPaid?: WebhookHandler;
744
+ onInvoiceCreated?: WebhookHandler;
745
+ onInvoiceSent?: WebhookHandler;
746
+ onInvoiceAccepted?: WebhookHandler;
747
+ onInvoiceRejected?: WebhookHandler;
748
+ onInvoiceCompleted?: WebhookHandler;
749
+ onInvoiceCanceled?: WebhookHandler;
750
+ onInvoiceUpdated?: WebhookHandler;
751
+ onSubscriptionCreated?: WebhookHandler;
752
+ onSubscriptionActivated?: WebhookHandler;
753
+ onSubscriptionInactivated?: WebhookHandler;
754
+ onSubscriptionCanceled?: WebhookHandler;
755
+ onSubscriptionFrozen?: WebhookHandler;
756
+ onSubscriptionCycleRenewalFailed?: WebhookHandler;
757
+ onSubscriptionCancelAtPeriodEnd?: WebhookHandler;
758
+ onSubscriptionFreezeNow?: WebhookHandler;
759
+ onSubscriptionUnfreezeNow?: WebhookHandler;
760
+ onSubscriptionUnfreezeFuture?: WebhookHandler;
761
+ onSubscriptionFreezeCancel?: WebhookHandler;
762
+ onPaymentLinkPayAttemptFailed?: WebhookHandler;
763
+ }
764
+ /**
765
+ * Fan out a webhook payload to the registered handlers. `onPayload` is
766
+ * always invoked first so "catch-all" use-cases (audit logs, fan-out
767
+ * queues) stay reliable even when a specific handler is missing.
768
+ */
769
+ declare function dispatchWebhook(payload: StreamPayWebhookPayload, handlers: WebhookHandlers): Promise<void>;
770
+
771
+ interface WebhooksOptions extends WebhookHandlers {
772
+ /** Shared secret configured in the StreamPay dashboard. */
773
+ secret: string;
774
+ /** Maximum age (seconds) a signed payload is considered fresh. */
775
+ toleranceSeconds?: number;
776
+ }
777
+ declare const webhooks: (options: WebhooksOptions) => (_client: StreamPayClient) => {
778
+ streampayWebhooks: better_auth.StrictEndpoint<"/streampay/webhooks", {
779
+ method: "POST";
780
+ metadata: {
781
+ isAction: false;
782
+ };
783
+ cloneRequest: true;
784
+ }, {
785
+ received: boolean;
786
+ }>;
787
+ };
788
+
789
+ /**
790
+ * The subset of the StreamPay SDK client this plugin actually touches.
791
+ * We intentionally re-declare it as an interface (rather than importing
792
+ * `StreamClient` from `@streamsdk/typescript`) because the SDK does not
793
+ * currently export the class type. Declaring the contract here also lets
794
+ * advanced users swap in a custom implementation (a mock, an HTTP client
795
+ * they control, a future fork) without us caring where it came from.
796
+ *
797
+ * Every method signature below matches `@streamsdk/typescript@1.0.6`
798
+ * exactly; we deliberately do NOT widen the parameter types, so when the
799
+ * SDK tightens its DTOs our plugin inherits the improvement for free.
800
+ */
801
+ interface StreamPayClient {
802
+ createConsumer(input: ConsumerCreate): Promise<ConsumerResponse>;
803
+ listConsumers(params?: PaginationParams): Promise<ConsumerListResponse>;
804
+ getConsumer(consumerId: string): Promise<ConsumerResponse>;
805
+ updateConsumer(consumerId: string, input: ConsumerUpdate): Promise<ConsumerResponse>;
806
+ deleteConsumer(consumerId: string): Promise<void>;
807
+ createPaymentLink(input: CreatePaymentLinkDto): Promise<PaymentLinkDetailed>;
808
+ getPaymentUrl(link: PaymentLinkDetailed): string | null;
809
+ listSubscriptions(params?: PaginationParams): Promise<SubscriptionListResponse>;
810
+ getSubscription(subscriptionId: string): Promise<SubscriptionDetailed>;
811
+ cancelSubscription(subscriptionId: string, input?: SubscriptionCancel): Promise<SubscriptionDetailed>;
812
+ freezeSubscription(subscriptionId: string, input: FreezeSubscriptionCreateRequest): Promise<FreezeSubscriptionBase>;
813
+ listInvoices(params?: PaginationParams): Promise<InvoiceListResponse>;
814
+ getInvoice(invoiceId: string): Promise<InvoiceDetailed>;
815
+ listPayments(params?: {
816
+ invoice_id?: string;
817
+ }): Promise<PaymentListResponse>;
818
+ getPayment(paymentId: string): Promise<PaymentResponse>;
819
+ }
820
+ interface StreamPayProduct {
821
+ productId: string;
822
+ slug: string;
823
+ }
824
+ type StreamPayPlugin = ReturnType<typeof checkout> | ReturnType<typeof portal> | ReturnType<typeof subscriptions> | ReturnType<typeof webhooks>;
825
+ /**
826
+ * Readonly array of sub-plugins. An empty array is valid — a user who
827
+ * wants nothing but `createConsumerOnSignUp` consumer sync can pass
828
+ * `use: []` and skip checkout/portal/subscriptions/webhooks entirely.
829
+ */
830
+ type StreamPayPlugins = readonly StreamPayPlugin[];
831
+ type StreamPayEndpoints = UnionToIntersection<ReturnType<StreamPayPlugin>>;
832
+ interface ConsumerCreateOverrides {
833
+ phone_number?: string;
834
+ alias?: string;
835
+ comment?: string;
836
+ preferred_language?: string;
837
+ iban?: string;
838
+ communication_methods?: ("WHATSAPP" | "EMAIL" | "SMS")[];
839
+ }
840
+ interface StreamPayOptions {
841
+ /**
842
+ * An initialized StreamPay SDK client (from `@streamsdk/typescript`,
843
+ * or any value that satisfies `StreamPayClient`). The plugin never
844
+ * touches credentials directly — you own the client.
845
+ */
846
+ client: StreamPayClient;
847
+ /**
848
+ * When `true`, a StreamPay consumer is created on sign-up with
849
+ * `external_id: user.id`. The resulting consumer id is written back
850
+ * onto the Better Auth user row as `streampayConsumerId`.
851
+ */
852
+ createConsumerOnSignUp?: boolean;
853
+ /**
854
+ * Provide StreamPay-specific consumer fields at creation time
855
+ * (phone, preferred language, VAT number, etc.). Runs inside a
856
+ * database hook, so it must resolve quickly.
857
+ */
858
+ getConsumerCreateParams?: (data: {
859
+ user: Partial<User>;
860
+ }, request?: Request) => Promise<ConsumerCreateOverrides> | ConsumerCreateOverrides;
861
+ /** Sub-plugins composed into the main `streampay()` plugin. */
862
+ use: StreamPayPlugins;
863
+ }
864
+
865
+ /**
866
+ * The narrow context shape the plugin's hooks actually read. Declared
867
+ * as a structural supertype of Better Auth's `GenericEndpointContext`
868
+ * so tests can pass a `MockCtx` without any cast.
869
+ *
870
+ * The hooks only need a logger now — consumer creation moved to the
871
+ * `before` hook and injects `streampayConsumerId` into the row via the
872
+ * hook's return value, so we no longer call `internalAdapter.updateUser`
873
+ * from the `after` hook.
874
+ */
875
+ interface StreamPayHookContext {
876
+ context: {
877
+ logger: {
878
+ error: (message: string) => void;
879
+ };
880
+ };
881
+ }
882
+
883
+ declare const streampay: <O extends StreamPayOptions>(options: O) => {
884
+ id: "streampay";
885
+ endpoints: {
886
+ checkout: better_auth.StrictEndpoint<"/checkout", {
887
+ method: "POST";
888
+ body: zod.ZodObject<{
889
+ products: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodArray<zod.ZodObject<{
890
+ productId: zod.ZodString;
891
+ quantity: zod.ZodOptional<zod.ZodNumber>;
892
+ }, zod_v4_core.$strip>>, zod.ZodArray<zod.ZodString>, zod.ZodString]>>;
893
+ slug: zod.ZodOptional<zod.ZodString>;
894
+ referenceId: zod.ZodOptional<zod.ZodString>;
895
+ consumerId: zod.ZodOptional<zod.ZodString>;
896
+ name: zod.ZodOptional<zod.ZodString>;
897
+ description: zod.ZodOptional<zod.ZodString>;
898
+ metadata: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>>>;
899
+ successUrl: zod.ZodOptional<zod.ZodString>;
900
+ failureUrl: zod.ZodOptional<zod.ZodString>;
901
+ maxNumberOfPayments: zod.ZodOptional<zod.ZodNumber>;
902
+ validUntil: zod.ZodOptional<zod.ZodString>;
903
+ couponIds: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
904
+ redirect: zod.ZodOptional<zod.ZodCoercedBoolean<unknown>>;
905
+ }, zod_v4_core.$strip>;
906
+ }, {
907
+ url: string;
908
+ id: string | null;
909
+ redirect: boolean;
910
+ }>;
911
+ } | {
912
+ state: better_auth.StrictEndpoint<"/consumer/state", {
913
+ method: "GET";
914
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
915
+ session: {
916
+ session: Record<string, any> & {
917
+ id: string;
918
+ createdAt: Date;
919
+ updatedAt: Date;
920
+ userId: string;
921
+ expiresAt: Date;
922
+ token: string;
923
+ ipAddress?: string | null | undefined;
924
+ userAgent?: string | null | undefined;
925
+ };
926
+ user: Record<string, any> & {
927
+ id: string;
928
+ createdAt: Date;
929
+ updatedAt: Date;
930
+ email: string;
931
+ emailVerified: boolean;
932
+ name: string;
933
+ image?: string | null | undefined;
934
+ };
935
+ };
936
+ }>)[];
937
+ }, {
938
+ id?: string;
939
+ name?: string;
940
+ phone_number?: string | null;
941
+ email?: string | null;
942
+ external_id?: string | null;
943
+ consumer?: {
944
+ id?: string | null;
945
+ phone_number?: string | null;
946
+ preferred_language?: string | null;
947
+ };
948
+ iban?: string | null;
949
+ is_deleted?: boolean;
950
+ alias?: string | null;
951
+ created_at?: string;
952
+ branch?: {
953
+ id?: string;
954
+ name?: string;
955
+ };
956
+ comment?: string | null;
957
+ communication_methods?: ("WHATSAPP" | "EMAIL" | "SMS")[];
958
+ preferred_language?: string;
959
+ last_invoice_activity?: {
960
+ id?: string;
961
+ org_invoice_number?: number;
962
+ subcription_id?: string | null;
963
+ };
964
+ }>;
965
+ subscriptions: better_auth.StrictEndpoint<"/consumer/subscriptions/list", {
966
+ method: "GET";
967
+ query: zod.ZodOptional<zod.ZodObject<{
968
+ page: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
969
+ limit: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
970
+ }, zod_v4_core.$strip>>;
971
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
972
+ session: {
973
+ session: Record<string, any> & {
974
+ id: string;
975
+ createdAt: Date;
976
+ updatedAt: Date;
977
+ userId: string;
978
+ expiresAt: Date;
979
+ token: string;
980
+ ipAddress?: string | null | undefined;
981
+ userAgent?: string | null | undefined;
982
+ };
983
+ user: Record<string, any> & {
984
+ id: string;
985
+ createdAt: Date;
986
+ updatedAt: Date;
987
+ email: string;
988
+ emailVerified: boolean;
989
+ name: string;
990
+ image?: string | null | undefined;
991
+ };
992
+ };
993
+ }>)[];
994
+ }, {
995
+ data: {
996
+ created_at?: string;
997
+ updated_at?: string | null;
998
+ id?: string;
999
+ description?: string | null;
1000
+ amount?: string;
1001
+ original_amount?: string;
1002
+ item_level_discounted_amount?: string;
1003
+ coupon_calculation_metadata?: {
1004
+ coupons?: {
1005
+ coupon_id?: string;
1006
+ name?: string;
1007
+ is_percentage?: boolean;
1008
+ discount_value?: string;
1009
+ order?: number;
1010
+ amount_before_discount?: string;
1011
+ discount_amount?: string;
1012
+ amount_after_discount?: string;
1013
+ }[];
1014
+ };
1015
+ remaining_days?: number;
1016
+ currency?: string;
1017
+ recurring_interval?: "WEEK" | "MONTH" | "QUARTER" | "YEAR";
1018
+ recurring_interval_count?: number;
1019
+ status?: "INACTIVE" | "ACTIVE" | "EXPIRED" | "CANCELED" | "FROZEN";
1020
+ current_period_start?: string;
1021
+ current_period_end?: string;
1022
+ current_cycle_number?: number;
1023
+ cancel_at_period_end?: boolean;
1024
+ cancel_at_cycle_number?: number | null;
1025
+ started_at?: string | null;
1026
+ ended_at?: string | null;
1027
+ user_id?: string;
1028
+ organization_consumer_id?: string;
1029
+ latest_invoice_id?: string | null;
1030
+ organization_consumer?: {
1031
+ id?: string;
1032
+ name?: string;
1033
+ alias?: string | null;
1034
+ email?: string | null;
1035
+ };
1036
+ items?: {
1037
+ created_at?: string;
1038
+ updated_at?: string | null;
1039
+ id?: string;
1040
+ product_id?: string;
1041
+ subscription_id?: string;
1042
+ quantity?: number;
1043
+ original_amount?: string;
1044
+ discounted_amount?: string;
1045
+ coupon_calculation_metadata?: {
1046
+ coupons?: {
1047
+ coupon_id?: string;
1048
+ name?: string;
1049
+ is_percentage?: boolean;
1050
+ discount_value?: string;
1051
+ order?: number;
1052
+ amount_before_discount?: string;
1053
+ discount_amount?: string;
1054
+ amount_after_discount?: string;
1055
+ }[];
1056
+ };
1057
+ product?: {
1058
+ created_at?: string;
1059
+ updated_at?: string | null;
1060
+ id?: string;
1061
+ name?: string;
1062
+ description?: string | null;
1063
+ type?: "RECURRING" | "ONE_OFF";
1064
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
1065
+ recurring_interval_count?: number;
1066
+ price?: string;
1067
+ currency: "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHE" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VED" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XOF" | "XPF" | "XSU" | "XUA" | "YER" | "ZAR" | "ZMW" | "ZWL";
1068
+ is_active?: boolean;
1069
+ is_one_time?: boolean;
1070
+ is_price_exempt_from_vat?: boolean;
1071
+ is_price_inclusive_of_vat?: boolean;
1072
+ price_excluding_vat?: string;
1073
+ vat_amount?: string;
1074
+ is_used_in_finalized_invoice: boolean;
1075
+ };
1076
+ }[] | null;
1077
+ latest_invoice?: {
1078
+ created_at?: string;
1079
+ updated_at?: string | null;
1080
+ id?: string;
1081
+ user_id?: string;
1082
+ organization_id?: string;
1083
+ organization_consumer_id?: string;
1084
+ account_id?: string;
1085
+ branch_id?: string;
1086
+ org_invoice_number?: number;
1087
+ description?: string | null;
1088
+ total_amount?: string;
1089
+ original_amount?: string;
1090
+ item_level_discounted_amount?: string;
1091
+ total_vat_amount?: string | null;
1092
+ total_price_excluding_vat?: string | null;
1093
+ coupon_calculation_metadata?: {
1094
+ coupons?: {
1095
+ coupon_id?: string;
1096
+ name?: string;
1097
+ is_percentage?: boolean;
1098
+ discount_value?: string;
1099
+ order?: number;
1100
+ amount_before_discount?: string;
1101
+ discount_amount?: string;
1102
+ amount_after_discount?: string;
1103
+ }[];
1104
+ };
1105
+ currency?: string | null;
1106
+ consumer_message?: string | null;
1107
+ status?: "CREATED" | "ACCEPTED" | "EXPIRED" | "CANCELED" | "DRAFT" | "SENT" | "REJECTED" | "COMPLETED";
1108
+ payment_method?: "OPENBANKING" | "PAYMENTGATEWAY";
1109
+ allowed_payment_flow?: "ALL" | "AUTO" | "MANUAL";
1110
+ current_payment_flow?: "ALL" | "AUTO" | "MANUAL";
1111
+ period_start?: string | null;
1112
+ period_end?: string | null;
1113
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
1114
+ recurring_interval_count?: number | null;
1115
+ type?: "RECURRING" | "ONE_OFF" | "ONE_OFF_FUTURE" | "INSTALLMENTS";
1116
+ };
1117
+ latest_freeze?: {
1118
+ created_at?: string;
1119
+ updated_at?: string | null;
1120
+ id?: string;
1121
+ freeze_start_datetime?: string;
1122
+ freeze_end_datetime?: string | null;
1123
+ notes?: string | null;
1124
+ subscription_id?: string;
1125
+ invoice_id?: string;
1126
+ duration?: number | null;
1127
+ };
1128
+ override_payment_methods?: {
1129
+ visa?: boolean | null;
1130
+ mastercard?: boolean | null;
1131
+ amex?: boolean | null;
1132
+ bank_transfer?: boolean | null;
1133
+ installment?: boolean | null;
1134
+ qurrah?: boolean | null;
1135
+ subscription_auto_renewal?: boolean | null;
1136
+ };
1137
+ }[];
1138
+ pagination: {
1139
+ total_count?: number;
1140
+ max_page?: number;
1141
+ current_page?: number;
1142
+ limit?: number;
1143
+ has_next_page?: boolean;
1144
+ has_previous_page?: boolean;
1145
+ } | undefined;
1146
+ }>;
1147
+ invoices: better_auth.StrictEndpoint<"/consumer/invoices/list", {
1148
+ method: "GET";
1149
+ query: zod.ZodOptional<zod.ZodObject<{
1150
+ page: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
1151
+ limit: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
1152
+ }, zod_v4_core.$strip>>;
1153
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1154
+ session: {
1155
+ session: Record<string, any> & {
1156
+ id: string;
1157
+ createdAt: Date;
1158
+ updatedAt: Date;
1159
+ userId: string;
1160
+ expiresAt: Date;
1161
+ token: string;
1162
+ ipAddress?: string | null | undefined;
1163
+ userAgent?: string | null | undefined;
1164
+ };
1165
+ user: Record<string, any> & {
1166
+ id: string;
1167
+ createdAt: Date;
1168
+ updatedAt: Date;
1169
+ email: string;
1170
+ emailVerified: boolean;
1171
+ name: string;
1172
+ image?: string | null | undefined;
1173
+ };
1174
+ };
1175
+ }>)[];
1176
+ }, {
1177
+ data: {
1178
+ created_at?: string;
1179
+ updated_at?: string | null;
1180
+ id?: string;
1181
+ user_id?: string;
1182
+ organization_id?: string;
1183
+ organization_consumer_id?: string;
1184
+ account_id?: string;
1185
+ branch_id?: string;
1186
+ org_invoice_number?: number;
1187
+ description?: string | null;
1188
+ total_amount?: string;
1189
+ original_amount?: string;
1190
+ item_level_discounted_amount?: string;
1191
+ total_vat_amount?: string | null;
1192
+ total_price_excluding_vat?: string | null;
1193
+ coupon_calculation_metadata?: {
1194
+ coupons?: {
1195
+ coupon_id?: string;
1196
+ name?: string;
1197
+ is_percentage?: boolean;
1198
+ discount_value?: string;
1199
+ order?: number;
1200
+ amount_before_discount?: string;
1201
+ discount_amount?: string;
1202
+ amount_after_discount?: string;
1203
+ }[];
1204
+ };
1205
+ currency?: string | null;
1206
+ consumer_message?: string | null;
1207
+ status?: "CREATED" | "ACCEPTED" | "EXPIRED" | "CANCELED" | "DRAFT" | "SENT" | "REJECTED" | "COMPLETED";
1208
+ payment_method?: "OPENBANKING" | "PAYMENTGATEWAY";
1209
+ allowed_payment_flow?: "ALL" | "AUTO" | "MANUAL";
1210
+ current_payment_flow?: "ALL" | "AUTO" | "MANUAL";
1211
+ period_start?: string | null;
1212
+ period_end?: string | null;
1213
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
1214
+ recurring_interval_count?: number | null;
1215
+ type?: "RECURRING" | "ONE_OFF" | "ONE_OFF_FUTURE" | "INSTALLMENTS";
1216
+ remaining_amount?: string | null;
1217
+ paid_amount?: string;
1218
+ organization_consumer?: {
1219
+ id?: string;
1220
+ name?: string;
1221
+ alias?: string | null;
1222
+ email?: string | null;
1223
+ phone_number?: string | null;
1224
+ preferred_language?: "AR" | "EN";
1225
+ consumer?: {
1226
+ id?: string;
1227
+ phone_number?: string | null;
1228
+ email?: string | null;
1229
+ preferred_language?: "AR" | "EN";
1230
+ };
1231
+ is_deleted?: boolean | null;
1232
+ communication_methods?: ("WHATSAPP" | "EMAIL" | "SMS")[] | null;
1233
+ };
1234
+ subscription?: {
1235
+ id?: string;
1236
+ recurring_interval?: "WEEK" | "MONTH" | "QUARTER" | "YEAR";
1237
+ recurring_interval_count?: number;
1238
+ status?: "INACTIVE" | "ACTIVE" | "EXPIRED" | "CANCELED" | "FROZEN";
1239
+ current_period_start?: string;
1240
+ current_period_end?: string | null;
1241
+ cancel_at_period_end?: boolean;
1242
+ };
1243
+ payments?: {
1244
+ id?: string;
1245
+ amount?: string;
1246
+ currency?: string;
1247
+ scheduled_on?: string;
1248
+ invoice_payment_number?: number;
1249
+ type?: "INITIAL" | "INSTALLMENT" | "SPLIT_PREPAID";
1250
+ payment_method?: "MADA" | "MASTERCARD" | "VISA" | "APPLE_PAY" | "SAMSUNG_PAY" | "AMEX" | "CASH" | "PGW_CARD_UNSPECIFIED" | "BANK_TRANSFER" | "CARD" | "QURRAH";
1251
+ current_status?: "EXPIRED" | "CANCELED" | "PENDING" | "PROCESSING" | "FAILED_INITIATION" | "SUCCEEDED" | "FAILED" | "UNDER_REVIEW" | "SETTLED" | "REFUNDED";
1252
+ payed_at?: string | null;
1253
+ settled_at?: string | null;
1254
+ refunded_at?: string | null;
1255
+ pdf_link?: string | null;
1256
+ paid_to_account_id?: string | null;
1257
+ }[] | null;
1258
+ total_number_of_payments?: number;
1259
+ last_payment_paid_at?: string | null;
1260
+ }[];
1261
+ pagination: {
1262
+ total_count?: number;
1263
+ max_page?: number;
1264
+ current_page?: number;
1265
+ limit?: number;
1266
+ has_next_page?: boolean;
1267
+ has_previous_page?: boolean;
1268
+ } | undefined;
1269
+ }>;
1270
+ payments: better_auth.StrictEndpoint<"/consumer/payments/list", {
1271
+ method: "GET";
1272
+ query: zod.ZodOptional<zod.ZodObject<{
1273
+ page: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
1274
+ limit: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
1275
+ invoiceId: zod.ZodOptional<zod.ZodString>;
1276
+ }, zod_v4_core.$strip>>;
1277
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1278
+ session: {
1279
+ session: Record<string, any> & {
1280
+ id: string;
1281
+ createdAt: Date;
1282
+ updatedAt: Date;
1283
+ userId: string;
1284
+ expiresAt: Date;
1285
+ token: string;
1286
+ ipAddress?: string | null | undefined;
1287
+ userAgent?: string | null | undefined;
1288
+ };
1289
+ user: Record<string, any> & {
1290
+ id: string;
1291
+ createdAt: Date;
1292
+ updatedAt: Date;
1293
+ email: string;
1294
+ emailVerified: boolean;
1295
+ name: string;
1296
+ image?: string | null | undefined;
1297
+ };
1298
+ };
1299
+ }>)[];
1300
+ }, {
1301
+ data?: {
1302
+ id?: string;
1303
+ amount?: string;
1304
+ scheduled_on?: string;
1305
+ type?: "INITIAL" | "INSTALLMENT" | "SPLIT_PREPAID";
1306
+ payment_method?: "MADA" | "MASTERCARD" | "VISA" | "APPLE_PAY" | "SAMSUNG_PAY" | "AMEX" | "CASH" | "PGW_CARD_UNSPECIFIED" | "BANK_TRANSFER" | "CARD" | "QURRAH";
1307
+ current_status?: "EXPIRED" | "CANCELED" | "PENDING" | "PROCESSING" | "FAILED_INITIATION" | "SUCCEEDED" | "FAILED" | "UNDER_REVIEW" | "SETTLED" | "REFUNDED";
1308
+ payed_at?: string | null;
1309
+ refunded_at?: string | null;
1310
+ refund_reason?: "REQUESTED_BY_CUSTOMER" | "DUPLICATE" | "FRAUDULENT" | "OTHER";
1311
+ refund_note?: string | null;
1312
+ }[];
1313
+ pagination?: {
1314
+ total_count?: number;
1315
+ max_page?: number;
1316
+ current_page?: number;
1317
+ limit?: number;
1318
+ has_next_page?: boolean;
1319
+ has_previous_page?: boolean;
1320
+ };
1321
+ }>;
1322
+ } | {
1323
+ cancelSubscription: better_auth.StrictEndpoint<"/consumer/subscriptions/cancel", {
1324
+ method: "POST";
1325
+ body: zod.ZodObject<{
1326
+ subscriptionId: zod.ZodString;
1327
+ cancelRelatedInvoices: zod.ZodOptional<zod.ZodBoolean>;
1328
+ }, zod_v4_core.$strip>;
1329
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1330
+ session: {
1331
+ session: Record<string, any> & {
1332
+ id: string;
1333
+ createdAt: Date;
1334
+ updatedAt: Date;
1335
+ userId: string;
1336
+ expiresAt: Date;
1337
+ token: string;
1338
+ ipAddress?: string | null | undefined;
1339
+ userAgent?: string | null | undefined;
1340
+ };
1341
+ user: Record<string, any> & {
1342
+ id: string;
1343
+ createdAt: Date;
1344
+ updatedAt: Date;
1345
+ email: string;
1346
+ emailVerified: boolean;
1347
+ name: string;
1348
+ image?: string | null | undefined;
1349
+ };
1350
+ };
1351
+ }>)[];
1352
+ }, {
1353
+ created_at?: string;
1354
+ updated_at?: string | null;
1355
+ id?: string;
1356
+ description?: string | null;
1357
+ amount?: string;
1358
+ original_amount?: string;
1359
+ item_level_discounted_amount?: string;
1360
+ coupon_calculation_metadata?: {
1361
+ coupons?: {
1362
+ coupon_id?: string;
1363
+ name?: string;
1364
+ is_percentage?: boolean;
1365
+ discount_value?: string;
1366
+ order?: number;
1367
+ amount_before_discount?: string;
1368
+ discount_amount?: string;
1369
+ amount_after_discount?: string;
1370
+ }[];
1371
+ };
1372
+ remaining_days?: number;
1373
+ currency?: string;
1374
+ recurring_interval?: "WEEK" | "MONTH" | "QUARTER" | "YEAR";
1375
+ recurring_interval_count?: number;
1376
+ status?: "INACTIVE" | "ACTIVE" | "EXPIRED" | "CANCELED" | "FROZEN";
1377
+ current_period_start?: string;
1378
+ current_period_end?: string;
1379
+ current_cycle_number?: number;
1380
+ cancel_at_period_end?: boolean;
1381
+ cancel_at_cycle_number?: number | null;
1382
+ started_at?: string | null;
1383
+ ended_at?: string | null;
1384
+ user_id?: string;
1385
+ organization_consumer_id?: string;
1386
+ latest_invoice_id?: string | null;
1387
+ organization_consumer?: {
1388
+ id?: string;
1389
+ name?: string;
1390
+ alias?: string | null;
1391
+ email?: string | null;
1392
+ };
1393
+ items?: {
1394
+ created_at?: string;
1395
+ updated_at?: string | null;
1396
+ id?: string;
1397
+ product_id?: string;
1398
+ subscription_id?: string;
1399
+ quantity?: number;
1400
+ original_amount?: string;
1401
+ discounted_amount?: string;
1402
+ coupon_calculation_metadata?: {
1403
+ coupons?: {
1404
+ coupon_id?: string;
1405
+ name?: string;
1406
+ is_percentage?: boolean;
1407
+ discount_value?: string;
1408
+ order?: number;
1409
+ amount_before_discount?: string;
1410
+ discount_amount?: string;
1411
+ amount_after_discount?: string;
1412
+ }[];
1413
+ };
1414
+ product?: {
1415
+ created_at?: string;
1416
+ updated_at?: string | null;
1417
+ id?: string;
1418
+ name?: string;
1419
+ description?: string | null;
1420
+ type?: "RECURRING" | "ONE_OFF";
1421
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
1422
+ recurring_interval_count?: number;
1423
+ price?: string;
1424
+ currency: "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BOV" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CHE" | "CHF" | "CHW" | "CLF" | "CLP" | "CNY" | "COP" | "COU" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MXV" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "USN" | "UYI" | "UYU" | "UYW" | "UZS" | "VED" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XOF" | "XPF" | "XSU" | "XUA" | "YER" | "ZAR" | "ZMW" | "ZWL";
1425
+ is_active?: boolean;
1426
+ is_one_time?: boolean;
1427
+ is_price_exempt_from_vat?: boolean;
1428
+ is_price_inclusive_of_vat?: boolean;
1429
+ price_excluding_vat?: string;
1430
+ vat_amount?: string;
1431
+ is_used_in_finalized_invoice: boolean;
1432
+ };
1433
+ }[] | null;
1434
+ latest_invoice?: {
1435
+ created_at?: string;
1436
+ updated_at?: string | null;
1437
+ id?: string;
1438
+ user_id?: string;
1439
+ organization_id?: string;
1440
+ organization_consumer_id?: string;
1441
+ account_id?: string;
1442
+ branch_id?: string;
1443
+ org_invoice_number?: number;
1444
+ description?: string | null;
1445
+ total_amount?: string;
1446
+ original_amount?: string;
1447
+ item_level_discounted_amount?: string;
1448
+ total_vat_amount?: string | null;
1449
+ total_price_excluding_vat?: string | null;
1450
+ coupon_calculation_metadata?: {
1451
+ coupons?: {
1452
+ coupon_id?: string;
1453
+ name?: string;
1454
+ is_percentage?: boolean;
1455
+ discount_value?: string;
1456
+ order?: number;
1457
+ amount_before_discount?: string;
1458
+ discount_amount?: string;
1459
+ amount_after_discount?: string;
1460
+ }[];
1461
+ };
1462
+ currency?: string | null;
1463
+ consumer_message?: string | null;
1464
+ status?: "CREATED" | "ACCEPTED" | "EXPIRED" | "CANCELED" | "DRAFT" | "SENT" | "REJECTED" | "COMPLETED";
1465
+ payment_method?: "OPENBANKING" | "PAYMENTGATEWAY";
1466
+ allowed_payment_flow?: "ALL" | "AUTO" | "MANUAL";
1467
+ current_payment_flow?: "ALL" | "AUTO" | "MANUAL";
1468
+ period_start?: string | null;
1469
+ period_end?: string | null;
1470
+ recurring_interval?: "WEEK" | "MONTH" | "YEAR" | "SEMESTER";
1471
+ recurring_interval_count?: number | null;
1472
+ type?: "RECURRING" | "ONE_OFF" | "ONE_OFF_FUTURE" | "INSTALLMENTS";
1473
+ };
1474
+ latest_freeze?: {
1475
+ created_at?: string;
1476
+ updated_at?: string | null;
1477
+ id?: string;
1478
+ freeze_start_datetime?: string;
1479
+ freeze_end_datetime?: string | null;
1480
+ notes?: string | null;
1481
+ subscription_id?: string;
1482
+ invoice_id?: string;
1483
+ duration?: number | null;
1484
+ };
1485
+ override_payment_methods?: {
1486
+ visa?: boolean | null;
1487
+ mastercard?: boolean | null;
1488
+ amex?: boolean | null;
1489
+ bank_transfer?: boolean | null;
1490
+ installment?: boolean | null;
1491
+ qurrah?: boolean | null;
1492
+ subscription_auto_renewal?: boolean | null;
1493
+ };
1494
+ }>;
1495
+ freezeSubscription: better_auth.StrictEndpoint<"/consumer/subscriptions/freeze", {
1496
+ method: "POST";
1497
+ body: zod.ZodObject<{
1498
+ subscriptionId: zod.ZodString;
1499
+ freezeStartDatetime: zod.ZodString;
1500
+ freezeEndDatetime: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
1501
+ notes: zod.ZodOptional<zod.ZodString>;
1502
+ }, zod_v4_core.$strip>;
1503
+ use: ((inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
1504
+ session: {
1505
+ session: Record<string, any> & {
1506
+ id: string;
1507
+ createdAt: Date;
1508
+ updatedAt: Date;
1509
+ userId: string;
1510
+ expiresAt: Date;
1511
+ token: string;
1512
+ ipAddress?: string | null | undefined;
1513
+ userAgent?: string | null | undefined;
1514
+ };
1515
+ user: Record<string, any> & {
1516
+ id: string;
1517
+ createdAt: Date;
1518
+ updatedAt: Date;
1519
+ email: string;
1520
+ emailVerified: boolean;
1521
+ name: string;
1522
+ image?: string | null | undefined;
1523
+ };
1524
+ };
1525
+ }>)[];
1526
+ }, {
1527
+ created_at?: string;
1528
+ updated_at?: string | null;
1529
+ id?: string;
1530
+ freeze_start_datetime?: string;
1531
+ freeze_end_datetime?: string | null;
1532
+ notes?: string | null;
1533
+ subscription_id?: string;
1534
+ invoice_id?: string;
1535
+ duration?: number | null;
1536
+ }>;
1537
+ } | {
1538
+ streampayWebhooks: better_auth.StrictEndpoint<"/streampay/webhooks", {
1539
+ method: "POST";
1540
+ metadata: {
1541
+ isAction: false;
1542
+ };
1543
+ cloneRequest: true;
1544
+ }, {
1545
+ received: boolean;
1546
+ }>;
1547
+ };
1548
+ schema: {
1549
+ user: {
1550
+ fields: {
1551
+ streampayConsumerId: {
1552
+ type: "string";
1553
+ required: false;
1554
+ input: false;
1555
+ };
1556
+ };
1557
+ };
1558
+ };
1559
+ init(): {
1560
+ options: {
1561
+ databaseHooks: {
1562
+ user: {
1563
+ create: {
1564
+ before: (user: Partial<better_auth.User>, context: StreamPayHookContext | null) => Promise<{
1565
+ data: {
1566
+ streampayConsumerId: string;
1567
+ };
1568
+ } | undefined>;
1569
+ after: (user: better_auth.User, context: StreamPayHookContext | null) => Promise<void>;
1570
+ };
1571
+ update: {
1572
+ after: (user: better_auth.User, context: StreamPayHookContext | null) => Promise<void>;
1573
+ };
1574
+ delete: {
1575
+ after: (user: better_auth.User, context: StreamPayHookContext | null) => Promise<void>;
1576
+ };
1577
+ };
1578
+ };
1579
+ };
1580
+ };
1581
+ };
1582
+
1583
+ export { CheckoutBody as C, type PortalOptions as P, type StreamPayClient as S, type WebhookHandler as W, type CheckoutOptions as a, type CheckoutParams as b, type ConsumerCreateOverrides as c, STREAMPAY_EVENT_TYPES as d, type StreamPayEndpoints as e, type StreamPayEntityType as f, type StreamPayEventType as g, type StreamPayOptions as h, type StreamPayPlugin as i, type StreamPayPlugins as j, type StreamPayProduct as k, type StreamPayWebhookPayload as l, type SubscriptionsOptions as m, type WebhookHandlers as n, type WebhooksOptions as o, checkout as p, dispatchWebhook as q, portal as r, streampay as s, subscriptions as t, webhooks as w };