@meterbox/customer-portal 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -5,7 +5,10 @@ pages (Account, Plans, Credits), composed from the widgets shipped in
5
5
  [`@meterbox/react`](https://www.npmjs.com/package/@meterbox/react). All data is
6
6
  fetched via the `/v1/customer-portal/*` endpoints using a short-lived
7
7
  customer-scoped JWT that your backend mints with `POST /v1/tokens/:id`, so no
8
- API key ever reaches the browser.
8
+ API key ever reaches the browser. The portal works from any origin (the
9
+ endpoints answer CORS for any site), and a token only works in the
10
+ environment it was minted in: mint with a sandbox API key to show sandbox
11
+ data.
9
12
 
10
13
  ```bash
11
14
  npm install @meterbox/customer-portal react react-dom
@@ -35,7 +38,8 @@ function handlePlanSelect(plan, billingInterval) {
35
38
  ## Pages
36
39
 
37
40
  - **Account**: name, email, current plan, status (`GET /v1/customer-portal/:id/me`)
38
- - **Plans**: `<PricingTable>` (monthly/annual toggle included) + inline
41
+ - **Plans**: the published plans (`GET /v1/customer-portal/:id/plans`) in a
42
+ `<PricingTable>` (monthly/annual toggle included) + inline
39
43
  `<PlanChangeCard>` for a monthly pick: proration preview plus "Change now"
40
44
  / "Schedule for end of period" actions, so picking a plan actually applies
41
45
  it, not just previews it. `onPlanSelect` fires with `(plan,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meterbox/customer-portal",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Drop-in multi-page React customer portal for Meterbox: Account, Plans, Credits. Built on @meterbox/react.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://meterbox.ai",
@@ -1,6 +1,7 @@
1
1
  /**
2
- * <PlansPage /> — fetches the public plan catalog + the customer's current
3
- * plan, renders `<PricingTable>`; on plan pick, renders an inline
2
+ * <PlansPage /> — fetches the plans this customer can pick
3
+ * (`GET /v1/customer-portal/:id/plans`: published plans, display fields only)
4
+ * + the customer's current plan, renders `<PricingTable>`; on plan pick, renders an inline
4
5
  * `<PlanChangeCard>` for that plan — the proration preview plus "Change
5
6
  * now" / "Schedule for end of period" actions, so picking a plan is no
6
7
  * longer a dead end the host app has to build its own apply flow for.
@@ -67,7 +68,14 @@ function PlansPage({
67
68
  let cancelled = false;
68
69
  setLoading(true);
69
70
  setError(null);
70
- Promise.all([fetchJson(`${root}/v1/plans`, {}, fetcher), fetchMe()])
71
+ Promise.all([
72
+ fetchJson(
73
+ `${root}/v1/customer-portal/${encodeURIComponent(customerId)}/plans`,
74
+ { Authorization: `Bearer ${customerToken}` },
75
+ fetcher,
76
+ ),
77
+ fetchMe(),
78
+ ])
71
79
  .then(([catalog, me]) => {
72
80
  if (cancelled) return;
73
81
  setPlans(catalog.plans || []);