@deiondz/better-auth-razorpay 2.0.5 → 2.0.7
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/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/client/hooks.d.ts +87 -0
- package/dist/client/hooks.js +182 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.js +49 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +4921 -0
- package/dist/index.js.map +1 -0
- package/dist/types-B25gyPpX.d.ts +208 -0
- package/dist/types-JYoruGio.d.ts +146 -0
- package/package.json +17 -18
- package/api/cancel-subscription.ts +0 -90
- package/api/create-or-update-subscription.ts +0 -254
- package/api/get-plans.ts +0 -36
- package/api/index.ts +0 -7
- package/api/list-subscriptions.ts +0 -79
- package/api/restore-subscription.ts +0 -79
- package/api/verify-payment.ts +0 -87
- package/api/webhook.ts +0 -305
- package/client/hooks.ts +0 -352
- package/client/types.ts +0 -154
- package/client.ts +0 -105
- package/index.ts +0 -162
- package/lib/error-handler.ts +0 -99
- package/lib/index.ts +0 -28
- package/lib/schemas.ts +0 -34
- package/lib/types.ts +0 -207
package/lib/types.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Razorpay subscription response from the Razorpay API.
|
|
3
|
-
*/
|
|
4
|
-
export interface RazorpaySubscription {
|
|
5
|
-
id: string
|
|
6
|
-
entity: string
|
|
7
|
-
plan_id: string
|
|
8
|
-
status: string
|
|
9
|
-
current_start: number
|
|
10
|
-
current_end: number
|
|
11
|
-
ended_at: number | null
|
|
12
|
-
quantity: number
|
|
13
|
-
notes: Record<string, string> | null
|
|
14
|
-
charge_at: number
|
|
15
|
-
start_at: number
|
|
16
|
-
end_at: number
|
|
17
|
-
auth_attempts: number
|
|
18
|
-
total_count: number
|
|
19
|
-
paid_count: number
|
|
20
|
-
customer_notify: boolean
|
|
21
|
-
created_at: number
|
|
22
|
-
expire_by: number | null
|
|
23
|
-
short_url: string
|
|
24
|
-
has_scheduled_changes: boolean
|
|
25
|
-
change_scheduled_at: number | null
|
|
26
|
-
source: string
|
|
27
|
-
offer_id: string | null
|
|
28
|
-
remaining_count: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Local subscription status aligned with Razorpay and plugin lifecycle. */
|
|
32
|
-
export type SubscriptionStatus =
|
|
33
|
-
| 'created'
|
|
34
|
-
| 'active'
|
|
35
|
-
| 'pending'
|
|
36
|
-
| 'halted'
|
|
37
|
-
| 'cancelled'
|
|
38
|
-
| 'completed'
|
|
39
|
-
| 'expired'
|
|
40
|
-
| 'trialing'
|
|
41
|
-
|
|
42
|
-
/** Local subscription record stored in the auth adapter. */
|
|
43
|
-
export interface SubscriptionRecord {
|
|
44
|
-
id: string
|
|
45
|
-
plan: string
|
|
46
|
-
referenceId: string
|
|
47
|
-
razorpayCustomerId?: string | null
|
|
48
|
-
razorpaySubscriptionId?: string | null
|
|
49
|
-
status: SubscriptionStatus
|
|
50
|
-
trialStart?: Date | null
|
|
51
|
-
trialEnd?: Date | null
|
|
52
|
-
periodStart?: Date | null
|
|
53
|
-
periodEnd?: Date | null
|
|
54
|
-
cancelAtPeriodEnd: boolean
|
|
55
|
-
seats: number
|
|
56
|
-
groupId?: string | null
|
|
57
|
-
createdAt: Date
|
|
58
|
-
updatedAt: Date
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Plan limits (customizable per plan). */
|
|
62
|
-
export interface PlanLimits {
|
|
63
|
-
[key: string]: number
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Free trial configuration for a plan. */
|
|
67
|
-
export interface PlanFreeTrial {
|
|
68
|
-
days: number
|
|
69
|
-
onTrialStart?: (subscription: SubscriptionRecord) => Promise<void>
|
|
70
|
-
onTrialEnd?: (args: { subscription: SubscriptionRecord }) => Promise<void>
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Named plan with monthly/annual Razorpay plan IDs and optional trial. */
|
|
74
|
-
export interface RazorpayPlan {
|
|
75
|
-
name: string
|
|
76
|
-
monthlyPlanId: string
|
|
77
|
-
annualPlanId?: string
|
|
78
|
-
description?: string
|
|
79
|
-
limits?: PlanLimits
|
|
80
|
-
freeTrial?: PlanFreeTrial
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Subscription plugin options (plans, callbacks, authorization). */
|
|
84
|
-
export interface SubscriptionOptions {
|
|
85
|
-
enabled: boolean
|
|
86
|
-
plans: RazorpayPlan[] | (() => Promise<RazorpayPlan[]>)
|
|
87
|
-
requireEmailVerification?: boolean
|
|
88
|
-
authorizeReference?: (args: {
|
|
89
|
-
user: { id: string; email?: string; name?: string; [key: string]: unknown }
|
|
90
|
-
referenceId: string
|
|
91
|
-
action: string
|
|
92
|
-
}) => Promise<boolean>
|
|
93
|
-
getSubscriptionCreateParams?: (args: {
|
|
94
|
-
user: { id: string; email?: string; name?: string; [key: string]: unknown }
|
|
95
|
-
session: unknown
|
|
96
|
-
plan: RazorpayPlan
|
|
97
|
-
subscription: SubscriptionRecord
|
|
98
|
-
}) => Promise<{ params?: Record<string, unknown> }>
|
|
99
|
-
onSubscriptionCreated?: (args: {
|
|
100
|
-
razorpaySubscription: RazorpaySubscription
|
|
101
|
-
subscription: SubscriptionRecord
|
|
102
|
-
plan: RazorpayPlan
|
|
103
|
-
}) => Promise<void>
|
|
104
|
-
onSubscriptionActivated?: (args: {
|
|
105
|
-
event: string
|
|
106
|
-
razorpaySubscription: RazorpaySubscription
|
|
107
|
-
subscription: SubscriptionRecord
|
|
108
|
-
plan: RazorpayPlan
|
|
109
|
-
}) => Promise<void>
|
|
110
|
-
onSubscriptionUpdate?: (args: { event: string; subscription: SubscriptionRecord }) => Promise<void>
|
|
111
|
-
onSubscriptionCancel?: (args: {
|
|
112
|
-
event: string
|
|
113
|
-
razorpaySubscription: RazorpaySubscription
|
|
114
|
-
subscription: SubscriptionRecord
|
|
115
|
-
}) => Promise<void>
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** User record shape used by the Razorpay plugin (customer ID on user). */
|
|
119
|
-
export interface RazorpayUserRecord {
|
|
120
|
-
id: string
|
|
121
|
-
email?: string
|
|
122
|
-
name?: string
|
|
123
|
-
razorpayCustomerId?: string | null
|
|
124
|
-
[key: string]: unknown
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** Razorpay webhook event types. */
|
|
128
|
-
export type RazorpayWebhookEvent =
|
|
129
|
-
| 'subscription.authenticated'
|
|
130
|
-
| 'subscription.activated'
|
|
131
|
-
| 'subscription.charged'
|
|
132
|
-
| 'subscription.cancelled'
|
|
133
|
-
| 'subscription.paused'
|
|
134
|
-
| 'subscription.resumed'
|
|
135
|
-
| 'subscription.pending'
|
|
136
|
-
| 'subscription.halted'
|
|
137
|
-
| 'subscription.expired'
|
|
138
|
-
|
|
139
|
-
export interface RazorpayWebhookPayload {
|
|
140
|
-
event: RazorpayWebhookEvent
|
|
141
|
-
subscription: {
|
|
142
|
-
id: string
|
|
143
|
-
plan_id: string
|
|
144
|
-
status: string
|
|
145
|
-
current_start?: number
|
|
146
|
-
current_end?: number
|
|
147
|
-
[key: string]: unknown
|
|
148
|
-
}
|
|
149
|
-
payment?: {
|
|
150
|
-
id: string
|
|
151
|
-
amount: number
|
|
152
|
-
currency: string
|
|
153
|
-
[key: string]: unknown
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface RazorpayWebhookContext {
|
|
158
|
-
userId: string
|
|
159
|
-
user: { id: string; email?: string; name?: string; [key: string]: unknown }
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export type OnWebhookEventCallback = (
|
|
163
|
-
payload: RazorpayWebhookPayload,
|
|
164
|
-
context: RazorpayWebhookContext
|
|
165
|
-
) => Promise<void>
|
|
166
|
-
|
|
167
|
-
/** Main plugin options: client, webhook secret, customer creation, subscription config, callbacks. */
|
|
168
|
-
export interface RazorpayPluginOptions {
|
|
169
|
-
/** Initialized Razorpay client instance. */
|
|
170
|
-
razorpayClient: import('razorpay')
|
|
171
|
-
/** Webhook secret for signature verification. */
|
|
172
|
-
razorpayWebhookSecret?: string
|
|
173
|
-
/** API key secret for payment signature verification. When set, enables POST /razorpay/verify-payment (same secret as Razorpay client, not webhook secret). */
|
|
174
|
-
razorpayKeySecret?: string
|
|
175
|
-
/** Create Razorpay customer when user signs up. Default: false. */
|
|
176
|
-
createCustomerOnSignUp?: boolean
|
|
177
|
-
/** Called after a Razorpay customer is created. */
|
|
178
|
-
onCustomerCreate?: (args: {
|
|
179
|
-
user: RazorpayUserRecord
|
|
180
|
-
razorpayCustomer: { id: string; [key: string]: unknown }
|
|
181
|
-
}) => Promise<void>
|
|
182
|
-
/** Custom params (e.g. notes) when creating Razorpay customer. */
|
|
183
|
-
getCustomerCreateParams?: (args: {
|
|
184
|
-
user: RazorpayUserRecord
|
|
185
|
-
session: unknown
|
|
186
|
-
}) => Promise<{ params?: Record<string, unknown> }>
|
|
187
|
-
/** Subscription feature config (plans, callbacks). */
|
|
188
|
-
subscription?: SubscriptionOptions
|
|
189
|
-
/** Global callback for all processed webhook events. */
|
|
190
|
-
onEvent?: (event: { event: string; [key: string]: unknown }) => Promise<void>
|
|
191
|
-
/** Legacy: callback after webhook events are processed (payload + context). */
|
|
192
|
-
onWebhookEvent?: OnWebhookEventCallback
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export interface RazorpaySuccessResponse<T = unknown> {
|
|
196
|
-
success: true
|
|
197
|
-
data: T
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export interface RazorpayErrorResponse {
|
|
201
|
-
success: false
|
|
202
|
-
error: { code: string; description: string; [key: string]: unknown }
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export type RazorpayApiResponse<T = unknown> =
|
|
206
|
-
| RazorpaySuccessResponse<T>
|
|
207
|
-
| RazorpayErrorResponse
|