@nozle-js/react 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -17,20 +17,60 @@ interface ScheduledCheckoutResult {
17
17
  subscription_id?: string;
18
18
  plan_code?: string;
19
19
  }
20
+ interface RazorpayCheckoutResult {
21
+ type: 'razorpay';
22
+ checkout_id: string;
23
+ key_id: string;
24
+ order_id: string;
25
+ amount_cents: number;
26
+ currency: string;
27
+ expires_at?: string;
28
+ invoice_id?: string;
29
+ customer_id?: string;
30
+ recurring?: boolean;
31
+ mandate_max_amount_cents?: number;
32
+ }
33
+ interface ProcessingCheckoutResult {
34
+ type: 'processing';
35
+ checkout_id: string;
36
+ status: string;
37
+ }
38
+ interface HostedCheckoutResult {
39
+ type: 'hosted';
40
+ payment_url: string;
41
+ checkout_id?: string;
42
+ }
43
+ interface RazorpayVerification {
44
+ razorpay_order_id: string;
45
+ razorpay_payment_id: string;
46
+ razorpay_signature: string;
47
+ }
48
+ interface CheckoutStatus {
49
+ checkout_id: string;
50
+ provider: 'razorpay';
51
+ status: 'processing' | 'awaiting_payment' | 'succeeded' | 'failed' | 'expired' | 'needs_review';
52
+ fulfillment_status: 'pending' | 'processing' | 'succeeded';
53
+ amount_cents?: number;
54
+ currency?: string;
55
+ invoice_id?: string | null;
56
+ checkout?: CheckoutResult;
57
+ }
58
+ /** Call your authenticated merchant backend, which calls Nozle using its secret key. */
59
+ type VerifyCheckout = (checkoutId: string, verification: RazorpayVerification) => Promise<CheckoutStatus>;
60
+ type GetCheckoutStatus = (checkoutId: string) => Promise<CheckoutStatus>;
20
61
  type CheckoutResult = {
21
62
  type: 'stripe';
22
63
  url?: string;
23
64
  clientSecret?: string;
24
65
  client_secret?: string;
25
- } | {
26
- type: 'razorpay';
27
- orderId: string;
28
- } | CompletedCheckoutResult | ScheduledCheckoutResult | {
66
+ } | RazorpayCheckoutResult | ProcessingCheckoutResult | HostedCheckoutResult | CompletedCheckoutResult | ScheduledCheckoutResult | {
29
67
  url: string;
30
68
  };
31
69
  interface CreateCheckoutInput {
32
70
  planCode: string;
33
71
  returnUrl: string;
72
+ idempotencyKey?: string;
73
+ registerMandate?: boolean;
34
74
  }
35
75
  type CreateCheckout = (input: CreateCheckoutInput) => Promise<CheckoutResult>;
