razorpay-react-checkout 1.2.0 → 1.3.1

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.
Files changed (47) hide show
  1. package/README.md +51 -0
  2. package/dist/index.d.mts +255 -0
  3. package/dist/index.d.ts +255 -9
  4. package/dist/index.js +414 -8
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +398 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/server.d.mts +29 -0
  9. package/dist/server.d.ts +29 -0
  10. package/dist/server.js +34 -0
  11. package/dist/server.js.map +1 -0
  12. package/dist/server.mjs +28 -0
  13. package/dist/server.mjs.map +1 -0
  14. package/package.json +13 -3
  15. package/dist/components/RazorpayButton.d.ts +0 -10
  16. package/dist/components/RazorpayButton.d.ts.map +0 -1
  17. package/dist/components/RazorpayButton.js +0 -27
  18. package/dist/components/RazorpayButton.js.map +0 -1
  19. package/dist/components/RazorpayListener.d.ts +0 -8
  20. package/dist/components/RazorpayListener.d.ts.map +0 -1
  21. package/dist/components/RazorpayListener.js +0 -32
  22. package/dist/components/RazorpayListener.js.map +0 -1
  23. package/dist/components/RazorpayProvider.d.ts +0 -25
  24. package/dist/components/RazorpayProvider.d.ts.map +0 -1
  25. package/dist/components/RazorpayProvider.js +0 -98
  26. package/dist/components/RazorpayProvider.js.map +0 -1
  27. package/dist/hooks/useRazorpay.d.ts +0 -27
  28. package/dist/hooks/useRazorpay.d.ts.map +0 -1
  29. package/dist/hooks/useRazorpay.js +0 -72
  30. package/dist/hooks/useRazorpay.js.map +0 -1
  31. package/dist/hooks/useRazorpaySuspense.d.ts +0 -6
  32. package/dist/hooks/useRazorpaySuspense.d.ts.map +0 -1
  33. package/dist/hooks/useRazorpaySuspense.js +0 -86
  34. package/dist/hooks/useRazorpaySuspense.js.map +0 -1
  35. package/dist/index.d.ts.map +0 -1
  36. package/dist/lib/script-loader.d.ts +0 -2
  37. package/dist/lib/script-loader.d.ts.map +0 -1
  38. package/dist/lib/script-loader.js +0 -43
  39. package/dist/lib/script-loader.js.map +0 -1
  40. package/dist/types.d.ts +0 -140
  41. package/dist/types.d.ts.map +0 -1
  42. package/dist/types.js +0 -2
  43. package/dist/types.js.map +0 -1
  44. package/dist/utils.d.ts +0 -16
  45. package/dist/utils.d.ts.map +0 -1
  46. package/dist/utils.js +0 -20
  47. package/dist/utils.js.map +0 -1
package/README.md CHANGED
@@ -230,6 +230,57 @@ Returns an object with the following properties:
230
230
  - `Razorpay`: `RazorpayConstructor | null` - The raw Razorpay constructor (available on `window`).
231
231
  - `openRazorpay`: `(options: RazorpayOptions) => RazorpayInstance | null` - Helper function to initialize and open the checkout.
232
232
 
