@nozle-js/react 0.11.0 → 0.12.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/README.md +47 -0
- package/dist/index.cjs +516 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +183 -32
- package/dist/index.d.ts +183 -32
- package/dist/index.js +513 -94
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,53 @@ The merchant endpoint authenticates the user, derives the Nozle customer from th
|
|
|
52
52
|
|
|
53
53
|
`createCheckout` returns a `stripe`, `razorpay`, `hosted`, `processing`, `completed`, or `scheduled` result. Nozle payment fulfillment determines activation; Razorpay requires capture. A browser redirect or callback alone does not prove activation.
|
|
54
54
|
|
|
55
|
+
## Pricing table and plan families
|
|
56
|
+
|
|
57
|
+
`PricingTable` shows one card per plan family. A family groups the billing intervals of one offer (for example Pro monthly and Pro yearly) and carries the pricing table settings you set in the Nozle dashboard (Developers → Customize SDK). `GET /api/v1/plans` returns them as `families` next to `plans`:
|
|
58
|
+
|
|
59
|
+
| Family field | Effect |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| `show_on_pricing: false` | The family is hidden. Plans with `pending_deletion: true` are left out, and a family without plans is hidden |
|
|
62
|
+
| `pricing_position` | Cards are ordered by it, ascending. Families without a position follow in API order |
|
|
63
|
+
| `pricing_highlighted` | The card is highlighted (at most one). The `highlightPlan` prop, a family code or plan code, overrides it |
|
|
64
|
+
| `badge_text` / `cta_text` | Badge on the highlighted card (default "Most Popular"; the `highlightLabel` prop replaces it) and button text (default "Get {name}") |
|
|
65
|
+
| `features[].show_on_pricing: false` | The feature is left out of the card |
|
|
66
|
+
| `features[].display_position` | Features are ordered by it, then by name |
|
|
67
|
+
| `features[].show_description` | The feature's description appears as a muted line under the bullet |
|
|
68
|
+
|
|
69
|
+
The interval switch offers the intervals of the visible families (Weekly, Monthly, Quarterly, Every 6 months, Annual) and is hidden when there is only one. Each card shows the family's plan for the selected interval as a per-month price (`$40.83 /mo`) with its billing line (`Billed $490 yearly · save 17%`, saving against the family's monthly plan), and a family without a plan for that interval shows its nearest interval. Feature values come from the selected plan's entitlements, for example `Projects: 20` or `Storage (GB: 10, Tier: fast)`. The button and checkout use the selected plan's code.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<PricingTable
|
|
73
|
+
returnUrl={window.location.href}
|
|
74
|
+
defaultInterval="yearly"
|
|
75
|
+
locale="en-GB"
|
|
76
|
+
features={{
|
|
77
|
+
pro: ["Priority support", { label: "API access", description: "REST and GraphQL" }],
|
|
78
|
+
}}
|
|
79
|
+
onSelect={(plan, family) => console.log(plan.code, family?.code)}
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- `defaultInterval` picks the first interval (`"annual"` also works). Otherwise Monthly when offered, else the first one. `showToggle={false}` hides the switch.
|
|
84
|
+
- `features` is a record keyed by family code (or plan code) that replaces the catalog features of that card, or an array aligned to the rendered cards.
|
|
85
|
+
- `contactSalesPlans` takes family codes as well as plan codes: the card shows "Custom" and a "Contact Sales" button.
|
|
86
|
+
- Cards follow the `appearance` theme like the other components: the highlighted family uses `colorHighlight` (default `colorPrimary`) and `highlightStyle`, and a theme's `planCardLayout: "panel"` lays family cards out as panels with the same billing line. The default highlight (`#4f46e5` in the `light` theme) keeps its white text at WCAG AA contrast; if you set your own `colorHighlight`, check that `colorHighlightForeground` on it reaches 4.5:1.
|
|
87
|
+
- `annualDiscountLabel` replaces the computed "Save N%" on the Annual option.
|
|
88
|
+
- `locale` (default `en-US`) formats prices and feature values. Prices are exact in the currency's minor units (`¥1,500` for 1500 JPY), and whole amounts show no decimals (`$20`).
|
|
89
|
+
- Pass `plans` and `families` to render without fetching. With `plans` alone, or with an older API that returns no `families`, each plan is its own card as before, sorted by price (or by `sort`), with its price per its own interval (`$14.99 /quarter`, no per-month price or billing line) and what the plan gives as its features.
|
|
90
|
+
|
|
91
|
+
For a custom pricing page, use the same rules with `usePlans()`:
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
const { plans, families } = usePlans();
|
|
95
|
+
const intervals = getAvailableIntervals({ plans, families });
|
|
96
|
+
const cards = getPricingCards({ plans, families }, { interval: "yearly", locale: "en-US" });
|
|
97
|
+
// cards[i]: { family, plan, name, price, pricePeriod, billing, features, highlighted, badge, cta, ... }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`getPricingIntervalOptions(catalog)` returns the switch options with their labels and best saving, and `getDefaultInterval(catalog, preferred?)` the interval to start on.
|
|
101
|
+
|
|
55
102
|
## Payment providers: Stripe and Razorpay
|
|
56
103
|
|
|
57
104
|
Your merchant backend returns whatever result Nozle gives for the customer's connected provider, and `CheckoutButton` handles each `type`:
|