better-auth-payu 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,828 @@
1
+ import * as better_auth0 from "better-auth";
2
+ import * as better_call0 from "better-call";
3
+ import { APIError } from "better-call";
4
+ import * as zod0 from "zod";
5
+
6
+ //#region src/types.d.ts
7
+ type PayUSubscriptionStatus = "created" | "authenticated" | "active" | "pending" | "halted" | "cancelled" | "completed" | "expired" | "paused";
8
+ type PayUBillingCycle = "DAILY" | "WEEKLY" | "MONTHLY" | "YEARLY" | "ADHOC" | "ASPRESENTED" | "BIMONTHLY" | "BI_YEARLY" | "FORTNIGHTLY" | "QUARTERLY";
9
+ type PayUMandateType = "card" | "upi" | "netbanking";
10
+ interface PayUPlan {
11
+ /** Unique plan identifier */
12
+ planId: string;
13
+ /** Human-readable plan name */
14
+ name: string;
15
+ /** Amount per billing cycle */
16
+ amount: string;
17
+ /** Billing cycle period */
18
+ billingCycle: PayUBillingCycle;
19
+ /** Interval between billing cycles (1 = every cycle) */
20
+ billingInterval: number;
21
+ /** Total number of charges (0 = unlimited) */
22
+ totalCount: number;
23
+ /** Optional annual plan variant ID */
24
+ annualPlanId?: string;
25
+ /** Trial period in days */
26
+ trialDays?: number;
27
+ /** Additional metadata */
28
+ metadata?: Record<string, unknown>;
29
+ }
30
+ interface Subscription {
31
+ id: string;
32
+ plan: string;
33
+ referenceId: string;
34
+ payuCustomerId: string | null;
35
+ payuSubscriptionId: string;
36
+ payuMandateType: PayUMandateType | null;
37
+ payuTransactionId: string | null;
38
+ payuMihpayid: string | null;
39
+ status: PayUSubscriptionStatus;
40
+ currentPeriodStart: Date | null;
41
+ currentPeriodEnd: Date | null;
42
+ cancelledAt: Date | null;
43
+ endedAt: Date | null;
44
+ pausedAt: Date | null;
45
+ totalCount: number | null;
46
+ paidCount: number | null;
47
+ remainingCount: number | null;
48
+ quantity: number | null;
49
+ seats: number | null;
50
+ trialStart: Date | null;
51
+ trialEnd: Date | null;
52
+ metadata: Record<string, unknown> | null;
53
+ createdAt: Date;
54
+ updatedAt: Date;
55
+ }
56
+ interface PayUTransactionResponse {
57
+ mihpayid: string;
58
+ status: string;
59
+ txnid: string;
60
+ amount: string;
61
+ productinfo: string;
62
+ firstname: string;
63
+ email: string;
64
+ phone: string;
65
+ hash: string;
66
+ key: string;
67
+ mode: string;
68
+ unmappedstatus: string;
69
+ field9: string;
70
+ error_Message: string;
71
+ bank_ref_num: string;
72
+ cardCategory: string;
73
+ addedon: string;
74
+ payment_source: string;
75
+ card_type: string;
76
+ name_on_card: string;
77
+ cardnum: string;
78
+ issuing_bank: string;
79
+ udf1?: string;
80
+ udf2?: string;
81
+ udf3?: string;
82
+ udf4?: string;
83
+ udf5?: string;
84
+ udf6?: string;
85
+ udf7?: string;
86
+ udf8?: string;
87
+ udf9?: string;
88
+ udf10?: string;
89
+ si?: PayUSIResponseDetails;
90
+ }
91
+ interface PayUSIResponseDetails {
92
+ status: string;
93
+ paymentMode: string;
94
+ startDate: string;
95
+ endDate: string;
96
+ maxAmount: string;
97
+ frequency: string;
98
+ mandateId?: string;
99
+ tokenValue?: string;
100
+ }
101
+ interface PayUWebhookEvent {
102
+ mihpayid: string;
103
+ status: string;
104
+ txnid: string;
105
+ amount: string;
106
+ productinfo: string;
107
+ firstname: string;
108
+ email: string;
109
+ phone: string;
110
+ hash: string;
111
+ key: string;
112
+ mode: string;
113
+ unmappedstatus: string;
114
+ field9: string;
115
+ error: string;
116
+ bank_ref_num: string;
117
+ addedon: string;
118
+ payment_source: string;
119
+ udf1?: string;
120
+ udf2?: string;
121
+ udf3?: string;
122
+ udf4?: string;
123
+ udf5?: string;
124
+ udf6?: string;
125
+ udf7?: string;
126
+ udf8?: string;
127
+ udf9?: string;
128
+ udf10?: string;
129
+ si?: PayUSIResponseDetails;
130
+ /** Webhook notification type */
131
+ notificationType?: string;
132
+ }
133
+ interface PayURefundResponse {
134
+ mihpayid: string;
135
+ request_id: string;
136
+ bank_ref_num: string;
137
+ amt: string;
138
+ mode: string;
139
+ action: string;
140
+ token: string;
141
+ status: string;
142
+ error_code?: number;
143
+ msg?: string;
144
+ }
145
+ interface SubscriptionCallbackData {
146
+ subscription: Subscription;
147
+ plan: PayUPlan | undefined;
148
+ event: PayUWebhookEvent;
149
+ }
150
+ interface SubscriptionOptions {
151
+ enabled: boolean;
152
+ plans?: PayUPlan[] | (() => Promise<PayUPlan[]> | PayUPlan[]);
153
+ defaultPlan?: string;
154
+ startOnConsent?: boolean;
155
+ requireOrganization?: boolean;
156
+ onSubscriptionActivated?: (data: SubscriptionCallbackData) => void | Promise<void>;
157
+ onSubscriptionCharged?: (data: SubscriptionCallbackData) => void | Promise<void>;
158
+ onSubscriptionPending?: (data: SubscriptionCallbackData) => void | Promise<void>;
159
+ onSubscriptionHalted?: (data: SubscriptionCallbackData) => void | Promise<void>;
160
+ onSubscriptionCompleted?: (data: SubscriptionCallbackData) => void | Promise<void>;
161
+ onSubscriptionCancelled?: (data: SubscriptionCallbackData) => void | Promise<void>;
162
+ onSubscriptionPaused?: (data: SubscriptionCallbackData) => void | Promise<void>;
163
+ onSubscriptionResumed?: (data: SubscriptionCallbackData) => void | Promise<void>;
164
+ onSubscriptionAuthenticated?: (data: SubscriptionCallbackData) => void | Promise<void>;
165
+ onPaymentSuccess?: (data: SubscriptionCallbackData) => void | Promise<void>;
166
+ onPaymentFailure?: (data: {
167
+ event: PayUWebhookEvent;
168
+ error: string;
169
+ }) => void | Promise<void>;
170
+ onMandateRevoked?: (data: SubscriptionCallbackData) => void | Promise<void>;
171
+ onMandateModified?: (data: SubscriptionCallbackData) => void | Promise<void>;
172
+ onRefundComplete?: (data: {
173
+ event: PayUWebhookEvent;
174
+ refund: PayURefundResponse;
175
+ }) => void | Promise<void>;
176
+ }
177
+ type AuthorizeReferenceAction = "create-subscription" | "cancel-subscription" | "pause-subscription" | "resume-subscription" | "update-subscription" | "list-subscriptions" | "get-subscription" | "check-mandate-status" | "modify-mandate" | "initiate-payment" | "verify-payment" | "initiate-refund" | "check-refund-status" | "list-refunds";
178
+ interface OrganizationOptions {
179
+ enabled: boolean;
180
+ creatorRole?: string;
181
+ memberRole?: string;
182
+ organizationLimit?: number;
183
+ seatManagement?: boolean;
184
+ authorizeReference?: (params: {
185
+ action: AuthorizeReferenceAction;
186
+ organizationId: string;
187
+ userId: string;
188
+ role: string | undefined;
189
+ }) => boolean | Promise<boolean>;
190
+ }
191
+ interface PayUOptions {
192
+ /** PayU Merchant Key */
193
+ merchantKey: string;
194
+ /** PayU Merchant Salt (V2 recommended) */
195
+ merchantSalt: string;
196
+ /** PayU API base URL (production or test) */
197
+ apiBaseUrl?: string;
198
+ /** Webhook secret for verifying webhook signatures */
199
+ webhookSecret?: string;
200
+ /** Subscription / Standing Instruction configuration */
201
+ subscription?: SubscriptionOptions;
202
+ /** Organization support configuration */
203
+ organization?: OrganizationOptions;
204
+ /** Custom schema overrides */
205
+ schema?: Record<string, Record<string, unknown>>;
206
+ }
207
+ //#endregion
208
+ //#region src/error-codes.d.ts
209
+ declare const PAYU_ERROR_CODES: {
210
+ readonly UNAUTHORIZED: "Unauthorized access";
211
+ readonly INVALID_REQUEST_BODY: "Invalid request body";
212
+ readonly SUBSCRIPTION_NOT_FOUND: "Subscription not found";
213
+ readonly SUBSCRIPTION_PLAN_NOT_FOUND: "Subscription plan not found";
214
+ readonly ALREADY_SUBSCRIBED_PLAN: "You're already subscribed to this plan";
215
+ readonly REFERENCE_ID_NOT_ALLOWED: "Reference id is not allowed";
216
+ readonly SUBSCRIPTION_NOT_ACTIVE: "Subscription is not active";
217
+ readonly SUBSCRIPTION_ALREADY_CANCELLED: "Subscription is already cancelled";
218
+ readonly SUBSCRIPTION_ALREADY_PAUSED: "Subscription is already paused";
219
+ readonly SUBSCRIPTION_NOT_PAUSED: "Subscription is not paused to resume";
220
+ readonly SUBSCRIPTION_IN_TERMINAL_STATE: "Subscription is in a terminal state";
221
+ readonly CUSTOMER_NOT_FOUND: "PayU customer not found for this user";
222
+ readonly UNABLE_TO_CREATE_CUSTOMER: "Unable to create PayU customer";
223
+ readonly WEBHOOK_HASH_NOT_FOUND: "PayU webhook hash not found";
224
+ readonly WEBHOOK_SECRET_NOT_FOUND: "PayU webhook secret not found";
225
+ readonly WEBHOOK_ERROR: "PayU webhook error";
226
+ readonly FAILED_TO_VERIFY_WEBHOOK: "Failed to verify PayU webhook hash";
227
+ readonly HASH_GENERATION_FAILED: "Failed to generate PayU hash";
228
+ readonly HASH_VERIFICATION_FAILED: "PayU hash verification failed";
229
+ readonly MANDATE_NOT_FOUND: "Mandate not found";
230
+ readonly MANDATE_REVOKE_FAILED: "Failed to revoke mandate";
231
+ readonly MANDATE_MODIFY_FAILED: "Failed to modify mandate";
232
+ readonly MANDATE_STATUS_CHECK_FAILED: "Failed to check mandate status";
233
+ readonly PAYMENT_INITIATION_FAILED: "Failed to initiate payment";
234
+ readonly PAYMENT_VERIFICATION_FAILED: "Failed to verify payment";
235
+ readonly PAYMENT_NOT_FOUND: "Payment not found";
236
+ readonly REFUND_INITIATION_FAILED: "Failed to initiate refund";
237
+ readonly REFUND_STATUS_CHECK_FAILED: "Failed to check refund status";
238
+ readonly TRANSACTION_NOT_FOUND: "Transaction not found";
239
+ readonly TRANSACTION_DETAILS_FAILED: "Failed to get transaction details";
240
+ readonly PRE_DEBIT_NOTIFICATION_FAILED: "Failed to send pre-debit notification";
241
+ readonly ORGANIZATION_ON_ACTIVE_SUBSCRIPTION: "Organization has an active subscription and cannot be deleted";
242
+ readonly ORGANIZATION_NOT_FOUND: "Organization not found";
243
+ readonly SI_UPDATE_FAILED: "Failed to update standing instruction";
244
+ readonly INVALID_SI_PARAMS: "Invalid standing instruction parameters";
245
+ readonly VPA_VALIDATION_FAILED: "Failed to validate VPA";
246
+ readonly INVALID_VPA: "Invalid VPA address";
247
+ };
248
+ //# sourceMappingURL=error-codes.d.ts.map
249
+ //#endregion
250
+ //#region src/metadata.d.ts
251
+ type PayUUdf = Record<string, string | undefined>;
252
+ type CustomerInternalUdf = {
253
+ customerType: "user";
254
+ userId: string;
255
+ } | {
256
+ customerType: "organization";
257
+ organizationId: string;
258
+ };
259
+ type SubscriptionInternalUdf = {
260
+ userId: string;
261
+ subscriptionId: string;
262
+ referenceId: string;
263
+ };
264
+ declare const customerUdf: {
265
+ /** Internal keys used for customer tracking */
266
+ keys: readonly ["customerType", "userId", "organizationId"];
267
+ /**
268
+ * Set customer UDFs by mapping internal fields to udf slots.
269
+ * Internal fields take priority over user-provided values.
270
+ */
271
+ set(internalFields: CustomerInternalUdf, userUdf?: PayUUdf): PayUUdf;
272
+ /**
273
+ * Extract customer-specific fields from UDF values.
274
+ */
275
+ get(udf: PayUUdf | null | undefined): {
276
+ userId: string | undefined;
277
+ organizationId: string | undefined;
278
+ customerType: CustomerInternalUdf["customerType"] | undefined;
279
+ };
280
+ };
281
+ declare const subscriptionUdf: {
282
+ /** Internal keys used for subscription tracking */
283
+ keys: readonly ["userId", "subscriptionId", "referenceId"];
284
+ /**
285
+ * Set subscription UDFs by mapping internal fields to udf slots.
286
+ * Internal fields take priority over user-provided values.
287
+ */
288
+ set(internalFields: SubscriptionInternalUdf, userUdf?: PayUUdf): PayUUdf;
289
+ /**
290
+ * Extract subscription-specific fields from UDF values.
291
+ */
292
+ get(udf: PayUUdf | null | undefined): {
293
+ userId: string | undefined;
294
+ subscriptionId: string | undefined;
295
+ referenceId: string | undefined;
296
+ };
297
+ };
298
+ /**
299
+ * Convert a PayUUdf object to individual udf params for API calls.
300
+ */
301
+ declare function udfToParams(udf: PayUUdf): Record<string, string>;
302
+ /**
303
+ * Extract UDF fields from a PayU response/webhook into a PayUUdf object.
304
+ */
305
+ declare function paramsToUdf(params: Record<string, string | undefined>): PayUUdf;
306
+ //#endregion
307
+ //#region src/utils.d.ts
308
+ /**
309
+ * Generate PayU hash using HMAC-SHA256 with merchant salt.
310
+ * Hash formula: sha512(key|txnid|amount|productinfo|firstname|email|udf1|...|udf10||salt)
311
+ */
312
+ declare function generatePayUHash(params: {
313
+ key: string;
314
+ txnid: string;
315
+ amount: string;
316
+ productinfo: string;
317
+ firstname: string;
318
+ email: string;
319
+ udf1?: string;
320
+ udf2?: string;
321
+ udf3?: string;
322
+ udf4?: string;
323
+ udf5?: string;
324
+ udf6?: string;
325
+ udf7?: string;
326
+ udf8?: string;
327
+ udf9?: string;
328
+ udf10?: string;
329
+ }, salt: string): string;
330
+ /**
331
+ * Verify PayU webhook/response hash.
332
+ * Reverse hash: sha512(salt|status||||||||||udf10|udf9|...|udf1|email|firstname|productinfo|amount|txnid|key)
333
+ */
334
+ declare function verifyPayUHash(params: {
335
+ key: string;
336
+ txnid: string;
337
+ amount: string;
338
+ productinfo: string;
339
+ firstname: string;
340
+ email: string;
341
+ status: string;
342
+ udf1?: string;
343
+ udf2?: string;
344
+ udf3?: string;
345
+ udf4?: string;
346
+ udf5?: string;
347
+ udf6?: string;
348
+ udf7?: string;
349
+ udf8?: string;
350
+ udf9?: string;
351
+ udf10?: string;
352
+ }, salt: string, receivedHash: string): boolean;
353
+ declare function isActive(sub: Subscription | {
354
+ status: string;
355
+ }): boolean;
356
+ declare function isAuthenticated(sub: Subscription | {
357
+ status: string;
358
+ }): boolean;
359
+ declare function isPaused(sub: Subscription | {
360
+ status: string;
361
+ }): boolean;
362
+ declare function isCancelled(sub: Subscription | {
363
+ status: string;
364
+ }): boolean;
365
+ declare function isTerminal(sub: Subscription | {
366
+ status: string;
367
+ }): boolean;
368
+ declare function isUsable(sub: Subscription | {
369
+ status: string;
370
+ }): boolean;
371
+ declare function hasPaymentIssue(sub: Subscription | {
372
+ status: string;
373
+ }): boolean;
374
+ declare function timestampToDate(timestamp: number | null | undefined): Date | undefined;
375
+ declare function dateStringToDate(dateStr: string | null | undefined): Date | undefined;
376
+ declare function toSubscriptionStatus(status: string): PayUSubscriptionStatus;
377
+ /**
378
+ * Generate hash for PayU API commands (verify_payment, cancel_refund, etc.)
379
+ * Hash formula: sha512(key|command|var1|salt)
380
+ */
381
+ declare function generateCommandHash(key: string, command: string, var1: string, salt: string): string;
382
+ //# sourceMappingURL=utils.d.ts.map
383
+
384
+ //#endregion
385
+ //#region src/index.d.ts
386
+ sideEffect();
387
+ declare const payu: <O extends PayUOptions>(options: O) => {
388
+ id: "payu";
389
+ endpoints: {
390
+ payuMandateStatus: better_call0.StrictEndpoint<"/payu/mandate/status", {
391
+ method: "GET";
392
+ query: zod0.ZodObject<{
393
+ subscriptionId: zod0.ZodString;
394
+ mandateType: zod0.ZodOptional<zod0.ZodEnum<{
395
+ card: "card";
396
+ upi: "upi";
397
+ netbanking: "netbanking";
398
+ }>>;
399
+ }, better_auth0.$strip>;
400
+ }, {
401
+ mandate: any;
402
+ }>;
403
+ payuMandateModify: better_call0.StrictEndpoint<"/payu/mandate/modify", {
404
+ method: "POST";
405
+ body: zod0.ZodObject<{
406
+ subscriptionId: zod0.ZodString;
407
+ amount: zod0.ZodString;
408
+ mandateType: zod0.ZodOptional<zod0.ZodEnum<{
409
+ card: "card";
410
+ upi: "upi";
411
+ netbanking: "netbanking";
412
+ }>>;
413
+ }, better_auth0.$strip>;
414
+ }, {
415
+ success: boolean;
416
+ result: any;
417
+ }>;
418
+ payuValidateVpa: better_call0.StrictEndpoint<"/payu/upi/validate-vpa", {
419
+ method: "POST";
420
+ body: zod0.ZodObject<{
421
+ vpa: zod0.ZodString;
422
+ }, better_auth0.$strip>;
423
+ }, {
424
+ valid: boolean;
425
+ result: any;
426
+ }>;
427
+ payuListPlans: better_call0.StrictEndpoint<"/payu/plan/list", {
428
+ method: "GET";
429
+ }, {
430
+ plans: PayUPlan[];
431
+ }>;
432
+ payuGetPlan: better_call0.StrictEndpoint<"/payu/plan/get", {
433
+ method: "GET";
434
+ query: zod0.ZodObject<{
435
+ planId: zod0.ZodString;
436
+ }, better_auth0.$strip>;
437
+ }, {
438
+ plan: PayUPlan;
439
+ }>;
440
+ payuTransactionInfo: better_call0.StrictEndpoint<"/payu/transaction/info", {
441
+ method: "GET";
442
+ query: zod0.ZodObject<{
443
+ txnid: zod0.ZodString;
444
+ }, better_auth0.$strip>;
445
+ }, {
446
+ transaction: any;
447
+ }>;
448
+ payuTransactionDetails: better_call0.StrictEndpoint<"/payu/transaction/details", {
449
+ method: "GET";
450
+ query: zod0.ZodObject<{
451
+ startDate: zod0.ZodString;
452
+ endDate: zod0.ZodString;
453
+ }, better_auth0.$strip>;
454
+ }, {
455
+ transactions: any;
456
+ }>;
457
+ payuInitiateRefund: better_call0.StrictEndpoint<"/payu/refund/initiate", {
458
+ method: "POST";
459
+ body: zod0.ZodObject<{
460
+ mihpayid: zod0.ZodString;
461
+ amount: zod0.ZodString;
462
+ tokenId: zod0.ZodString;
463
+ }, better_auth0.$strip>;
464
+ }, {
465
+ success: boolean;
466
+ refund: any;
467
+ }>;
468
+ payuRefundStatus: better_call0.StrictEndpoint<"/payu/refund/status", {
469
+ method: "GET";
470
+ query: zod0.ZodObject<{
471
+ requestId: zod0.ZodOptional<zod0.ZodString>;
472
+ mihpayid: zod0.ZodOptional<zod0.ZodString>;
473
+ }, better_auth0.$strip>;
474
+ }, {
475
+ refundStatus: any;
476
+ }>;
477
+ payuListRefunds: better_call0.StrictEndpoint<"/payu/refund/list", {
478
+ method: "POST";
479
+ body: zod0.ZodObject<{
480
+ mihpayids: zod0.ZodArray<zod0.ZodString>;
481
+ }, better_auth0.$strip>;
482
+ }, {
483
+ refunds: any;
484
+ }>;
485
+ payuInitiatePayment: better_call0.StrictEndpoint<"/payu/payment/initiate", {
486
+ method: "POST";
487
+ body: zod0.ZodObject<{
488
+ txnid: zod0.ZodString;
489
+ amount: zod0.ZodString;
490
+ productinfo: zod0.ZodString;
491
+ firstname: zod0.ZodString;
492
+ email: zod0.ZodString;
493
+ phone: zod0.ZodString;
494
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
495
+ }, better_auth0.$strip>;
496
+ }, {
497
+ paymentParams: {
498
+ key: string;
499
+ txnid: string;
500
+ amount: string;
501
+ productinfo: string;
502
+ firstname: string;
503
+ email: string;
504
+ phone: string;
505
+ hash: string;
506
+ surl: string;
507
+ furl: string;
508
+ };
509
+ }>;
510
+ payuVerifyPayment: better_call0.StrictEndpoint<"/payu/payment/verify", {
511
+ method: "POST";
512
+ body: zod0.ZodObject<{
513
+ txnid: zod0.ZodString;
514
+ }, better_auth0.$strip>;
515
+ }, {
516
+ transaction: any;
517
+ }>;
518
+ payuCheckPayment: better_call0.StrictEndpoint<"/payu/payment/check", {
519
+ method: "POST";
520
+ body: zod0.ZodObject<{
521
+ mihpayid: zod0.ZodString;
522
+ }, better_auth0.$strip>;
523
+ }, {
524
+ transaction: any;
525
+ }>;
526
+ payuWebhook: better_call0.StrictEndpoint<"/payu/webhook", {
527
+ method: "POST";
528
+ }, {
529
+ success: boolean;
530
+ }>;
531
+ } & (O["subscription"] extends {
532
+ enabled: true;
533
+ } ? {
534
+ payuCreateSubscription: better_call0.StrictEndpoint<"/payu/subscription/create", {
535
+ method: "POST";
536
+ body: zod0.ZodObject<{
537
+ plan: zod0.ZodString;
538
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
539
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
540
+ user: "user";
541
+ organization: "organization";
542
+ }>>;
543
+ mandateType: zod0.ZodOptional<zod0.ZodEnum<{
544
+ card: "card";
545
+ upi: "upi";
546
+ netbanking: "netbanking";
547
+ }>>;
548
+ }, better_auth0.$strip>;
549
+ }, {
550
+ subscription: Record<string, any>;
551
+ paymentParams: {
552
+ key: string;
553
+ txnid: string;
554
+ amount: string;
555
+ productinfo: string;
556
+ hash: string;
557
+ mandateType: "card" | "upi" | "netbanking";
558
+ };
559
+ }>;
560
+ payuPayAndSubscribe: better_call0.StrictEndpoint<"/payu/subscription/pay-and-subscribe", {
561
+ method: "POST";
562
+ body: zod0.ZodObject<{
563
+ plan: zod0.ZodString;
564
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
565
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
566
+ user: "user";
567
+ organization: "organization";
568
+ }>>;
569
+ mandateType: zod0.ZodOptional<zod0.ZodEnum<{
570
+ card: "card";
571
+ upi: "upi";
572
+ netbanking: "netbanking";
573
+ }>>;
574
+ initialAmount: zod0.ZodOptional<zod0.ZodString>;
575
+ }, better_auth0.$strip>;
576
+ }, {
577
+ subscription: Record<string, any>;
578
+ paymentParams: {
579
+ key: string;
580
+ txnid: string;
581
+ amount: string;
582
+ productinfo: string;
583
+ hash: string;
584
+ mandateType: "card" | "upi" | "netbanking";
585
+ };
586
+ }>;
587
+ payuCancelSubscription: better_call0.StrictEndpoint<"/payu/subscription/cancel", {
588
+ method: "POST";
589
+ body: zod0.ZodObject<{
590
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
591
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
592
+ user: "user";
593
+ organization: "organization";
594
+ }>>;
595
+ cancelAtCycleEnd: zod0.ZodOptional<zod0.ZodBoolean>;
596
+ }, better_auth0.$strip>;
597
+ }, {
598
+ success: boolean;
599
+ }>;
600
+ payuPauseSubscription: better_call0.StrictEndpoint<"/payu/subscription/pause", {
601
+ method: "POST";
602
+ body: zod0.ZodObject<{
603
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
604
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
605
+ user: "user";
606
+ organization: "organization";
607
+ }>>;
608
+ }, better_auth0.$strip>;
609
+ }, {
610
+ success: boolean;
611
+ }>;
612
+ payuResumeSubscription: better_call0.StrictEndpoint<"/payu/subscription/resume", {
613
+ method: "POST";
614
+ body: zod0.ZodObject<{
615
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
616
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
617
+ user: "user";
618
+ organization: "organization";
619
+ }>>;
620
+ }, better_auth0.$strip>;
621
+ }, {
622
+ success: boolean;
623
+ }>;
624
+ payuListSubscriptions: better_call0.StrictEndpoint<"/payu/subscription/list", {
625
+ method: "GET";
626
+ query: zod0.ZodObject<{
627
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
628
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
629
+ user: "user";
630
+ organization: "organization";
631
+ }>>;
632
+ }, better_auth0.$strip>;
633
+ }, {
634
+ subscriptions: {}[];
635
+ }>;
636
+ payuGetSubscription: better_call0.StrictEndpoint<"/payu/subscription/get", {
637
+ method: "GET";
638
+ query: zod0.ZodObject<{
639
+ subscriptionId: zod0.ZodString;
640
+ }, better_auth0.$strip>;
641
+ }, {
642
+ subscription: {};
643
+ }>;
644
+ payuUpdateSubscription: better_call0.StrictEndpoint<"/payu/subscription/update", {
645
+ method: "POST";
646
+ body: zod0.ZodObject<{
647
+ referenceId: zod0.ZodOptional<zod0.ZodString>;
648
+ customerType: zod0.ZodOptional<zod0.ZodEnum<{
649
+ user: "user";
650
+ organization: "organization";
651
+ }>>;
652
+ plan: zod0.ZodOptional<zod0.ZodString>;
653
+ quantity: zod0.ZodOptional<zod0.ZodNumber>;
654
+ }, better_auth0.$strip>;
655
+ }, {
656
+ success: boolean;
657
+ }>;
658
+ payuPreDebitNotify: better_call0.StrictEndpoint<"/payu/subscription/pre-debit-notify", {
659
+ method: "POST";
660
+ body: zod0.ZodObject<{
661
+ subscriptionId: zod0.ZodString;
662
+ amount: zod0.ZodString;
663
+ txnid: zod0.ZodString;
664
+ debitDate: zod0.ZodString;
665
+ }, better_auth0.$strip>;
666
+ }, {
667
+ success: boolean;
668
+ result: any;
669
+ }>;
670
+ payuChargeSubscription: better_call0.StrictEndpoint<"/payu/subscription/charge", {
671
+ method: "POST";
672
+ body: zod0.ZodObject<{
673
+ subscriptionId: zod0.ZodString;
674
+ amount: zod0.ZodString;
675
+ txnid: zod0.ZodString;
676
+ }, better_auth0.$strip>;
677
+ }, {
678
+ success: boolean;
679
+ result: any;
680
+ }>;
681
+ payuUpdateSI: better_call0.StrictEndpoint<"/payu/subscription/update-si", {
682
+ method: "POST";
683
+ body: zod0.ZodObject<{
684
+ subscriptionId: zod0.ZodString;
685
+ billingAmount: zod0.ZodOptional<zod0.ZodString>;
686
+ billingCycle: zod0.ZodOptional<zod0.ZodString>;
687
+ billingInterval: zod0.ZodOptional<zod0.ZodNumber>;
688
+ paymentEndDate: zod0.ZodOptional<zod0.ZodString>;
689
+ }, better_auth0.$strip>;
690
+ }, {
691
+ success: boolean;
692
+ result: any;
693
+ }>;
694
+ } : {});
695
+ init(ctx: better_auth0.AuthContext): void;
696
+ schema: {
697
+ user: {
698
+ fields: {
699
+ payuCustomerId: {
700
+ type: "string";
701
+ required: false;
702
+ };
703
+ };
704
+ };
705
+ } & (O["subscription"] extends {
706
+ enabled: true;
707
+ } ? {
708
+ subscription: {
709
+ fields: {
710
+ plan: {
711
+ type: "string";
712
+ required: true;
713
+ };
714
+ referenceId: {
715
+ type: "string";
716
+ required: true;
717
+ };
718
+ payuCustomerId: {
719
+ type: "string";
720
+ required: false;
721
+ };
722
+ payuSubscriptionId: {
723
+ type: "string";
724
+ required: false;
725
+ };
726
+ payuMandateType: {
727
+ type: "string";
728
+ required: false;
729
+ };
730
+ payuTransactionId: {
731
+ type: "string";
732
+ required: false;
733
+ };
734
+ payuMihpayid: {
735
+ type: "string";
736
+ required: false;
737
+ };
738
+ status: {
739
+ type: "string";
740
+ defaultValue: string;
741
+ };
742
+ currentStart: {
743
+ type: "date";
744
+ required: false;
745
+ };
746
+ currentEnd: {
747
+ type: "date";
748
+ required: false;
749
+ };
750
+ endedAt: {
751
+ type: "date";
752
+ required: false;
753
+ };
754
+ quantity: {
755
+ type: "number";
756
+ required: false;
757
+ defaultValue: number;
758
+ };
759
+ totalCount: {
760
+ type: "number";
761
+ required: false;
762
+ };
763
+ paidCount: {
764
+ type: "number";
765
+ required: false;
766
+ defaultValue: number;
767
+ };
768
+ remainingCount: {
769
+ type: "number";
770
+ required: false;
771
+ };
772
+ cancelledAt: {
773
+ type: "date";
774
+ required: false;
775
+ };
776
+ pausedAt: {
777
+ type: "date";
778
+ required: false;
779
+ };
780
+ cancelAtCycleEnd: {
781
+ type: "boolean";
782
+ required: false;
783
+ defaultValue: false;
784
+ };
785
+ billingPeriod: {
786
+ type: "string";
787
+ required: false;
788
+ };
789
+ seats: {
790
+ type: "number";
791
+ required: false;
792
+ };
793
+ trialStart: {
794
+ type: "date";
795
+ required: false;
796
+ };
797
+ trialEnd: {
798
+ type: "date";
799
+ required: false;
800
+ };
801
+ metadata: {
802
+ type: "string";
803
+ required: false;
804
+ };
805
+ };
806
+ };
807
+ } : {}) & (O["organization"] extends {
808
+ enabled: true;
809
+ } ? {
810
+ organization: {
811
+ fields: {
812
+ payuCustomerId: {
813
+ type: "string";
814
+ required: false;
815
+ };
816
+ };
817
+ };
818
+ } : {});
819
+ hooks: {
820
+ after: {
821
+ matcher(context: better_auth0.HookEndpointContext): boolean;
822
+ handler(ctx: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>): Promise<void>;
823
+ }[];
824
+ };
825
+ };
826
+ //#endregion
827
+ export { Subscription as C, PayUWebhookEvent as S, SubscriptionOptions as T, subscriptionUdf as _, hasPaymentIssue as a, PayUPlan as b, isCancelled as c, isUsable as d, timestampToDate as f, paramsToUdf as g, customerUdf as h, generatePayUHash as i, isPaused as l, verifyPayUHash as m, dateStringToDate as n, isActive as o, toSubscriptionStatus as p, generateCommandHash as r, isAuthenticated as s, payu as t, isTerminal as u, udfToParams as v, SubscriptionCallbackData as w, PayUTransactionResponse as x, PAYU_ERROR_CODES as y };
828
+ //# sourceMappingURL=index-B1s85S1-.d.ts.map