36
76
  interface NozleClient {
@@ -41,15 +81,19 @@ interface NozleClient {
41
81
  interface BillingContextValue {
42
82
  client: NozleClient;
43
83
  createCheckout?: CreateCheckout;
84
+ verifyCheckout?: VerifyCheckout;
85
+ getCheckoutStatus?: GetCheckoutStatus;
44
86
  }
45
87
  declare const BillingContext: React__default.Context<BillingContextValue | null>;
46
88
  interface BillingProviderProps {
47
89
  publishableKey: string;
48
90
  createCheckout?: CreateCheckout;
91
+ verifyCheckout?: VerifyCheckout;
92
+ getCheckoutStatus?: GetCheckoutStatus;
49
93
  baseUrl?: string;
50
94
  children: ReactNode;
51
95
  }
52
- declare function BillingProvider({ publishableKey, createCheckout, baseUrl, children, }: BillingProviderProps): React__default.ReactElement;
96
+ declare function BillingProvider({ publishableKey, createCheckout, verifyCheckout, getCheckoutStatus, baseUrl, children, }: BillingProviderProps): React__default.ReactElement;
53
97
  declare function useOptionalBillingContext(): BillingContextValue | null;
54
98
  declare function useBillingContext(): BillingContextValue;
55
99
  declare function useNozleClient(): NozleClient;
@@ -156,39 +200,55 @@ interface PlanComparisonProps {
156
200
  */
157
201
  declare function PlanComparison({ plans, features, }: PlanComparisonProps): React__default.ReactElement;
158
202
 
159
- interface CheckoutButtonProps {
203
+ interface RazorpayActions {
204
+ verifyCheckout?: VerifyCheckout;
205
+ getCheckoutStatus?: GetCheckoutStatus;
206
+ onSuccess?: (paymentId: string) => void;
207
+ onProcessing?: (status: CheckoutStatus) => void;
208
+ onDismiss?: () => void;
209
+ onError?: (error: Error) => void;
210
+ }
211
+ interface RazorpayOptions {
212
+ key: string;
213
+ order_id: string;
214
+ amount: number;
215
+ currency: string;
216
+ customer_id?: string;
217
+ recurring?: '1';
218
+ handler: (response: RazorpayVerification) => void;
219
+ modal: {
220
+ ondismiss: () => void;
221
+ };
222
+ }
223
+ interface RazorpayInstance {
224
+ open(): void;
225
+ close(): void;
226
+ on(event: string, callback: () => void): void;
227
+ }
228
+ declare global {
229
+ interface Window {
230
+ Razorpay?: new (options: RazorpayOptions) => RazorpayInstance;
231
+ }
232
+ }
233
+
234
+ interface CheckoutButtonProps extends Omit<RazorpayActions, 'verifyCheckout' | 'getCheckoutStatus'> {
160
235
  planCode: string;
161
236
  returnUrl?: string;
162
237
  label?: string;
163
238
  className?: string;
164
239
  style?: React__default.CSSProperties;
165
240
  onError?: (error: Error) => void;
241
+ /** @deprecated The server supplies the public Razorpay key in the checkout response. */
166
242
  razorpayKeyId?: string;
243
+ registerMandate?: boolean;
167
244
  onStripeClientSecret?: (clientSecret: string) => void;
168
245
  onSuccess?: (paymentId: string) => void;
169
246
  onComplete?: (result: CompletedCheckoutResult) => void;
170
247
  onScheduled?: (result: ScheduledCheckoutResult) => void;
171
248
  }
172
- interface RazorpayOptions {
173
- key: string;
174
- order_id: string;
175
- handler: (response: {
176
- razorpay_payment_id: string;
177
- }) => void;
178
- modal?: {
179
- ondismiss?: () => void;
180
- };
181
- }
182
- declare global {
183
- interface Window {
184
- Razorpay: new (options: RazorpayOptions) => {
185
- open(): void;
186
- };
187
- }
188
- }
189
- declare function CheckoutButton({ planCode, returnUrl, label, className, style, onError, razorpayKeyId, onStripeClientSecret, onSuccess, onComplete, onScheduled, }: CheckoutButtonProps): React__default.ReactElement;
249
+ declare function CheckoutButton({ planCode, returnUrl, label, className, style, onError, razorpayKeyId, registerMandate, onProcessing, onDismiss, onStripeClientSecret, onSuccess, onComplete, onScheduled, }: CheckoutButtonProps): React__default.ReactElement;
190
250
 
191
- interface CheckoutProps {
251
+ interface StripeCheckoutProps {
192
252
  /** Stripe PaymentIntent client secret */
193
253
  clientSecret: string;
194
254
  /** Stripe publishable key */
@@ -223,7 +283,17 @@ interface UseCheckoutResult {
223
283
  error: Error | null;
224
284
  }
225
285
  declare function useCheckout(): UseCheckoutResult;
226
- declare function Checkout({ clientSecret, publishableKey, stripeAccount, returnUrl, submitLabel, onSuccess, onComplete, onError, onReady, className, style, children, }: CheckoutProps): React__default.JSX.Element;
286
+ interface ProviderCheckoutProps {
287
+ checkout: CheckoutResult;
288
+ submitLabel?: string;
289
+ onSuccess?: (paymentId: string) => void;
290
+ onComplete?: () => void;
291
+ onProcessing?: (status: CheckoutStatus) => void;
292
+ onError?: (error: Error) => void;
293
+ className?: string;
294
+ }
295
+ type CheckoutProps = StripeCheckoutProps | ProviderCheckoutProps;
296
+ declare function Checkout(props: CheckoutProps): React__default.JSX.Element;
227
297
 
228
298
  interface ProrationPreview {
229
299
  credit: number;
@@ -457,4 +527,4 @@ interface PaymentMethodDisplayProps {
457
527
  }
458
528
  declare function PaymentMethodDisplay({ paymentMethod, onUpdatePaymentMethod, updateHref, }: PaymentMethodDisplayProps): React.JSX.Element;
459
529
 
460
- export { BillingContext, type BillingContextValue, BillingProvider, type BillingProviderProps, type Plan$1 as CatalogPlan, Checkout, CheckoutButton, type CheckoutButtonProps, type CheckoutProps, type CheckoutResult, type ComparisonFeature, type CompletedCheckoutResult, type CreateCheckout, type CreateCheckoutInput, FeatureGate, type FeatureGateProps, LockedOverlay, type LockedOverlayProps, type NozleClient, type PaymentMethod, PaymentMethodDisplay, type PaymentMethodDisplayProps, type Plan, PlanBadge, type PlanBadgeProps, PlanCard, type PlanCardProps, PlanComparison, type PlanComparisonProps, PlanGate, type PlanGateProps, type PricingPlan, PricingTable, type PricingTableProps, type ProrationPreview, type ScheduledCheckoutResult, UpgradeButton, type UpgradeButtonProps, UpgradeModal, type UpgradeModalProps, UpgradePrompt, type UpgradePromptProps, UsageAlert, type UsageAlertFeature, type UsageAlertProps, UsageDashboard, type UsageDashboardFeature, type UsageDashboardProps, UsageGate, type UsageGateProps, UsageMeter, type UsageMeterProps, type UseCheckoutResult, type UseCheckoutResult$1 as UseCheckoutSessionResult, getUsageMeterColor, useBillingContext, useCheckout, useCheckout$1 as useCheckoutSession, useNozleClient, useOptionalBillingContext, usePlans };
530
+ export { BillingContext, type BillingContextValue, BillingProvider, type BillingProviderProps, type Plan$1 as CatalogPlan, Checkout, CheckoutButton, type CheckoutButtonProps, type CheckoutProps, type CheckoutResult, type CheckoutStatus, type ComparisonFeature, type CompletedCheckoutResult, type CreateCheckout, type CreateCheckoutInput, FeatureGate, type FeatureGateProps, type GetCheckoutStatus, type HostedCheckoutResult, LockedOverlay, type LockedOverlayProps, type NozleClient, type PaymentMethod, PaymentMethodDisplay, type PaymentMethodDisplayProps, type Plan, PlanBadge, type PlanBadgeProps, PlanCard, type PlanCardProps, PlanComparison, type PlanComparisonProps, PlanGate, type PlanGateProps, type PricingPlan, PricingTable, type PricingTableProps, type ProcessingCheckoutResult, type ProrationPreview, type RazorpayCheckoutResult, type RazorpayVerification, type ScheduledCheckoutResult, UpgradeButton, type UpgradeButtonProps, UpgradeModal, type UpgradeModalProps, UpgradePrompt, type UpgradePromptProps, UsageAlert, type UsageAlertFeature, type UsageAlertProps, UsageDashboard, type UsageDashboardFeature, type UsageDashboardProps, UsageGate, type UsageGateProps, UsageMeter, type UsageMeterProps, type UseCheckoutResult, type UseCheckoutResult$1 as UseCheckoutSessionResult, type VerifyCheckout, getUsageMeterColor, useBillingContext, useCheckout, useCheckout$1 as useCheckoutSession, useNozleClient, useOptionalBillingContext, usePlans };
package/dist/index.d.ts CHANGED
@@ -17,20 +17,60 @@ interface ScheduledCheckoutResult {
17
17
  subscription_id?: string;
18
18
  plan_code?: string;
19
19
  }
20
+ interface RazorpayCheckoutResult {
21
+ type: 'razorpay';
22
+ checkout_id: string;
23
+ key_id: string;
24
+ order_id: string;
25
+ amount_cents: number;
26
+ currency: string;
27
+ expires_at?: string;
28
+ invoice_id?: string;
29
+ customer_id?: string;
30
+ recurring?: boolean;
31
+ mandate_max_amount_cents?: number;
32
+ }
33
+ interface ProcessingCheckoutResult {
34
+ type: 'processing';
35
+ checkout_id: string;
36
+ status: string;
37
+ }
38
+ interface HostedCheckoutResult {
39
+ type: 'hosted';
40
+ payment_url: string;
41
+ checkout_id?: string;
42
+ }
43
+ interface RazorpayVerification {
44
+ razorpay_order_id: string;
45
+ razorpay_payment_id: string;
46
+ razorpay_signature: string;
47
+ }
48
+ interface CheckoutStatus {
49
+ checkout_id: string;
50
+ provider: 'razorpay';
51
+ status: 'processing' | 'awaiting_payment' | 'succeeded' | 'failed' | 'expired' | 'needs_review';
52
+ fulfillment_status: 'pending' | 'processing' | 'succeeded';
53
+ amount_cents?: number;
54
+ currency?: string;
55
+ invoice_id?: string | null;
56
+ checkout?: CheckoutResult;
57
+ }
58
+ /** Call your authenticated merchant backend, which calls Nozle using its secret key. */
59
+ type VerifyCheckout = (checkoutId: string, verification: RazorpayVerification) => Promise<CheckoutStatus>;
60
+ type GetCheckoutStatus = (checkoutId: string) => Promise<CheckoutStatus>;
20
61
  type CheckoutResult = {
21
62
  type: 'stripe';
22
63
  url?: string;
23
64
  clientSecret?: string;
24
65
  client_secret?: string;
25
- } | {
26
- type: 'razorpay';
27
- orderId: string;
28
- } | CompletedCheckoutResult | ScheduledCheckoutResult | {
66
+ } | RazorpayCheckoutResult | ProcessingCheckoutResult | HostedCheckoutResult | CompletedCheckoutResult | ScheduledCheckoutResult | {
29
67
  url: string;
30
68
  };
31
69
  interface CreateCheckoutInput {
32
70
  planCode: string;
33
71
  returnUrl: string;
72
+ idempotencyKey?: string;
73
+ registerMandate?: boolean;
34
74
  }
35
75
  type CreateCheckout = (input: CreateCheckoutInput) => Promise<CheckoutResult>;
36
76
  interface NozleClient {
@@ -41,15 +81,19 @@ interface NozleClient {
41
81
  interface BillingContextValue {
42
82
  client: NozleClient;
43
83
  createCheckout?: CreateCheckout;
84
+ verifyCheckout?: VerifyCheckout;
85
+ getCheckoutStatus?: GetCheckoutStatus;
44
86
  }
45
87
  declare const BillingContext: React__default.Context<BillingContextValue | null>;
46
88
  interface BillingProviderProps {
47
89
  publishableKey: string;
48
90
  createCheckout?: CreateCheckout;
91
+ verifyCheckout?: VerifyCheckout;
92
+ getCheckoutStatus?: GetCheckoutStatus;
49
93
  baseUrl?: string;
50
94
  children: ReactNode;
51
95
  }
52
- declare function BillingProvider({ publishableKey, createCheckout, baseUrl, children, }: BillingProviderProps): React__default.ReactElement;
96
+ declare function BillingProvider({ publishableKey, createCheckout, verifyCheckout, getCheckoutStatus, baseUrl, children, }: BillingProviderProps): React__default.ReactElement;
53
97
  declare function useOptionalBillingContext(): BillingContextValue | null;
54
98
  declare function useBillingContext(): BillingContextValue;
55
99
  declare function useNozleClient(): NozleClient;
@@ -156,39 +200,55 @@ interface PlanComparisonProps {
156
200
  */
157
201
  declare function PlanComparison({ plans, features, }: PlanComparisonProps): React__default.ReactElement;
158
202
 
159
- interface CheckoutButtonProps {
203
+ interface RazorpayActions {
204
+ verifyCheckout?: VerifyCheckout;
205
+ getCheckoutStatus?: GetCheckoutStatus;
206
+ onSuccess?: (paymentId: string) => void;
207
+ onProcessing?: (status: CheckoutStatus) => void;
208
+ onDismiss?: () => void;
209
+ onError?: (error: Error) => void;
210
+ }
211
+ interface RazorpayOptions {
212
+ key: string;
213
+ order_id: string;
214
+ amount: number;
215
+ currency: string;
216
+ customer_id?: string;
217
+ recurring?: '1';
218
+ handler: (response: RazorpayVerification) => void;
219
+ modal: {
220
+ ondismiss: () => void;
221
+ };
222
+ }
223
+ interface RazorpayInstance {
224
+ open(): void;
225
+ close(): void;
226
+ on(event: string, callback: () => void): void;
227
+ }
228
+ declare global {
229
+ interface Window {
230
+ Razorpay?: new (options: RazorpayOptions) => RazorpayInstance;
231
+ }
232
+ }
233
+
234
+ interface CheckoutButtonProps extends Omit<RazorpayActions, 'verifyCheckout' | 'getCheckoutStatus'> {
160
235
  planCode: string;
161
236
  returnUrl?: string;
162
237
  label?: string;
163
238
  className?: string;
164
239
  style?: React__default.CSSProperties;
165
240
  onError?: (error: Error) => void;
241
+ /** @deprecated The server supplies the public Razorpay key in the checkout response. */
166
242
  razorpayKeyId?: string;
243
+ registerMandate?: boolean;
167
244
  onStripeClientSecret?: (clientSecret: string) => void;
168
245
  onSuccess?: (paymentId: string) => void;
169
246
  onComplete?: (result: CompletedCheckoutResult) => void;
170
247
  onScheduled?: (result: ScheduledCheckoutResult) => void;
171
248
  }
172
- interface RazorpayOptions {
173
- key: string;
174
- order_id: string;
175
- handler: (response: {
176
- razorpay_payment_id: string;
177
- }) => void;
178
- modal?: {
179
- ondismiss?: () => void;
180
- };
181
- }
182
- declare global {
183
- interface Window {
184
- Razorpay: new (options: RazorpayOptions) => {
185
- open(): void;
186
- };
187
- }
188
- }
189
- declare function CheckoutButton({ planCode, returnUrl, label, className, style, onError, razorpayKeyId, onStripeClientSecret, onSuccess, onComplete, onScheduled, }: CheckoutButtonProps): React__default.ReactElement;
249
+ declare function CheckoutButton({ planCode, returnUrl, label, className, style, onError, razorpayKeyId, registerMandate, onProcessing, onDismiss, onStripeClientSecret, onSuccess, onComplete, onScheduled, }: CheckoutButtonProps): React__default.ReactElement;
190
250
 
191
- interface CheckoutProps {
251
+ interface StripeCheckoutProps {
192
252
  /** Stripe PaymentIntent client secret */
193
253
  clientSecret: string;
194
254
  /** Stripe publishable key */
@@ -223,7 +283,17 @@ interface UseCheckoutResult {
223
283
  error: Error | null;
224
284
  }
225
285
  declare function useCheckout(): UseCheckoutResult;
226
- declare function Checkout({ clientSecret, publishableKey, stripeAccount, returnUrl, submitLabel, onSuccess, onComplete, onError, onReady, className, style, children, }: CheckoutProps): React__default.JSX.Element;
286
+ interface ProviderCheckoutProps {
287
+ checkout: CheckoutResult;
288
+ submitLabel?: string;
289
+ onSuccess?: (paymentId: string) => void;
290
+ onComplete?: () => void;
291
+ onProcessing?: (status: CheckoutStatus) => void;
292
+ onError?: (error: Error) => void;
293
+ className?: string;
294
+ }
295
+ type CheckoutProps = StripeCheckoutProps | ProviderCheckoutProps;
296
+ declare function Checkout(props: CheckoutProps): React__default.JSX.Element;
227
297
 
228
298
  interface ProrationPreview {
229
299
  credit: number;
@@ -457,4 +527,4 @@ interface PaymentMethodDisplayProps {
457
527
  }
458
528
  declare function PaymentMethodDisplay({ paymentMethod, onUpdatePaymentMethod, updateHref, }: PaymentMethodDisplayProps): React.JSX.Element;
459
529
 
460
- export { BillingContext, type BillingContextValue, BillingProvider, type BillingProviderProps, type Plan$1 as CatalogPlan, Checkout, CheckoutButton, type CheckoutButtonProps, type CheckoutProps, type CheckoutResult, type ComparisonFeature, type CompletedCheckoutResult, type CreateCheckout, type CreateCheckoutInput, FeatureGate, type FeatureGateProps, LockedOverlay, type LockedOverlayProps, type NozleClient, type PaymentMethod, PaymentMethodDisplay, type PaymentMethodDisplayProps, type Plan, PlanBadge, type PlanBadgeProps, PlanCard, type PlanCardProps, PlanComparison, type PlanComparisonProps, PlanGate, type PlanGateProps, type PricingPlan, PricingTable, type PricingTableProps, type ProrationPreview, type ScheduledCheckoutResult, UpgradeButton, type UpgradeButtonProps, UpgradeModal, type UpgradeModalProps, UpgradePrompt, type UpgradePromptProps, UsageAlert, type UsageAlertFeature, type UsageAlertProps, UsageDashboard, type UsageDashboardFeature, type UsageDashboardProps, UsageGate, type UsageGateProps, UsageMeter, type UsageMeterProps, type UseCheckoutResult, type UseCheckoutResult$1 as UseCheckoutSessionResult, getUsageMeterColor, useBillingContext, useCheckout, useCheckout$1 as useCheckoutSession, useNozleClient, useOptionalBillingContext, usePlans };
530
+ export { BillingContext, type BillingContextValue, BillingProvider, type BillingProviderProps, type Plan$1 as CatalogPlan, Checkout, CheckoutButton, type CheckoutButtonProps, type CheckoutProps, type CheckoutResult, type CheckoutStatus, type ComparisonFeature, type CompletedCheckoutResult, type CreateCheckout, type CreateCheckoutInput, FeatureGate, type FeatureGateProps, type GetCheckoutStatus, type HostedCheckoutResult, LockedOverlay, type LockedOverlayProps, type NozleClient, type PaymentMethod, PaymentMethodDisplay, type PaymentMethodDisplayProps, type Plan, PlanBadge, type PlanBadgeProps, PlanCard, type PlanCardProps, PlanComparison, type PlanComparisonProps, PlanGate, type PlanGateProps, type PricingPlan, PricingTable, type PricingTableProps, type ProcessingCheckoutResult, type ProrationPreview, type RazorpayCheckoutResult, type RazorpayVerification, type ScheduledCheckoutResult, UpgradeButton, type UpgradeButtonProps, UpgradeModal, type UpgradeModalProps, UpgradePrompt, type UpgradePromptProps, UsageAlert, type UsageAlertFeature, type UsageAlertProps, UsageDashboard, type UsageDashboardFeature, type UsageDashboardProps, UsageGate, type UsageGateProps, UsageMeter, type UsageMeterProps, type UseCheckoutResult, type UseCheckoutResult$1 as UseCheckoutSessionResult, type VerifyCheckout, getUsageMeterColor, useBillingContext, useCheckout, useCheckout$1 as useCheckoutSession, useNozleClient, useOptionalBillingContext, usePlans };