233
+ ### Server-Side Utilities (New!)
234
+
235
+ Verify Razorpay signatures easily on your backend (Next.js API routes, Express, etc.).
236
+
237
+ ```ts
238
+ import { verifySignature } from 'razorpay-react-checkout/server';
239
+
240
+ // In your API route
241
+ const isValid = verifySignature({
242
+ order_id: 'order_123',
243
+ payment_id: 'pay_123',
244
+ signature: 'sig_123'
245
+ }, process.env.RAZORPAY_KEY_SECRET);
246
+
247
+ if (isValid) {
248
+ // Signature verified
249
+ }
250
+ ```
251
+
252
+ ### Better Error Handling
253
+
254
+ Parse cryptic Razorpay error objects into user-friendly messages.
255
+
256
+ ```tsx
257
+ import { getReadableErrorMessage, RazorpayEvents, RazorpayErrorCodes } from 'razorpay-react-checkout';
258
+
259
+ // ...
260
+ rzp.on(RazorpayEvents.PAYMENT_FAILED, (response) => {
261
+ const message = getReadableErrorMessage(response.error);
262
+ toast.error(message);
263
+
264
+ if (response.error.code === RazorpayErrorCodes.BAD_REQUEST_ERROR) {
265
+ // Handle specific error
266
+ }
267
+ });
268
+ ```
269
+
270
+ ### Enhanced Button Component
271
+
272
+ Now supports variants and Tailwind classes!
273
+
274
+ ```tsx
275
+ <RazorpayButton
276
+ options={...}
277
+ variant="primary" // primary, secondary, outline, ghost, danger
278
+ className="w-full"
279
+ >
280
+ Pae Now
281
+ </RazorpayButton>
282
+ ```
283
+
233
284
  ## License
234
285
 
235
286
  MIT
