@nozle-js/react 0.10.1 → 0.10.2
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/LICENSE +21 -0
- package/README.md +74 -1
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -71,6 +71,7 @@ interface CheckoutSubscriptionResult {
|
|
|
71
71
|
interface CompletedCheckoutResult extends CheckoutSubscriptionResult {
|
|
72
72
|
type: "completed";
|
|
73
73
|
status: string;
|
|
74
|
+
/** `credits` or `none`. */
|
|
74
75
|
payment_source?: string;
|
|
75
76
|
subscription_id?: string;
|
|
76
77
|
plan_code?: string;
|
|
@@ -84,7 +85,9 @@ interface ScheduledCheckoutResult extends CheckoutSubscriptionResult {
|
|
|
84
85
|
subscription_id?: string;
|
|
85
86
|
plan_code?: string;
|
|
86
87
|
effective_at?: string;
|
|
87
|
-
|
|
88
|
+
/** `upgrade` or `downgrade`. */
|
|
89
|
+
transition_direction?: string;
|
|
90
|
+
transition_policy?: string;
|
|
88
91
|
}
|
|
89
92
|
interface RazorpayCheckoutResult {
|
|
90
93
|
type: "razorpay";
|
|
@@ -94,20 +97,40 @@ interface RazorpayCheckoutResult {
|
|
|
94
97
|
amount_cents: number;
|
|
95
98
|
currency: string;
|
|
96
99
|
expires_at?: string;
|
|
100
|
+
/** Set for an invoice checkout. A paid upgrade returns `plan_upgrade_intent_id` instead. */
|
|
97
101
|
invoice_id?: string;
|
|
102
|
+
plan_upgrade_intent_id?: string;
|
|
103
|
+
external_entity_id?: string;
|
|
104
|
+
external_subscription_id?: string;
|
|
98
105
|
customer_id?: string;
|
|
99
106
|
recurring?: boolean;
|
|
100
107
|
mandate_max_amount_cents?: number;
|
|
101
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The checkout is not ready to collect payment yet: Razorpay while the order is
|
|
111
|
+
* being created, and Stripe when a quoted upgrade is replayed while its webhook is
|
|
112
|
+
* still pending. Recover with the checkout status call using `checkout_id`.
|
|
113
|
+
*/
|
|
102
114
|
interface ProcessingCheckoutResult {
|
|
103
115
|
type: "processing";
|
|
104
116
|
checkout_id: string;
|
|
105
117
|
status: string;
|
|
118
|
+
amount_cents?: number;
|
|
119
|
+
currency?: string;
|
|
120
|
+
expires_at?: string;
|
|
121
|
+
invoice_id?: string;
|
|
122
|
+
plan_upgrade_intent_id?: string;
|
|
106
123
|
}
|
|
124
|
+
/** A Razorpay payment link. The customer is redirected to `payment_url`. */
|
|
107
125
|
interface HostedCheckoutResult {
|
|
108
126
|
type: "hosted";
|
|
109
127
|
payment_url: string;
|
|
110
128
|
checkout_id?: string;
|
|
129
|
+
amount_cents?: number;
|
|
130
|
+
currency?: string;
|
|
131
|
+
expires_at?: string;
|
|
132
|
+
invoice_id?: string;
|
|
133
|
+
plan_upgrade_intent_id?: string;
|
|
111
134
|
}
|
|
112
135
|
interface RazorpayVerification {
|
|
113
136
|
razorpay_order_id: string;
|
|
@@ -129,13 +152,19 @@ type VerifyCheckout = (checkoutId: string, verification: RazorpayVerification) =
|
|
|
129
152
|
type GetCheckoutStatus = (checkoutId: string) => Promise<CheckoutStatus>;
|
|
130
153
|
type CheckoutResult = {
|
|
131
154
|
type: "stripe";
|
|
155
|
+
/** Not returned by plan and invoice checkout, which never issue a Stripe-hosted URL. */
|
|
132
156
|
url?: string;
|
|
157
|
+
/** Embedded Checkout Session secret (`cs_...`). */
|
|
133
158
|
clientSecret?: string;
|
|
134
159
|
client_secret?: string;
|
|
160
|
+
/** Not returned by Nozle. Pass your Stripe publishable key to `Checkout`. */
|
|
135
161
|
publishable_key?: string;
|
|
162
|
+
/** Not returned by Nozle. */
|
|
136
163
|
stripe_account?: string;
|
|
137
164
|
checkout_id?: string;
|
|
138
165
|
invoice_id?: string;
|
|
166
|
+
/** Set instead of `invoice_id` for a paid upgrade. */
|
|
167
|
+
plan_upgrade_intent_id?: string;
|
|
139
168
|
amount_cents?: number;
|
|
140
169
|
currency?: string;
|
|
141
170
|
external_entity_id?: string;
|
|
@@ -445,7 +474,11 @@ interface StripeCheckoutProps {
|
|
|
445
474
|
submitLabel?: string;
|
|
446
475
|
/** Called with the paymentIntentId when payment succeeds without redirect */
|
|
447
476
|
onSuccess?: (paymentIntentId: string) => void;
|
|
448
|
-
/**
|
|
477
|
+
/**
|
|
478
|
+
* Called when an embedded Checkout Session completes without a redirect. It does
|
|
479
|
+
* not fire when the session redirects to `returnUrl`: show success from the return
|
|
480
|
+
* page, or reload billing status there.
|
|
481
|
+
*/
|
|
449
482
|
onComplete?: () => void;
|
|
450
483
|
/** Called with the error when payment fails */
|
|
451
484
|
onError?: (error: Error) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ interface CheckoutSubscriptionResult {
|
|
|
71
71
|
interface CompletedCheckoutResult extends CheckoutSubscriptionResult {
|
|
72
72
|
type: "completed";
|
|
73
73
|
status: string;
|
|
74
|
+
/** `credits` or `none`. */
|
|
74
75
|
payment_source?: string;
|
|
75
76
|
subscription_id?: string;
|
|
76
77
|
plan_code?: string;
|
|
@@ -84,7 +85,9 @@ interface ScheduledCheckoutResult extends CheckoutSubscriptionResult {
|
|
|
84
85
|
subscription_id?: string;
|
|
85
86
|
plan_code?: string;
|
|
86
87
|
effective_at?: string;
|
|
87
|
-
|
|
88
|
+
/** `upgrade` or `downgrade`. */
|
|
89
|
+
transition_direction?: string;
|
|
90
|
+
transition_policy?: string;
|
|
88
91
|
}
|
|
89
92
|
interface RazorpayCheckoutResult {
|
|
90
93
|
type: "razorpay";
|
|
@@ -94,20 +97,40 @@ interface RazorpayCheckoutResult {
|
|
|
94
97
|
amount_cents: number;
|
|
95
98
|
currency: string;
|
|
96
99
|
expires_at?: string;
|
|
100
|
+
/** Set for an invoice checkout. A paid upgrade returns `plan_upgrade_intent_id` instead. */
|
|
97
101
|
invoice_id?: string;
|
|
102
|
+
plan_upgrade_intent_id?: string;
|
|
103
|
+
external_entity_id?: string;
|
|
104
|
+
external_subscription_id?: string;
|
|
98
105
|
customer_id?: string;
|
|
99
106
|
recurring?: boolean;
|
|
100
107
|
mandate_max_amount_cents?: number;
|
|
101
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The checkout is not ready to collect payment yet: Razorpay while the order is
|
|
111
|
+
* being created, and Stripe when a quoted upgrade is replayed while its webhook is
|
|
112
|
+
* still pending. Recover with the checkout status call using `checkout_id`.
|
|
113
|
+
*/
|
|
102
114
|
interface ProcessingCheckoutResult {
|
|
103
115
|
type: "processing";
|
|
104
116
|
checkout_id: string;
|
|
105
117
|
status: string;
|
|
118
|
+
amount_cents?: number;
|
|
119
|
+
currency?: string;
|
|
120
|
+
expires_at?: string;
|
|
121
|
+
invoice_id?: string;
|
|
122
|
+
plan_upgrade_intent_id?: string;
|
|
106
123
|
}
|
|
124
|
+
/** A Razorpay payment link. The customer is redirected to `payment_url`. */
|
|
107
125
|
interface HostedCheckoutResult {
|
|
108
126
|
type: "hosted";
|
|
109
127
|
payment_url: string;
|
|
110
128
|
checkout_id?: string;
|
|
129
|
+
amount_cents?: number;
|
|
130
|
+
currency?: string;
|
|
131
|
+
expires_at?: string;
|
|
132
|
+
invoice_id?: string;
|
|
133
|
+
plan_upgrade_intent_id?: string;
|
|
111
134
|
}
|
|
112
135
|
interface RazorpayVerification {
|
|
113
136
|
razorpay_order_id: string;
|
|
@@ -129,13 +152,19 @@ type VerifyCheckout = (checkoutId: string, verification: RazorpayVerification) =
|
|
|
129
152
|
type GetCheckoutStatus = (checkoutId: string) => Promise<CheckoutStatus>;
|
|
130
153
|
type CheckoutResult = {
|
|
131
154
|
type: "stripe";
|
|
155
|
+
/** Not returned by plan and invoice checkout, which never issue a Stripe-hosted URL. */
|
|
132
156
|
url?: string;
|
|
157
|
+
/** Embedded Checkout Session secret (`cs_...`). */
|
|
133
158
|
clientSecret?: string;
|
|
134
159
|
client_secret?: string;
|
|
160
|
+
/** Not returned by Nozle. Pass your Stripe publishable key to `Checkout`. */
|
|
135
161
|
publishable_key?: string;
|
|
162
|
+
/** Not returned by Nozle. */
|
|
136
163
|
stripe_account?: string;
|
|
137
164
|
checkout_id?: string;
|
|
138
165
|
invoice_id?: string;
|
|
166
|
+
/** Set instead of `invoice_id` for a paid upgrade. */
|
|
167
|
+
plan_upgrade_intent_id?: string;
|
|
139
168
|
amount_cents?: number;
|
|
140
169
|
currency?: string;
|
|
141
170
|
external_entity_id?: string;
|
|
@@ -445,7 +474,11 @@ interface StripeCheckoutProps {
|
|
|
445
474
|
submitLabel?: string;
|
|
446
475
|
/** Called with the paymentIntentId when payment succeeds without redirect */
|
|
447
476
|
onSuccess?: (paymentIntentId: string) => void;
|
|
448
|
-
/**
|
|
477
|
+
/**
|
|
478
|
+
* Called when an embedded Checkout Session completes without a redirect. It does
|
|
479
|
+
* not fire when the session redirects to `returnUrl`: show success from the return
|
|
480
|
+
* page, or reload billing status there.
|
|
481
|
+
*/
|
|
449
482
|
onComplete?: () => void;
|
|
450
483
|
/** Called with the error when payment fails */
|
|
451
484
|
onError?: (error: Error) => void;
|
package/dist/index.js
CHANGED
|
@@ -3224,10 +3224,11 @@ function PricingTable({
|
|
|
3224
3224
|
}
|
|
3225
3225
|
let cancelled = false;
|
|
3226
3226
|
client.catalogFetch("/api/v1/plans").then(async (res) => {
|
|
3227
|
-
if (!
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3227
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
3228
|
+
const data = await res.json();
|
|
3229
|
+
if (!cancelled) setPlans(data.plans || []);
|
|
3230
|
+
}).catch((cause) => {
|
|
3231
|
+
if (!cancelled) setCheckoutError(`Plans could not be loaded: ${cause instanceof Error ? cause.message : "unknown error"}`);
|
|
3231
3232
|
}).finally(() => {
|
|
3232
3233
|
if (!cancelled) setLoading(false);
|
|
3233
3234
|
});
|