@@ -0,0 +1,255 @@
1
+ import React$1, { ReactNode } from 'react';
2
+
3
+ interface RazorpayTheme {
4
+ /**
5
+ * Hex code for the color of the checkout form.
6
+ */
7
+ color?: string;
8
+ /**
9
+ * Hex code for the backdrop color of the checkout modal.
10
+ */
11
+ backdrop_color?: string;
12
+ /**
13
+ * Hide the top bar of the checkout form.
14
+ */
15
+ hide_topbar?: boolean;
16
+ /**
17
+ * Image URL for the logo in the top bar.
18
+ */
19
+ image_padding?: string;
20
+ }
21
+ interface RazorpayModalOptions {
22
+ backdropclose?: boolean;
23
+ escape?: boolean;
24
+ handleback?: boolean;
25
+ confirm_close?: boolean;
26
+ ondismiss?: () => void;
27
+ animation?: boolean;
28
+ }
29
+ interface RazorpayPrefillOptions {
30
+ name?: string;
31
+ email?: string;
32
+ contact?: string;
33
+ method?: 'card' | 'netbanking' | 'wallet' | 'emi' | 'upi';
34
+ }
35
+ interface RazorpayTransfer {
36
+ /**
37
+ * The account ID of the linked account to which the transfer is to be made.
38
+ */
39
+ account: string;
40
+ /**
41
+ * The amount to be transferred to the linked account in currency subunits.
42
+ */
43
+ amount: number;
44
+ /**
45
+ * The currency in which the transfer is to be made.
46
+ */
47
+ currency: string;
48
+ /**
49
+ * A set of key-value pairs that you can attach to the transfer.
50
+ */
51
+ notes?: Record<string, string>;
52
+ /**
53
+ * Indicates whether the transfer should be put on hold.
54
+ */
55
+ on_hold?: boolean;
56
+ /**
57
+ * The timestamp at which the transfer should be settled.
58
+ */
59
+ on_hold_until?: number;
60
+ }
61
+ interface RazorpaySuccessResponse {
62
+ razorpay_payment_id: string;
63
+ razorpay_order_id?: string;
64
+ razorpay_signature?: string;
65
+ razorpay_subscription_id?: string;
66
+ }
67
+ interface RazorpayError {
68
+ code: string;
69
+ description: string;
70
+ source: string;
71
+ step: string;
72
+ reason: string;
73
+ metadata: {
74
+ order_id: string;
75
+ payment_id?: string;
76
+ };
77
+ }
78
+ interface RazorpayErrorResponse {
79
+ error: RazorpayError;
80
+ }
81
+ interface RazorpayOptions {
82
+ key: string;
83
+ amount: number | string;
84
+ currency: string;
85
+ name?: string;
86
+ description?: string;
87
+ image?: string;
88
+ order_id?: string;
89
+ handler?: (response: RazorpaySuccessResponse) => void;
90
+ prefill?: RazorpayPrefillOptions;
91
+ notes?: Record<string, string>;
92
+ theme?: RazorpayTheme;
93
+ modal?: RazorpayModalOptions;
94
+ subscription_id?: string;
95
+ subscription_card_change?: boolean;
96
+ recurring?: boolean;
97
+ callback_url?: string;
98
+ redirect?: boolean;
99
+ customer_id?: string;
100
+ remember_customer?: boolean;
101
+ timeout?: number;
102
+ readonly?: {
103
+ contact?: boolean;
104
+ email?: boolean;
105
+ name?: boolean;
106
+ };
107
+ hidden?: {
108
+ contact?: boolean;
109
+ email?: boolean;
110
+ };
111
+ send_sms_hash?: boolean;
112
+ allow_rotation?: boolean;
113
+ retry?: {
114
+ enabled?: boolean;
115
+ max_count?: number;
116
+ };
117
+ config?: {
118
+ display?: {
119
+ language?: 'en' | 'ben' | 'hi' | 'mar' | 'guj' | 'tam' | 'tel';
120
+ };
121
+ };
122
+ /**
123
+ * Transfers for Razorpay Route (Split Payments)
124
+ */
125
+ transfers?: RazorpayTransfer[];
126
+ }
127
+ interface RazorpayInstance {
128
+ open: () => void;
129
+ on: (event: string, callback: (response: RazorpayErrorResponse | any) => void) => void;
130
+ close: () => void;
131
+ }
132
+ interface RazorpayConstructor {
133
+ new (options: RazorpayOptions): RazorpayInstance;
134
+ open: (options: RazorpayOptions) => void;
135
+ configure: (options: RazorpayOptions) => void;
136
+ }
137
+ declare global {
138
+ interface Window {
139
+ Razorpay?: RazorpayConstructor;
140
+ }
141
+ }
142
+
143
+ declare const useRazorpay: () => {
144
+ openRazorpay: (options: RazorpayOptions) => RazorpayInstance | null;
145
+ isLoaded: boolean;
146
+ isLoading: boolean;
147
+ error: Error | null;
148
+ Razorpay: RazorpayConstructor | null;
149
+ defaultOptions?: Partial<RazorpayOptions>;
150
+ onPaymentSuccess: (response: RazorpaySuccessResponse) => void;
151
+ onPaymentError: (error: RazorpayErrorResponse) => void;
152
+ registerPaymentSuccess: (cb: (response: RazorpaySuccessResponse) => void) => () => void;
153
+ registerPaymentError: (cb: (error: RazorpayErrorResponse) => void) => () => void;
154
+ debug?: boolean;
155
+ } | {
156
+ openRazorpay: (options: RazorpayOptions) => RazorpayInstance | null;
157
+ isLoaded: boolean;
158
+ isLoading: boolean;
159
+ error: Error | null;
160
+ Razorpay: RazorpayConstructor | null | undefined;
161
+ defaultOptions: undefined;
162
+ onPaymentSuccess: () => void;
163
+ onPaymentError: () => void;
164
+ registerPaymentSuccess: () => () => void;
165
+ registerPaymentError: () => () => void;
166
+ debug: boolean;
167
+ };
168
+
169
+ declare const useRazorpaySuspense: () => {
170
+ openRazorpay: (options: RazorpayOptions) => RazorpayInstance | null;
171
+ Razorpay: RazorpayConstructor | null | undefined;
172
+ };
173
+
174
+ interface RazorpayContextType {
175
+ isLoaded: boolean;
176
+ isLoading: boolean;
177
+ error: Error | null;
178
+ Razorpay: RazorpayConstructor | null;
179
+ defaultOptions?: Partial<RazorpayOptions>;
180
+ onPaymentSuccess: (response: RazorpaySuccessResponse) => void;
181
+ onPaymentError: (error: RazorpayErrorResponse) => void;
182
+ registerPaymentSuccess: (cb: (response: RazorpaySuccessResponse) => void) => () => void;
183
+ registerPaymentError: (cb: (error: RazorpayErrorResponse) => void) => () => void;
184
+ debug?: boolean;
185
+ }
186
+ interface RazorpayProviderProps {
187
+ children: ReactNode;
188
+ options?: Partial<RazorpayOptions>;
189
+ onPaymentSuccess?: (response: RazorpaySuccessResponse) => void;
190
+ onPaymentError?: (error: RazorpayErrorResponse) => void;
191
+ debug?: boolean;
192
+ }
193
+ declare const RazorpayProvider: React$1.FC<RazorpayProviderProps>;
194
+ declare const useRazorpayContext: () => RazorpayContextType | undefined;
195
+
196
+ interface RazorpayButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
197
+ options: RazorpayOptions;
198
+ onSuccess?: (response: RazorpaySuccessResponse) => void;
199
+ onFailure?: (response: RazorpayErrorResponse) => void;
200
+ variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger';
201
+ }
202
+ declare const RazorpayButton: React$1.FC<RazorpayButtonProps>;
203
+
204
+ interface RazorpayListenerProps {
205
+ onPaymentSuccess?: (response: RazorpaySuccessResponse) => void;
206
+ onPaymentError?: (error: RazorpayErrorResponse) => void;
207
+ }
208
+ declare const RazorpayListener: React.FC<RazorpayListenerProps>;
209
+
210
+ /**
211
+ * Formats a currency amount.
212
+ *
213
+ * If the amount is passing in rupees (e.g. 500), it converts it to paise (50000) for Razorpay.
214
+ * It assumes the amount is in the base unit (e.g. Rupees) and converts to the smallest unit (e.g. Paise).
215
+ *
216
+ * @param amount - The amount in the base unit (e.g. 500 Rupees)
217
+ * @returns The amount in the smallest unit (e.g. 50000 Paise)
218
+ */
219
+ declare const formatAmount: (amount: number) => number;
220
+ /**
221
+ * Checks if the amount is already in paise (heuristic).
222
+ * This is just a helper, use with caution.
223
+ */
224
+ declare const isPaise: (amount: number) => boolean;
225
+ /**
226
+ * Parses a Razorpay error object and returns a human-readable message.
227
+ *
228
+ * @param error - The error object returned by Razorpay payment.failed event.
229
+ * @returns A user-friendly error message string.
230
+ */
231
+ declare const getReadableErrorMessage: (error: any) => string;
232
+
233
+ /**
234
+ * Standardized Razorpay events.
235
+ * Use these to avoid magic strings when listening to events.
236
+ */
237
+ declare enum RazorpayEvents {
238
+ PAYMENT_FAILED = "payment.failed",
239
+ PAYMENT_AUTHORIZED = "payment.authorized",
240
+ PAYMENT_CAPTURED = "payment.captured",
241
+ EXTERNAL_WALLET_SELECTED = "external_wallet.selected"
242
+ }
243
+ /**
244
+ * Standardized Razorpay error codes.
245
+ * Use these to handle specific error scenarios.
246
+ */
247
+ declare enum RazorpayErrorCodes {
248
+ BAD_REQUEST_ERROR = "BAD_REQUEST_ERROR",
249
+ GATEWAY_ERROR = "GATEWAY_ERROR",
250
+ SERVER_ERROR = "SERVER_ERROR"
251
+ }
252
+
253
+ declare const loadRazorpayScript: () => Promise<boolean>;
254
+
255
+ export { RazorpayButton, type RazorpayButtonProps, type RazorpayConstructor, type RazorpayError, RazorpayErrorCodes, type RazorpayErrorResponse, RazorpayEvents, type RazorpayInstance, RazorpayListener, type RazorpayModalOptions, type RazorpayOptions, type RazorpayPrefillOptions, RazorpayProvider, type RazorpaySuccessResponse, type RazorpayTheme, type RazorpayTransfer, formatAmount, getReadableErrorMessage, isPaise, loadRazorpayScript, useRazorpay, useRazorpayContext, useRazorpaySuspense };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,255 @@
1
- export * from './types';
2
- export * from './hooks/useRazorpay';
3
- export * from './hooks/useRazorpaySuspense';
4
- export * from './components/RazorpayProvider';
5
- export * from './components/RazorpayButton';
6
- export * from './components/RazorpayListener';
7
- export * from './utils';
8
- export { loadRazorpayScript } from './lib/script-loader';
9
- //# sourceMappingURL=index.d.ts.map
1
+ import React$1, { ReactNode } from 'react';
2
+
3
+ interface RazorpayTheme {
4
+ /**
5
+ * Hex code for the color of the checkout form.
6
+ */
7
+ color?: string;
8
+ /**
9
+ * Hex code for the backdrop color of the checkout modal.
10
+ */
11
+ backdrop_color?: string;
12
+ /**
13
+ * Hide the top bar of the checkout form.
14
+ */
15
+ hide_topbar?: boolean;
16
+ /**
17
+ * Image URL for the logo in the top bar.
18
+ */
19
+ image_padding?: string;
20
+ }
21
+ interface RazorpayModalOptions {
22
+ backdropclose?: boolean;
23
+ escape?: boolean;
24
+ handleback?: boolean;
25
+ confirm_close?: boolean;
26
+ ondismiss?: () => void;
27
+ animation?: boolean;
28
+ }
29
+ interface RazorpayPrefillOptions {
30
+ name?: string;
31
+ email?: string;
32
+ contact?: string;
33
+ method?: 'card' | 'netbanking' | 'wallet' | 'emi' | 'upi';
34
+ }
35
+ interface RazorpayTransfer {
36
+ /**
37
+ * The account ID of the linked account to which the transfer is to be made.
38
+ */
39
+ account: string;
40
+ /**
41
+ * The amount to be transferred to the linked account in currency subunits.
42
+ */
43
+ amount: number;
44
+ /**
45
+ * The currency in which the transfer is to be made.
46
+ */
47
+ currency: string;
48
+ /**
49
+ * A set of key-value pairs that you can attach to the transfer.
50
+ */
51
+ notes?: Record<string, string>;
52
+ /**
53
+ * Indicates whether the transfer should be put on hold.
54
+ */
55
+ on_hold?: boolean;
56
+ /**
57
+ * The timestamp at which the transfer should be settled.
58
+ */
59
+ on_hold_until?: number;
60
+ }
61
+ interface RazorpaySuccessResponse {
62
+ razorpay_payment_id: string;
63
+ razorpay_order_id?: string;
64
+ razorpay_signature?: string;
65
+ razorpay_subscription_id?: string;
66
+ }
67
+ interface RazorpayError {
68
+ code: string;
69
+ description: string;
70
+ source: string;
71
+ step: string;
72
+ reason: string;
73
+ metadata: {
74
+ order_id: string;
75
+ payment_id?: string;
76
+ };
77
+ }
78
+ interface RazorpayErrorResponse {
79
+ error: RazorpayError;
80
+ }
81
+ interface RazorpayOptions {
82
+ key: string;
83
+ amount: number | string;
84
+ currency: string;
85
+ name?: string;
86
+ description?: string;
87
+ image?: string;
88
+ order_id?: string;
89
+ handler?: (response: RazorpaySuccessResponse) => void;
90
+ prefill?: RazorpayPrefillOptions;
91
+ notes?: Record<string, string>;
92
+ theme?: RazorpayTheme;
93
+ modal?: RazorpayModalOptions;
94
+ subscription_id?: string;
95
+ subscription_card_change?: boolean;
96
+ recurring?: boolean;
97
+ callback_url?: string;
98
+ redirect?: boolean;
99
+ customer_id?: string;
100
+ remember_customer?: boolean;
101
+ timeout?: number;
102
+ readonly?: {
103
+ contact?: boolean;
104
+ email?: boolean;
105
+ name?: boolean;
106
+ };
107
+ hidden?: {
108
+ contact?: boolean;
109
+ email?: boolean;
110
+ };
111
+ send_sms_hash?: boolean;
112
+ allow_rotation?: boolean;
113
+ retry?: {
114
+ enabled?: boolean;
115
+ max_count?: number;
116
+ };
117
+ config?: {
118
+ display?: {
119
+ language?: 'en' | 'ben' | 'hi' | 'mar' | 'guj' | 'tam' | 'tel';
120
+ };
121
+ };
122
+ /**
123
+ * Transfers for Razorpay Route (Split Payments)
124
+ */
125
+ transfers?: RazorpayTransfer[];
126
+ }
127
+ interface RazorpayInstance {
128
+ open: () => void;
129
+ on: (event: string, callback: (response: RazorpayErrorResponse | any) => void) => void;
130
+ close: () => void;
131
+ }
132
+ interface RazorpayConstructor {
133
+ new (options: RazorpayOptions): RazorpayInstance;
134
+ open: (options: RazorpayOptions) => void;
135
+ configure: (options: RazorpayOptions) => void;
136
+ }
137
+ declare global {
138
+ interface Window {
139
+ Razorpay?: RazorpayConstructor;
140
+ }
141
+ }
142
+
143
+ declare const useRazorpay: () => {
144
+ openRazorpay: (options: RazorpayOptions) => RazorpayInstance | null;
145
+ isLoaded: boolean;
146
+ isLoading: boolean;
147
+ error: Error | null;
148
+ Razorpay: RazorpayConstructor | null;
149
+ defaultOptions?: Partial<RazorpayOptions>;
150
+ onPaymentSuccess: (response: RazorpaySuccessResponse) => void;
151
+ onPaymentError: (error: RazorpayErrorResponse) => void;
152
+ registerPaymentSuccess: (cb: (response: RazorpaySuccessResponse) => void) => () => void;
153
+ registerPaymentError: (cb: (error: RazorpayErrorResponse) => void) => () => void;
154
+ debug?: boolean;
155
+ } | {
156
+ openRazorpay: (options: RazorpayOptions) => RazorpayInstance | null;
157
+ isLoaded: boolean;
158
+ isLoading: boolean;
159
+ error: Error | null;
160
+ Razorpay: RazorpayConstructor | null | undefined;
161
+ defaultOptions: undefined;
162
+ onPaymentSuccess: () => void;
163
+ onPaymentError: () => void;
164
+ registerPaymentSuccess: () => () => void;
165
+ registerPaymentError: () => () => void;
166
+ debug: boolean;
167
+ };
168
+
169
+ declare const useRazorpaySuspense: () => {
170
+ openRazorpay: (options: RazorpayOptions) => RazorpayInstance | null;
171
+ Razorpay: RazorpayConstructor | null | undefined;
172
+ };
173
+
174
+ interface RazorpayContextType {
175
+ isLoaded: boolean;
176
+ isLoading: boolean;
177
+ error: Error | null;
178
+ Razorpay: RazorpayConstructor | null;
179
+ defaultOptions?: Partial<RazorpayOptions>;
180
+ onPaymentSuccess: (response: RazorpaySuccessResponse) => void;
181
+ onPaymentError: (error: RazorpayErrorResponse) => void;
182
+ registerPaymentSuccess: (cb: (response: RazorpaySuccessResponse) => void) => () => void;
183
+ registerPaymentError: (cb: (error: RazorpayErrorResponse) => void) => () => void;
184
+ debug?: boolean;
185
+ }
186
+ interface RazorpayProviderProps {
187
+ children: ReactNode;
188
+ options?: Partial<RazorpayOptions>;
189
+ onPaymentSuccess?: (response: RazorpaySuccessResponse) => void;
190
+ onPaymentError?: (error: RazorpayErrorResponse) => void;
191
+ debug?: boolean;
192
+ }
193
+ declare const RazorpayProvider: React$1.FC<RazorpayProviderProps>;
194
+ declare const useRazorpayContext: () => RazorpayContextType | undefined;
195
+
196
+ interface RazorpayButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
197
+ options: RazorpayOptions;
198
+ onSuccess?: (response: RazorpaySuccessResponse) => void;
199
+ onFailure?: (response: RazorpayErrorResponse) => void;
200
+ variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger';
201
+ }
202
+ declare const RazorpayButton: React$1.FC<RazorpayButtonProps>;
203
+
204
+ interface RazorpayListenerProps {
205
+ onPaymentSuccess?: (response: RazorpaySuccessResponse) => void;
206
+ onPaymentError?: (error: RazorpayErrorResponse) => void;
207
+ }
208
+ declare const RazorpayListener: React.FC<RazorpayListenerProps>;
209
+
210
+ /**
211
+ * Formats a currency amount.
212
+ *
213
+ * If the amount is passing in rupees (e.g. 500), it converts it to paise (50000) for Razorpay.
214
+ * It assumes the amount is in the base unit (e.g. Rupees) and converts to the smallest unit (e.g. Paise).
215
+ *
216
+ * @param amount - The amount in the base unit (e.g. 500 Rupees)
217
+ * @returns The amount in the smallest unit (e.g. 50000 Paise)
218
+ */
219
+ declare const formatAmount: (amount: number) => number;
220
+ /**
221
+ * Checks if the amount is already in paise (heuristic).
222
+ * This is just a helper, use with caution.
223
+ */
224
+ declare const isPaise: (amount: number) => boolean;
225
+ /**
226
+ * Parses a Razorpay error object and returns a human-readable message.
227
+ *
228
+ * @param error - The error object returned by Razorpay payment.failed event.
229
+ * @returns A user-friendly error message string.
230
+ */
231
+ declare const getReadableErrorMessage: (error: any) => string;
232
+
233
+ /**
234
+ * Standardized Razorpay events.
235
+ * Use these to avoid magic strings when listening to events.
236
+ */
237
+ declare enum RazorpayEvents {
238
+ PAYMENT_FAILED = "payment.failed",
239
+ PAYMENT_AUTHORIZED = "payment.authorized",
240
+ PAYMENT_CAPTURED = "payment.captured",
241
+ EXTERNAL_WALLET_SELECTED = "external_wallet.selected"
242
+ }
243
+ /**
244
+ * Standardized Razorpay error codes.
245
+ * Use these to handle specific error scenarios.
246
+ */
247
+ declare enum RazorpayErrorCodes {
248
+ BAD_REQUEST_ERROR = "BAD_REQUEST_ERROR",
249
+ GATEWAY_ERROR = "GATEWAY_ERROR",
250
+ SERVER_ERROR = "SERVER_ERROR"
251
+ }
252
+
253
+ declare const loadRazorpayScript: () => Promise<boolean>;
254
+
255
+ export { RazorpayButton, type RazorpayButtonProps, type RazorpayConstructor, type RazorpayError, RazorpayErrorCodes, type RazorpayErrorResponse, RazorpayEvents, type RazorpayInstance, RazorpayListener, type RazorpayModalOptions, type RazorpayOptions, type RazorpayPrefillOptions, RazorpayProvider, type RazorpaySuccessResponse, type RazorpayTheme, type RazorpayTransfer, formatAmount, getReadableErrorMessage, isPaise, loadRazorpayScript, useRazorpay, useRazorpayContext, useRazorpaySuspense };