@openrails/billing-ui 0.236.0 → 0.238.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/CHANGELOG.md +87 -9
- package/README.md +78 -83
- package/dist/account/account-billing.d.ts +1 -1
- package/dist/account/payment-methods-panel.d.ts +2 -2
- package/dist/authenticate.d.ts +5 -4
- package/dist/buy-button.d.ts +17 -10
- package/dist/client/client.d.ts +52 -23
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +24 -218
- package/dist/client/generated/wire.d.ts +39 -200
- package/dist/client/index.d.ts +2 -1
- package/dist/client/token-source.d.ts +60 -0
- package/dist/client/types.d.ts +108 -199
- package/dist/client-Bi_lP_M0.js +932 -0
- package/dist/client-Bi_lP_M0.js.map +1 -0
- package/dist/client.js +2 -2
- package/dist/components/eyebrow.d.ts +5 -0
- package/dist/embedded-checkout.d.ts +22 -0
- package/dist/{hooks-2d-XjpuI.js → hooks-Bk80rNv8.js} +99 -90
- package/dist/hooks-Bk80rNv8.js.map +1 -0
- package/dist/index.d.ts +5 -8
- package/dist/index.js +1149 -2163
- package/dist/index.js.map +1 -1
- package/dist/modal.d.ts +3 -9
- package/dist/offers.d.ts +10 -9
- package/dist/psp.d.ts +0 -8
- package/dist/react/config.d.ts +17 -12
- package/dist/react/context.d.ts +3 -1
- package/dist/react/hooks.d.ts +5 -5
- package/dist/react/index.d.ts +1 -1
- package/dist/react.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/tokenized-card-form.d.ts +5 -1
- package/dist/types.d.ts +12 -250
- package/docs/payment-form-contract.md +31 -74
- package/package.json +1 -2
- package/dist/checkout-frame.d.ts +0 -17
- package/dist/checkout-page.d.ts +0 -21
- package/dist/checkout.d.ts +0 -22
- package/dist/client/checkout.d.ts +0 -28
- package/dist/client-BuvolBPT.js +0 -1092
- package/dist/client-BuvolBPT.js.map +0 -1
- package/dist/components/ccbill-fields.d.ts +0 -8
- package/dist/components/methods.d.ts +0 -13
- package/dist/components/summary.d.ts +0 -12
- package/dist/fixtures.d.ts +0 -9
- package/dist/frame.d.ts +0 -47
- package/dist/hooks-2d-XjpuI.js.map +0 -1
- package/dist/lib/rail-meta.d.ts +0 -15
- package/dist/lib/redirect.d.ts +0 -2
- package/dist/source.d.ts +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as e, O as t, c as n, o as r } from "./client-Bi_lP_M0.js";
|
|
2
2
|
import { en as i } from "./locales/en.js";
|
|
3
3
|
import { createContext as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d, useSyncExternalStore as f } from "react";
|
|
4
4
|
import { jsx as p } from "react/jsx-runtime";
|
|
@@ -143,7 +143,7 @@ function P() {
|
|
|
143
143
|
var F = () => P().client, I = () => P().refresh, L = () => s(N);
|
|
144
144
|
//#endregion
|
|
145
145
|
//#region src/react/config.ts
|
|
146
|
-
function R(
|
|
146
|
+
function R(e) {
|
|
147
147
|
let n = {
|
|
148
148
|
config: null,
|
|
149
149
|
loading: !0,
|
|
@@ -157,17 +157,17 @@ function R(t) {
|
|
|
157
157
|
n.loading || o({
|
|
158
158
|
...n,
|
|
159
159
|
loading: !0
|
|
160
|
-
}),
|
|
160
|
+
}), e().then((e) => {
|
|
161
161
|
a === i && o({
|
|
162
162
|
config: e,
|
|
163
163
|
loading: !1,
|
|
164
164
|
error: null
|
|
165
165
|
});
|
|
166
|
-
}, (
|
|
166
|
+
}, (e) => {
|
|
167
167
|
a === i && o({
|
|
168
168
|
config: n.config,
|
|
169
169
|
loading: !1,
|
|
170
|
-
error: e
|
|
170
|
+
error: t(e)
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
173
|
};
|
|
@@ -177,20 +177,26 @@ function R(t) {
|
|
|
177
177
|
},
|
|
178
178
|
snapshot: () => n,
|
|
179
179
|
ensure() {
|
|
180
|
-
r || s();
|
|
180
|
+
(!r || n.error && !n.config && !n.loading) && s();
|
|
181
181
|
},
|
|
182
182
|
refetch: s
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
function z() {
|
|
186
|
-
let
|
|
185
|
+
function z(e) {
|
|
186
|
+
let t = f(e.subscribe, e.snapshot, e.snapshot);
|
|
187
187
|
return c(() => e.ensure(), [e]), {
|
|
188
188
|
...t,
|
|
189
189
|
refetch: e.refetch
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
function B() {
|
|
193
|
-
|
|
193
|
+
return z(P().config);
|
|
194
|
+
}
|
|
195
|
+
function V() {
|
|
196
|
+
return z(P().customerConfig);
|
|
197
|
+
}
|
|
198
|
+
function H() {
|
|
199
|
+
let { client: e } = P(), { config: t } = B();
|
|
194
200
|
return l(() => ({
|
|
195
201
|
...Object.fromEntries((t?.currencies ?? []).map((e) => [e.code.toUpperCase(), e.decimals])),
|
|
196
202
|
...e.currencies
|
|
@@ -198,7 +204,7 @@ function B() {
|
|
|
198
204
|
}
|
|
199
205
|
//#endregion
|
|
200
206
|
//#region src/react/provider.tsx
|
|
201
|
-
function
|
|
207
|
+
function U({ client: e, onChange: t, appearance: n, messages: r, t: i, locale: a, navigate: o, children: s }) {
|
|
202
208
|
let c = l(() => w(_(r), i, a), [
|
|
203
209
|
r,
|
|
204
210
|
i,
|
|
@@ -216,7 +222,7 @@ function V({ client: e, onChange: t, appearance: n, messages: r, t: i, locale: a
|
|
|
216
222
|
value: u,
|
|
217
223
|
children: /* @__PURE__ */ p(T.Provider, {
|
|
218
224
|
value: c,
|
|
219
|
-
children: e ? /* @__PURE__ */ p(
|
|
225
|
+
children: e ? /* @__PURE__ */ p(W, {
|
|
220
226
|
client: e,
|
|
221
227
|
onChange: t,
|
|
222
228
|
children: s
|
|
@@ -224,35 +230,37 @@ function V({ client: e, onChange: t, appearance: n, messages: r, t: i, locale: a
|
|
|
224
230
|
})
|
|
225
231
|
});
|
|
226
232
|
}
|
|
227
|
-
function
|
|
233
|
+
function W({ client: e, onChange: t, children: n }) {
|
|
228
234
|
let [r, i] = d(0), a = u(t);
|
|
229
235
|
c(() => {
|
|
230
236
|
a.current = t;
|
|
231
237
|
});
|
|
232
238
|
let s = o((e) => {
|
|
233
239
|
i((e) => e + 1), a.current?.(e);
|
|
234
|
-
}, []), f = o(() => i((e) => e + 1), []), m = l(() => R(e), [e]), h = l(() => ({
|
|
240
|
+
}, []), f = o(() => i((e) => e + 1), []), m = l(() => R(() => e.getConfig()), [e]), h = l(() => R(() => e.getCustomerConfig()), [e]), g = l(() => ({
|
|
235
241
|
client: e,
|
|
236
242
|
version: r,
|
|
237
243
|
notify: s,
|
|
238
244
|
refresh: f,
|
|
239
|
-
config: m
|
|
245
|
+
config: m,
|
|
246
|
+
customerConfig: h
|
|
240
247
|
}), [
|
|
241
248
|
e,
|
|
242
249
|
r,
|
|
243
250
|
s,
|
|
244
251
|
f,
|
|
245
|
-
m
|
|
252
|
+
m,
|
|
253
|
+
h
|
|
246
254
|
]);
|
|
247
255
|
return /* @__PURE__ */ p(N.Provider, {
|
|
248
|
-
value:
|
|
256
|
+
value: g,
|
|
249
257
|
children: n
|
|
250
258
|
});
|
|
251
259
|
}
|
|
252
260
|
//#endregion
|
|
253
261
|
//#region src/react/remote.ts
|
|
254
|
-
function
|
|
255
|
-
let [r, i] = d(0), a = `${
|
|
262
|
+
function G(e, n) {
|
|
263
|
+
let [r, i] = d(0), a = `${e}|${r}`, [s, l] = d({
|
|
256
264
|
request: null,
|
|
257
265
|
data: null,
|
|
258
266
|
error: null
|
|
@@ -260,18 +268,18 @@ function U(t, n) {
|
|
|
260
268
|
c(() => {
|
|
261
269
|
f.current = n;
|
|
262
270
|
}), c(() => {
|
|
263
|
-
let
|
|
264
|
-
return f.current(
|
|
271
|
+
let e = new AbortController();
|
|
272
|
+
return f.current(e.signal).then((e) => l({
|
|
265
273
|
request: a,
|
|
266
274
|
data: e,
|
|
267
275
|
error: null
|
|
268
276
|
}), (n) => {
|
|
269
|
-
|
|
277
|
+
e.signal.aborted || l((e) => ({
|
|
270
278
|
request: a,
|
|
271
|
-
data:
|
|
272
|
-
error:
|
|
279
|
+
data: e.data,
|
|
280
|
+
error: t(n)
|
|
273
281
|
}));
|
|
274
|
-
}), () =>
|
|
282
|
+
}), () => e.abort();
|
|
275
283
|
}, [a]);
|
|
276
284
|
let p = o(() => i((e) => e + 1), []), m = o((e) => l((t) => t.data === null ? t : {
|
|
277
285
|
...t,
|
|
@@ -287,7 +295,7 @@ function U(t, n) {
|
|
|
287
295
|
}
|
|
288
296
|
//#endregion
|
|
289
297
|
//#region src/react/hooks.ts
|
|
290
|
-
function
|
|
298
|
+
function K() {
|
|
291
299
|
let [e, t] = d({});
|
|
292
300
|
return [e, o((e, n) => {
|
|
293
301
|
t((t) => {
|
|
@@ -296,33 +304,33 @@ function W() {
|
|
|
296
304
|
});
|
|
297
305
|
}, [])];
|
|
298
306
|
}
|
|
299
|
-
var
|
|
300
|
-
function
|
|
301
|
-
let { client: i, version: a, notify: s } = P(), c =
|
|
307
|
+
var q = () => e("wallet_required", "A wallet must sign this action.");
|
|
308
|
+
function J(e = {}) {
|
|
309
|
+
let { client: i, version: a, notify: s } = P(), c = e.status ?? "all", l = e.limit ?? 100, u = G(`${c}|${l}|${a}`, (e) => i.listSubscriptions({
|
|
302
310
|
status: c,
|
|
303
311
|
limit: l,
|
|
304
312
|
signal: e
|
|
305
|
-
})), [d, f] =
|
|
313
|
+
})), [d, f] = K(), { replace: p } = u, m = o((e) => p((t) => ({
|
|
306
314
|
...t,
|
|
307
315
|
data: t.data.map((t) => t.id === e.id ? e : t)
|
|
308
|
-
})), [p]), h = o(async (
|
|
309
|
-
f(
|
|
316
|
+
})), [p]), h = o(async (e, n, r, i) => {
|
|
317
|
+
f(e, n);
|
|
310
318
|
try {
|
|
311
319
|
let e = await r();
|
|
312
320
|
return m(e), i(e), null;
|
|
313
|
-
} catch (
|
|
314
|
-
return e
|
|
321
|
+
} catch (e) {
|
|
322
|
+
return t(e);
|
|
315
323
|
} finally {
|
|
316
|
-
f(
|
|
324
|
+
f(e, null);
|
|
317
325
|
}
|
|
318
|
-
}, [f, m]), g = o((e,
|
|
319
|
-
let o = await i.cancelSubscription(e, { reason:
|
|
326
|
+
}, [f, m]), g = o((e, t, a) => h(e, "cancel", async () => {
|
|
327
|
+
let o = await i.cancelSubscription(e, { reason: t });
|
|
320
328
|
if (!o.next_action) return o;
|
|
321
|
-
if (!
|
|
329
|
+
if (!r(o.next_action) || !a) throw q();
|
|
322
330
|
f(e, "signing");
|
|
323
|
-
let s = await
|
|
331
|
+
let s = await n(o.next_action, a);
|
|
324
332
|
return f(e, "confirming"), i.cancelSubscription(e, {
|
|
325
|
-
reason:
|
|
333
|
+
reason: t,
|
|
326
334
|
signature: s
|
|
327
335
|
});
|
|
328
336
|
}, () => s({
|
|
@@ -348,27 +356,27 @@ function K(r = {}) {
|
|
|
348
356
|
h,
|
|
349
357
|
i,
|
|
350
358
|
s
|
|
351
|
-
]), y = o(async (
|
|
352
|
-
f(
|
|
359
|
+
]), y = o(async (e, a, o) => {
|
|
360
|
+
f(e, "change");
|
|
353
361
|
try {
|
|
354
|
-
let
|
|
355
|
-
if (
|
|
356
|
-
f(
|
|
357
|
-
let
|
|
358
|
-
f(
|
|
362
|
+
let t = await i.changeSubscription(e, a);
|
|
363
|
+
if (t.status === "requires_action" && r(t.next_action) && o) {
|
|
364
|
+
f(e, "signing");
|
|
365
|
+
let r = await n(t.next_action, o);
|
|
366
|
+
f(e, "confirming"), t = await i.changeSubscription(e, {
|
|
359
367
|
...a,
|
|
360
|
-
signature:
|
|
368
|
+
signature: r
|
|
361
369
|
});
|
|
362
370
|
}
|
|
363
371
|
return s({
|
|
364
372
|
type: "subscription.changed",
|
|
365
|
-
subscriptionId:
|
|
366
|
-
change:
|
|
367
|
-
}),
|
|
368
|
-
} catch (
|
|
369
|
-
return e
|
|
373
|
+
subscriptionId: e,
|
|
374
|
+
change: t
|
|
375
|
+
}), t;
|
|
376
|
+
} catch (e) {
|
|
377
|
+
return t(e);
|
|
370
378
|
} finally {
|
|
371
|
-
f(
|
|
379
|
+
f(e, null);
|
|
372
380
|
}
|
|
373
381
|
}, [
|
|
374
382
|
i,
|
|
@@ -388,87 +396,88 @@ function K(r = {}) {
|
|
|
388
396
|
changeSubscription: y
|
|
389
397
|
};
|
|
390
398
|
}
|
|
391
|
-
function
|
|
392
|
-
let { client:
|
|
393
|
-
|
|
394
|
-
|
|
399
|
+
function Y({ merchant: e, keys: t }) {
|
|
400
|
+
let { client: n } = P(), r = G(JSON.stringify([e, t]), (r) => n.listProducts({
|
|
401
|
+
merchant: e,
|
|
402
|
+
keys: t,
|
|
403
|
+
signal: r
|
|
395
404
|
}));
|
|
396
405
|
return {
|
|
397
|
-
products:
|
|
398
|
-
loading:
|
|
399
|
-
error:
|
|
400
|
-
refetch:
|
|
406
|
+
products: r.data?.data ?? null,
|
|
407
|
+
loading: r.loading,
|
|
408
|
+
error: r.error,
|
|
409
|
+
refetch: r.refetch
|
|
401
410
|
};
|
|
402
411
|
}
|
|
403
|
-
function
|
|
404
|
-
let { client:
|
|
412
|
+
function X() {
|
|
413
|
+
let { client: e, version: n, notify: r } = P(), i = G(`${n}`, (t) => e.listPaymentMethods({ signal: t })), [a, s] = K(), [c, l] = d(!1), { replace: u } = i, f = o(async (n) => {
|
|
405
414
|
l(!0);
|
|
406
415
|
try {
|
|
407
|
-
let
|
|
408
|
-
return u((
|
|
409
|
-
...
|
|
410
|
-
data: [...
|
|
416
|
+
let t = await e.addPaymentMethod(n);
|
|
417
|
+
return u((e) => ({
|
|
418
|
+
...e,
|
|
419
|
+
data: [...e.data, t]
|
|
411
420
|
})), r({
|
|
412
421
|
type: "payment_method.added",
|
|
413
|
-
paymentMethodId:
|
|
422
|
+
paymentMethodId: t.id
|
|
414
423
|
}), null;
|
|
415
|
-
} catch (
|
|
416
|
-
return e
|
|
424
|
+
} catch (e) {
|
|
425
|
+
return t(e);
|
|
417
426
|
} finally {
|
|
418
427
|
l(!1);
|
|
419
428
|
}
|
|
420
429
|
}, [
|
|
421
|
-
|
|
430
|
+
e,
|
|
422
431
|
r,
|
|
423
432
|
u
|
|
424
433
|
]), p = o(async (n) => {
|
|
425
434
|
s(n, "remove");
|
|
426
435
|
try {
|
|
427
|
-
return await
|
|
436
|
+
return await e.removePaymentMethod(n), u((e) => ({
|
|
428
437
|
...e,
|
|
429
438
|
data: e.data.filter((e) => e.id !== n)
|
|
430
439
|
})), r({
|
|
431
440
|
type: "payment_method.removed",
|
|
432
441
|
paymentMethodId: n
|
|
433
442
|
}), null;
|
|
434
|
-
} catch (
|
|
435
|
-
return e
|
|
443
|
+
} catch (e) {
|
|
444
|
+
return t(e);
|
|
436
445
|
} finally {
|
|
437
446
|
s(n, null);
|
|
438
447
|
}
|
|
439
448
|
}, [
|
|
440
|
-
|
|
449
|
+
e,
|
|
441
450
|
s,
|
|
442
451
|
r,
|
|
443
452
|
u
|
|
444
453
|
]), m = o(async (n, i) => {
|
|
445
454
|
s(n, "default");
|
|
446
455
|
try {
|
|
447
|
-
await
|
|
456
|
+
await e.setDefaultPaymentMethod({
|
|
448
457
|
currency: i,
|
|
449
458
|
paymentMethodId: n
|
|
450
459
|
});
|
|
451
|
-
let
|
|
452
|
-
return u((
|
|
453
|
-
...
|
|
454
|
-
data:
|
|
455
|
-
let r = (
|
|
460
|
+
let t = i.toUpperCase();
|
|
461
|
+
return u((e) => ({
|
|
462
|
+
...e,
|
|
463
|
+
data: e.data.map((e) => {
|
|
464
|
+
let r = (e.default_currencies ?? []).filter((e) => e !== t);
|
|
456
465
|
return {
|
|
457
|
-
...
|
|
458
|
-
default_currencies:
|
|
466
|
+
...e,
|
|
467
|
+
default_currencies: e.id === n ? [...r, t] : r
|
|
459
468
|
};
|
|
460
469
|
})
|
|
461
470
|
})), r({
|
|
462
471
|
type: "payment_method.default_changed",
|
|
463
472
|
paymentMethodId: n
|
|
464
473
|
}), null;
|
|
465
|
-
} catch (
|
|
466
|
-
return e
|
|
474
|
+
} catch (e) {
|
|
475
|
+
return t(e);
|
|
467
476
|
} finally {
|
|
468
477
|
s(n, null);
|
|
469
478
|
}
|
|
470
479
|
}, [
|
|
471
|
-
|
|
480
|
+
e,
|
|
472
481
|
s,
|
|
473
482
|
r,
|
|
474
483
|
u
|
|
@@ -485,11 +494,11 @@ function J() {
|
|
|
485
494
|
setDefault: m
|
|
486
495
|
};
|
|
487
496
|
}
|
|
488
|
-
function
|
|
497
|
+
function Z(e = {}) {
|
|
489
498
|
let { client: t, version: n } = P(), r = e.pageSize ?? 20, i = `${r}|${e.rail ?? ""}`, [a, s] = d({
|
|
490
499
|
filter: i,
|
|
491
500
|
cursors: [null]
|
|
492
|
-
}), c = l(() => a.filter === i ? a.cursors : [null], [a, i]), u = c.length - 1, f = c[u], p =
|
|
501
|
+
}), c = l(() => a.filter === i ? a.cursors : [null], [a, i]), u = c.length - 1, f = c[u], p = G(`${i}|${f ?? ""}|${n}`, (n) => t.listPayments({
|
|
493
502
|
limit: r,
|
|
494
503
|
cursor: f,
|
|
495
504
|
rail: e.rail,
|
|
@@ -521,6 +530,6 @@ function Y(e = {}) {
|
|
|
521
530
|
};
|
|
522
531
|
}
|
|
523
532
|
//#endregion
|
|
524
|
-
export {
|
|
533
|
+
export { _ as S, E as _, U as a, m as b, V as c, I as d, L as f, k as g, O as h, J as i, F as l, j as m, Z as n, B as o, M as p, Y as r, H as s, X as t, P as u, w as v, v as x, h as y };
|
|
525
534
|
|
|
526
|
-
//# sourceMappingURL=hooks-
|
|
535
|
+
//# sourceMappingURL=hooks-Bk80rNv8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-Bk80rNv8.js","names":[],"sources":["../src/i18n/messages.ts","../src/i18n/context.ts","../src/appearance.ts","../src/scope-context.ts","../src/react/context.ts","../src/react/config.ts","../src/react/provider.tsx","../src/react/remote.ts","../src/react/hooks.ts"],"sourcesContent":["import { en } from \"../locales/en.ts\"\n\n/**\n * A count-dependent message: CLDR plural categories for the locale, with\n * `other` required. An exact-count key (`\"1\"`) wins over the category, like\n * ICU's `=1`, for locales whose single form differs from `{count}` (毎日).\n */\nexport type PluralMessage = {\n [K in Intl.LDMLPluralRule | \"1\"]?: string\n} & { other: string }\n\ntype Widen<T> = {\n [K in keyof T]: T[K] extends string\n ? string\n : T[K] extends PluralMessage\n ? PluralMessage\n : Widen<T[K]>\n}\n\n/** The complete message tree; English is the reference shape. */\nexport type BillingUiMessages = Widen<typeof en>\n\ntype DeepPartial<T> = {\n [K in keyof T]?: T[K] extends string\n ? string\n : T[K] extends PluralMessage\n ? Partial<PluralMessage>\n : DeepPartial<T[K]>\n}\n\n/** A locale bundle or host override: any subset of the tree. */\nexport type BillingUiMessageBundle = DeepPartial<BillingUiMessages>\n\ntype Paths<T, P extends string = \"\"> = {\n [K in keyof T & string]: T[K] extends string\n ? `${P}${K}`\n : T[K] extends PluralMessage\n ? never\n : Paths<T[K], `${P}${K}.`>\n}[keyof T & string]\n\ntype PluralPaths<T, P extends string = \"\"> = {\n [K in keyof T & string]: T[K] extends string\n ? never\n : T[K] extends PluralMessage\n ? `${P}${K}`\n : PluralPaths<T[K], `${P}${K}.`>\n}[keyof T & string]\n\n/** Dotted key of any message, e.g. `subscriptions.title`. */\nexport type MessageKey = Paths<BillingUiMessages>\n\n/** Dotted key of a count-dependent message, e.g. `interval.every.day`. */\nexport type PluralKey = PluralPaths<BillingUiMessages>\n\nexport type MessageVars = Record<string, string | number>\n\n/**\n * Host translation hook. Receives the bare key (`subscriptions.title`,\n * `errors.not_found`); return nothing or the key itself to use ours.\n */\nexport type BillingUiTranslate = (\n key: string,\n vars?: MessageVars\n) => string | null | undefined\n\n/** Types a locale bundle or override against the message tree. */\nexport function defineMessages(\n bundle: BillingUiMessageBundle\n): BillingUiMessageBundle {\n return bundle\n}\n\nexport const defaultMessages: BillingUiMessages = en\n\ntype Tree = { [key: string]: string | Tree }\n\nfunction mergeInto(target: Tree, source: Tree): Tree {\n const out: Tree = { ...target }\n for (const [key, value] of Object.entries(source)) {\n if (value === undefined || value === null) continue\n const current = out[key]\n if (typeof value === \"string\") {\n if (value !== \"\") out[key] = value\n } else if (typeof current === \"object\") {\n out[key] = mergeInto(current, value)\n } else {\n out[key] = mergeInto({}, value)\n }\n }\n return out\n}\n\n/** Layers bundles over English; later bundles win, missing keys fall back. */\nexport function resolveMessages(\n bundles?: BillingUiMessageBundle | readonly BillingUiMessageBundle[]\n): BillingUiMessages {\n const list = bundles ? (Array.isArray(bundles) ? bundles : [bundles]) : []\n let tree = en as unknown as Tree\n for (const bundle of list) tree = mergeInto(tree, bundle as Tree)\n return tree as unknown as BillingUiMessages\n}\n\nexport function interpolate(template: string, vars?: MessageVars): string {\n if (!vars) return template\n return template.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n name in vars ? String(vars[name]) : match\n )\n}\n\nfunction lookup(messages: BillingUiMessages, key: string): string | undefined {\n let node: unknown = messages\n for (const part of key.split(\".\")) {\n if (!node || typeof node !== \"object\") return undefined\n node = (node as Tree)[part]\n }\n return typeof node === \"string\" ? node : undefined\n}\n\nexport interface Translator {\n messages: BillingUiMessages\n /** BCP 47 tag used for plural rules and numbers; the runtime's when unset. */\n locale?: string\n t(key: MessageKey, vars?: MessageVars): string\n /**\n * Count-dependent message: tries `<key>.<count>`, then the locale's plural\n * category, then `<key>.other`. `{count}` is locale-formatted.\n */\n plural(key: PluralKey, count: number, vars?: MessageVars): string\n /** Message for a billing error, error code, or thrown value. */\n error(error: unknown, vars?: MessageVars): string\n}\n\nfunction errorCode(error: unknown): string | undefined {\n if (typeof error === \"string\") return error\n if (error && typeof error === \"object\" && \"code\" in error) {\n const code = (error as { code: unknown }).code\n if (typeof code === \"string\") return code\n }\n return undefined\n}\n\nfunction isNetworkError(error: unknown): boolean {\n return error instanceof TypeError && /fetch|network/i.test(error.message)\n}\n\nfunction pluralRules(locale?: string): Intl.PluralRules {\n try {\n return new Intl.PluralRules(locale)\n } catch {\n return new Intl.PluralRules(\"en\")\n }\n}\n\nfunction formatCount(count: number, locale?: string): string {\n try {\n return new Intl.NumberFormat(locale).format(count)\n } catch {\n return String(count)\n }\n}\n\nexport function createTranslator(\n messages: BillingUiMessages,\n hostT?: BillingUiTranslate,\n locale?: string\n): Translator {\n const rules = pluralRules(locale)\n const translate = (key: string, vars?: MessageVars): string | undefined => {\n const hosted = hostT?.(key, vars)\n if (hosted && hosted !== key) return hosted\n const own = lookup(messages, key)\n return own === undefined ? undefined : interpolate(own, vars)\n }\n return {\n messages,\n locale,\n t: (key, vars) => translate(key, vars) ?? key,\n plural(key, count, vars) {\n const all = { ...vars, count: formatCount(count, locale) }\n return (\n translate(`${key}.${count}`, all) ??\n translate(`${key}.${rules.select(count)}`, all) ??\n translate(`${key}.other`, all) ??\n key\n )\n },\n error(error, vars) {\n const code = errorCode(error)\n if (code && code !== \"generic\" && code !== \"network\") {\n const metadata =\n error && typeof error === \"object\" && \"metadata\" in error\n ? (error as { metadata?: MessageVars }).metadata\n : undefined\n const message = translate(`errors.${code}`, { ...metadata, ...vars })\n if (message) return message\n }\n const fallback = isNetworkError(error)\n ? \"errors.network\"\n : \"errors.generic\"\n return translate(fallback, vars) ?? messages.errors.generic\n },\n }\n}\n","import { createContext, useContext } from \"react\"\n\nimport {\n createTranslator,\n defaultMessages,\n type Translator,\n} from \"./messages.ts\"\n\nexport const MessagesContext = createContext<Translator>(\n createTranslator(defaultMessages)\n)\n\n/** English defaults when rendered outside a `BillingProvider`. */\nexport function useMessages(): Translator {\n return useContext(MessagesContext)\n}\n","// Integrator theming. The component scopes the standard shadcn token set\n// under its root, so `theme` flips the whole palette and `variables` override\n// individual tokens without the integrator touching our CSS.\nimport type { CSSProperties } from \"react\"\n\n// `inherit` uses the host page's shadcn tokens (`--background`, ...) and its\n// `.dark` class instead of the bundled zinc palette.\nexport type CheckoutTheme = \"light\" | \"dark\" | \"auto\" | \"inherit\"\n\n// The tokens integrators may override. Values are raw CSS color/length\n// strings; they land as custom properties on the checkout root.\nexport interface CheckoutVariables {\n background?: string\n foreground?: string\n card?: string\n mutedForeground?: string\n faintForeground?: string\n border?: string\n input?: string\n primary?: string\n primaryForeground?: string\n destructive?: string\n ring?: string\n radius?: string\n fontFamily?: string\n}\n\nexport interface CheckoutAppearance {\n theme?: CheckoutTheme\n variables?: CheckoutVariables\n}\n\nconst VARIABLE_TO_CSS: Record<keyof CheckoutVariables, string> = {\n background: \"--background\",\n foreground: \"--foreground\",\n card: \"--card\",\n mutedForeground: \"--muted-foreground\",\n faintForeground: \"--orck-faint\",\n border: \"--border\",\n input: \"--input\",\n primary: \"--primary\",\n primaryForeground: \"--primary-foreground\",\n destructive: \"--destructive\",\n ring: \"--ring\",\n radius: \"--radius\",\n fontFamily: \"--orck-font\",\n}\n\nexport function appearanceStyle(\n appearance: CheckoutAppearance | undefined\n): CSSProperties | undefined {\n const variables = appearance?.variables\n if (!variables) return undefined\n const style: Record<string, string> = {}\n for (const [key, value] of Object.entries(variables)) {\n if (!value) continue\n style[VARIABLE_TO_CSS[key as keyof CheckoutVariables]] = value\n }\n return style as CSSProperties\n}\n\nexport function appearanceTheme(\n appearance: CheckoutAppearance | undefined\n): CheckoutTheme {\n return appearance?.theme ?? \"auto\"\n}\n","import { createContext, useContext, type CSSProperties } from \"react\"\n\nimport {\n appearanceStyle,\n appearanceTheme,\n type CheckoutAppearance,\n type CheckoutTheme,\n} from \"./appearance\"\n\nexport type Navigate = (to: string) => void\n\nexport interface UiSettings {\n appearance?: CheckoutAppearance\n locale?: string\n navigate?: Navigate\n}\n\nexport const UiContext = createContext<UiSettings>({})\n\nexport const useUiSettings = (): UiSettings => useContext(UiContext)\n\nexport interface ScopeProps {\n className: string\n \"data-orck-theme\": CheckoutTheme\n style?: CSSProperties\n}\n\n/** Props that make an element a styling root; portals carry them too. */\nexport function useScopeProps(appearance?: CheckoutAppearance): ScopeProps {\n const settings = useUiSettings()\n const resolved = appearance ?? settings.appearance\n return {\n className: \"orck\",\n \"data-orck-theme\": appearanceTheme(resolved),\n style: appearanceStyle(resolved),\n }\n}\n","import { createContext, useContext } from \"react\"\n\nimport type { BillingClient } from \"../client/client\"\nimport type { CustomerConfig, SubscriptionChange } from \"../client/types\"\nimport type { ConfigStore } from \"./config\"\n\nexport type BillingChange =\n | {\n type: \"subscription.canceled\" | \"subscription.resumed\"\n subscriptionId: string\n }\n | {\n type: \"subscription.payment_method_changed\"\n subscriptionId: string\n /** null: the subscription follows the default card. */\n paymentMethodId: string | null\n }\n | {\n type: \"subscription.changed\"\n subscriptionId: string\n /** `status` may still be `processing` or `requires_action`. */\n change: SubscriptionChange\n }\n | {\n type:\n | \"payment_method.added\"\n | \"payment_method.removed\"\n | \"payment_method.default_changed\"\n paymentMethodId: string\n }\n\nexport interface BillingContextValue {\n client: BillingClient\n /** Bumped after every mutation; hooks refetch on change. */\n version: number\n notify(change: BillingChange): void\n /** Refetch every hook after a host-side change such as a plan switch. */\n refresh(): void\n /** The shared `GET /config`; read it with `useConfig()`. */\n config: ConfigStore\n /** The shared `GET /me/config`; read it with `useCustomerConfig()`. */\n customerConfig: ConfigStore<CustomerConfig>\n}\n\nexport const BillingContext = createContext<BillingContextValue | null>(null)\n\nexport function useBillingContext(): BillingContextValue {\n const ctx = useContext(BillingContext)\n if (!ctx) throw new Error(\"billing-ui: wrap the tree in <BillingProvider>\")\n return ctx\n}\n\nexport const useBillingClient = (): BillingClient => useBillingContext().client\n\nexport const useBillingRefresh = (): (() => void) => useBillingContext().refresh\n\n/** The billing context when a BillingProvider is present, else null. */\nexport const useOptionalBillingContext = (): BillingContextValue | null =>\n useContext(BillingContext)\n","import { useEffect, useMemo, useSyncExternalStore } from \"react\"\n\nimport { toBillingError, type BillingError } from \"../client/errors\"\nimport type {\n CurrencyScales,\n CustomerConfig,\n PublicConfig,\n} from \"../client/types\"\nimport { useBillingContext } from \"./context\"\n\nexport interface ConfigState<T = PublicConfig> {\n config: T | null\n loading: boolean\n error: BillingError | null\n refetch: () => void\n}\n\ninterface Snapshot<T> {\n config: T | null\n loading: boolean\n error: BillingError | null\n}\n\n/** One shared copy of a configuration read per client, fetched on first use. */\nexport interface ConfigStore<T = PublicConfig> {\n subscribe(listener: () => void): () => void\n snapshot(): Snapshot<T>\n /** Fetches the document unless it is loaded or loading. */\n ensure(): void\n refetch(): void\n}\n\nexport function createConfigStore<T>(read: () => Promise<T>): ConfigStore<T> {\n let snapshot: Snapshot<T> = { config: null, loading: true, error: null }\n let started = false\n let latest = 0\n const listeners = new Set<() => void>()\n const set = (next: Snapshot<T>) => {\n snapshot = next\n for (const listener of listeners) listener()\n }\n const load = () => {\n started = true\n const request = ++latest\n if (!snapshot.loading) set({ ...snapshot, loading: true })\n read().then(\n (config) => {\n if (request === latest) set({ config, loading: false, error: null })\n },\n (err: unknown) => {\n if (request === latest)\n set({\n config: snapshot.config,\n loading: false,\n error: toBillingError(err),\n })\n }\n )\n }\n return {\n subscribe(listener) {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n snapshot: () => snapshot,\n // A read that failed with nothing loaded is tried again by the next\n // component: the customer may have signed in since.\n ensure() {\n if (!started || (snapshot.error && !snapshot.config && !snapshot.loading))\n load()\n },\n refetch: load,\n }\n}\n\nfunction useStore<T>(store: ConfigStore<T>): ConfigState<T> {\n const snapshot = useSyncExternalStore(\n store.subscribe,\n store.snapshot,\n store.snapshot\n )\n useEffect(() => store.ensure(), [store])\n return { ...snapshot, refetch: store.refetch }\n}\n\n/**\n * The deployment's configuration (`GET /config`), fetched once per\n * `BillingProvider` and shared by every component that reads it.\n */\nexport function useConfig(): ConfigState {\n return useStore(useBillingContext().config)\n}\n\n/**\n * The customer's merchant (`GET /me/config`): its payment setup and how it\n * presents itself, fetched once per `BillingProvider` for the signed-in\n * customer and shared by every component that reads it.\n */\nexport function useCustomerConfig(): ConfigState<CustomerConfig> {\n return useStore(useBillingContext().customerConfig)\n}\n\n/**\n * Currency scales: the server's registry, under the client's pinned copy and\n * host overrides, which stand alone until the registry loads.\n */\nexport function useCurrencyScales(): CurrencyScales {\n const { client } = useBillingContext()\n const { config } = useConfig()\n return useMemo(() => {\n const served = Object.fromEntries(\n (config?.currencies ?? []).map((c) => [c.code.toUpperCase(), c.decimals])\n )\n return { ...served, ...client.currencies }\n }, [config, client])\n}\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\"\n\nimport type { CheckoutAppearance } from \"../appearance\"\nimport type { BillingClient } from \"../client/client\"\nimport { MessagesContext } from \"../i18n/context\"\nimport {\n createTranslator,\n resolveMessages,\n type BillingUiMessageBundle,\n type BillingUiTranslate,\n} from \"../i18n/messages\"\nimport { UiContext, type Navigate } from \"../scope-context\"\nimport { createConfigStore } from \"./config\"\nimport { BillingContext, type BillingChange } from \"./context\"\n\nexport interface BillingProviderProps {\n /**\n * The customer's client: hooks and the account panels read it, and a\n * checkout saves a new card to the customer first. Leave it out where no\n * customer is signed in, such as the shared payment page.\n */\n client?: BillingClient\n /** Fires after each successful mutation: the host's cache-invalidation hook. */\n onChange?: (change: BillingChange) => void\n appearance?: CheckoutAppearance\n /** Locale bundle(s) layered over English; later entries win. */\n messages?: BillingUiMessageBundle | readonly BillingUiMessageBundle[]\n /** Host translation hook, consulted before the bundles. */\n t?: BillingUiTranslate\n /** BCP 47 tag for dates, money and plurals; defaults to the browser's. */\n locale?: string\n /** Host router for in-app links (e.g. the plans page). */\n navigate?: Navigate\n children?: ReactNode\n}\n\n/**\n * The one billing-ui provider: the client, and the appearance and words of\n * the styled components. Renders no DOM; surfaces create their own styling\n * roots, and no stylesheet loads until a styled component is imported.\n */\nexport function BillingProvider({\n client,\n onChange,\n appearance,\n messages,\n t,\n locale,\n navigate,\n children,\n}: BillingProviderProps) {\n const translator = useMemo(\n () => createTranslator(resolveMessages(messages), t, locale),\n [messages, t, locale]\n )\n const ui = useMemo(\n () => ({ appearance, locale, navigate }),\n [appearance, locale, navigate]\n )\n return (\n <UiContext.Provider value={ui}>\n <MessagesContext.Provider value={translator}>\n {client ? (\n <ClientProvider client={client} onChange={onChange}>\n {children}\n </ClientProvider>\n ) : (\n children\n )}\n </MessagesContext.Provider>\n </UiContext.Provider>\n )\n}\n\nfunction ClientProvider({\n client,\n onChange,\n children,\n}: {\n client: BillingClient\n onChange?: (change: BillingChange) => void\n children?: ReactNode\n}) {\n const [version, setVersion] = useState(0)\n const onChangeRef = useRef(onChange)\n useEffect(() => {\n onChangeRef.current = onChange\n })\n const notify = useCallback((change: BillingChange) => {\n setVersion((v) => v + 1)\n onChangeRef.current?.(change)\n }, [])\n const refresh = useCallback(() => setVersion((v) => v + 1), [])\n const config = useMemo(\n () => createConfigStore(() => client.getConfig()),\n [client]\n )\n const customerConfig = useMemo(\n () => createConfigStore(() => client.getCustomerConfig()),\n [client]\n )\n const value = useMemo(\n () => ({ client, version, notify, refresh, config, customerConfig }),\n [client, version, notify, refresh, config, customerConfig]\n )\n return (\n <BillingContext.Provider value={value}>{children}</BillingContext.Provider>\n )\n}\n","import { useCallback, useEffect, useRef, useState } from \"react\"\n\nimport { toBillingError, type BillingError } from \"../client/errors\"\n\nexport interface RemoteState<T> {\n data: T | null\n loading: boolean\n error: BillingError | null\n refetch: () => void\n}\n\n// Keyed fetch that keeps the previous data while a newer key loads, so a\n// refetch after a mutation never flashes an empty list.\nexport function useRemote<T>(\n key: string,\n load: (signal: AbortSignal) => Promise<T>\n): RemoteState<T> & { replace: (update: (data: T) => T) => void } {\n const [nonce, setNonce] = useState(0)\n const request = `${key}|${nonce}`\n const [state, setState] = useState<{\n request: string | null\n data: T | null\n error: BillingError | null\n }>({ request: null, data: null, error: null })\n const loadRef = useRef(load)\n useEffect(() => {\n loadRef.current = load\n })\n\n useEffect(() => {\n const ctl = new AbortController()\n loadRef.current(ctl.signal).then(\n (data) => setState({ request, data, error: null }),\n (err: unknown) => {\n if (!ctl.signal.aborted)\n setState((s) => ({\n request,\n data: s.data,\n error: toBillingError(err),\n }))\n }\n )\n return () => ctl.abort()\n }, [request])\n\n const refetch = useCallback(() => setNonce((n) => n + 1), [])\n const replace = useCallback(\n (update: (data: T) => T) =>\n setState((s) => (s.data === null ? s : { ...s, data: update(s.data) })),\n []\n )\n return {\n data: state.data,\n loading: state.request !== request,\n error: state.request === request ? state.error : null,\n refetch,\n replace,\n }\n}\n","import { useCallback, useMemo, useState } from \"react\"\n\nimport {\n isWalletAction,\n signWalletAction,\n type ProductListOptions,\n type SendSolanaTransaction,\n type SubscriptionChangeInput,\n} from \"../client/client\"\nimport { localError, toBillingError, type BillingError } from \"../client/errors\"\nimport type {\n NewCard,\n Payment,\n PaymentMethod,\n Product,\n Subscription,\n SubscriptionChange,\n} from \"../client/types\"\nimport { useBillingContext } from \"./context\"\nimport { useRemote } from \"./remote\"\n\n// Actions never throw: they resolve to null on success or the error.\nexport type ActionResult = Promise<BillingError | null>\n\n/** `signing` and `confirming` are a wallet step's stages. */\nexport type SubscriptionAction =\n | \"cancel\"\n | \"resume\"\n | \"payment_method\"\n | \"change\"\n | \"signing\"\n | \"confirming\"\n\nexport interface SubscriptionsOptions {\n /** Server filter; default `all`. */\n status?: string\n limit?: number\n}\n\nexport interface SubscriptionsState {\n subscriptions: Subscription[] | null\n /** The next page's cursor; null on the last page. */\n nextCursor: string | null\n loading: boolean\n error: BillingError | null\n refetch: () => void\n /** In-flight action per subscription id. */\n pending: Readonly<Record<string, SubscriptionAction>>\n /**\n * Cancels at period end. A Solana subscription is canceled by the wallet:\n * pass `sendTransaction`; without it the cancel resolves to a\n * `wallet_required` error.\n */\n cancel: (\n subscriptionId: string,\n reason: string,\n sendTransaction?: SendSolanaTransaction\n ) => ActionResult\n resume: (subscriptionId: string) => ActionResult\n /** `null` makes the subscription follow the default card. */\n setPaymentMethod: (\n subscriptionId: string,\n paymentMethodId: string | null\n ) => ActionResult\n /**\n * Resolves to the change, whose `status` may still be `processing` or\n * `requires_action`, or to the error. A Solana change is signed with\n * `sendTransaction` and resolves once the chain confirms it.\n */\n changeSubscription: (\n subscriptionId: string,\n input: SubscriptionChangeInput & { idempotencyKey: string },\n sendTransaction?: SendSolanaTransaction\n ) => Promise<SubscriptionChange | BillingError>\n}\n\nfunction usePending<A extends string>() {\n const [pending, setPending] = useState<Readonly<Record<string, A>>>({})\n const mark = useCallback((id: string, action: A | null) => {\n setPending((p) => {\n const next = { ...p }\n if (action) next[id] = action\n else delete next[id]\n return next\n })\n }, [])\n return [pending, mark] as const\n}\n\nconst walletRequired = () =>\n localError(\"wallet_required\", \"A wallet must sign this action.\")\n\nexport function useSubscriptions(\n options: SubscriptionsOptions = {}\n): SubscriptionsState {\n const { client, version, notify } = useBillingContext()\n const status = options.status ?? \"all\"\n const limit = options.limit ?? 100\n const remote = useRemote(`${status}|${limit}|${version}`, (signal) =>\n client.listSubscriptions({ status, limit, signal })\n )\n const [pending, mark] = usePending<SubscriptionAction>()\n const { replace } = remote\n\n const patchRow = useCallback(\n (next: Subscription) =>\n replace((page) => ({\n ...page,\n data: page.data.map((s) => (s.id === next.id ? next : s)),\n })),\n [replace]\n )\n\n const act = useCallback(\n async (\n id: string,\n action: SubscriptionAction,\n run: () => Promise<Subscription>,\n done: (subscription: Subscription) => void\n ): ActionResult => {\n mark(id, action)\n try {\n const next = await run()\n patchRow(next)\n done(next)\n return null\n } catch (err) {\n return toBillingError(err)\n } finally {\n mark(id, null)\n }\n },\n [mark, patchRow]\n )\n\n // A declined wallet prompt resolves to a `wallet_rejected` error.\n const cancel = useCallback(\n (id: string, reason: string, sendTransaction?: SendSolanaTransaction) =>\n act(\n id,\n \"cancel\",\n async () => {\n const sub = await client.cancelSubscription(id, { reason })\n if (!sub.next_action) return sub\n if (!isWalletAction(sub.next_action) || !sendTransaction)\n throw walletRequired()\n mark(id, \"signing\")\n const signature = await signWalletAction(\n sub.next_action,\n sendTransaction\n )\n mark(id, \"confirming\")\n return client.cancelSubscription(id, { reason, signature })\n },\n () => notify({ type: \"subscription.canceled\", subscriptionId: id })\n ),\n [act, client, mark, notify]\n )\n\n const resume = useCallback(\n (id: string) =>\n act(\n id,\n \"resume\",\n () => client.resumeSubscription(id),\n () => notify({ type: \"subscription.resumed\", subscriptionId: id })\n ),\n [act, client, notify]\n )\n\n const setPaymentMethod = useCallback(\n (id: string, paymentMethodId: string | null) =>\n act(\n id,\n \"payment_method\",\n () => client.setSubscriptionPaymentMethod(id, paymentMethodId),\n () =>\n notify({\n type: \"subscription.payment_method_changed\",\n subscriptionId: id,\n paymentMethodId,\n })\n ),\n [act, client, notify]\n )\n\n // An upgrade may open a successor subscription: notify refetches the list.\n const changeSubscription = useCallback(\n async (\n id: string,\n input: SubscriptionChangeInput & { idempotencyKey: string },\n sendTransaction?: SendSolanaTransaction\n ) => {\n mark(id, \"change\")\n try {\n let change = await client.changeSubscription(id, input)\n if (\n change.status === \"requires_action\" &&\n isWalletAction(change.next_action) &&\n sendTransaction\n ) {\n mark(id, \"signing\")\n const signature = await signWalletAction(\n change.next_action!,\n sendTransaction\n )\n mark(id, \"confirming\")\n change = await client.changeSubscription(id, { ...input, signature })\n }\n notify({\n type: \"subscription.changed\",\n subscriptionId: id,\n change,\n })\n return change\n } catch (err) {\n return toBillingError(err)\n } finally {\n mark(id, null)\n }\n },\n [client, mark, notify]\n )\n\n return {\n subscriptions: remote.data?.data ?? null,\n nextCursor: remote.data?.next_cursor ?? null,\n loading: remote.loading,\n error: remote.error,\n refetch: remote.refetch,\n pending,\n cancel,\n resume,\n setPaymentMethod,\n changeSubscription,\n }\n}\n\nexport interface ProductsState {\n products: Product[] | null\n loading: boolean\n error: BillingError | null\n refetch: () => void\n}\n\n/** The merchant and its product keys to look up: `ProductListOptions`. */\nexport type ProductsOptions = Pick<ProductListOptions, \"merchant\" | \"keys\">\n\n/**\n * The products `merchant` has on sale named by `keys`, each with its active\n * prices: a public catalog lookup.\n */\nexport function useProducts({\n merchant,\n keys,\n}: ProductsOptions): ProductsState {\n const { client } = useBillingContext()\n const remote = useRemote(JSON.stringify([merchant, keys]), (signal) =>\n client.listProducts({ merchant, keys, signal })\n )\n return {\n products: remote.data?.data ?? null,\n loading: remote.loading,\n error: remote.error,\n refetch: remote.refetch,\n }\n}\n\nexport type PaymentMethodAction = \"remove\" | \"default\"\n\nexport interface PaymentMethodsState {\n methods: PaymentMethod[] | null\n loading: boolean\n error: BillingError | null\n refetch: () => void\n pending: Readonly<Record<string, PaymentMethodAction>>\n adding: boolean\n add: (card: NewCard) => ActionResult\n remove: (paymentMethodId: string) => ActionResult\n /** Makes the card the default for the currency. */\n setDefault: (paymentMethodId: string, currency: string) => ActionResult\n}\n\nexport function usePaymentMethods(): PaymentMethodsState {\n const { client, version, notify } = useBillingContext()\n const remote = useRemote(`${version}`, (signal) =>\n client.listPaymentMethods({ signal })\n )\n const [pending, mark] = usePending<PaymentMethodAction>()\n const [adding, setAdding] = useState(false)\n const { replace } = remote\n\n const add = useCallback(\n async (card: NewCard): ActionResult => {\n setAdding(true)\n try {\n const method = await client.addPaymentMethod(card)\n replace((page) => ({ ...page, data: [...page.data, method] }))\n notify({ type: \"payment_method.added\", paymentMethodId: method.id })\n return null\n } catch (err) {\n return toBillingError(err)\n } finally {\n setAdding(false)\n }\n },\n [client, notify, replace]\n )\n\n const remove = useCallback(\n async (id: string): ActionResult => {\n mark(id, \"remove\")\n try {\n await client.removePaymentMethod(id)\n replace((page) => ({\n ...page,\n data: page.data.filter((m) => m.id !== id),\n }))\n notify({ type: \"payment_method.removed\", paymentMethodId: id })\n return null\n } catch (err) {\n return toBillingError(err)\n } finally {\n mark(id, null)\n }\n },\n [client, mark, notify, replace]\n )\n\n const setDefault = useCallback(\n async (id: string, currency: string): ActionResult => {\n mark(id, \"default\")\n try {\n await client.setDefaultPaymentMethod({\n currency,\n paymentMethodId: id,\n })\n const code = currency.toUpperCase()\n replace((page) => ({\n ...page,\n data: page.data.map((m) => {\n const others = (m.default_currencies ?? []).filter(\n (c) => c !== code\n )\n return {\n ...m,\n default_currencies: m.id === id ? [...others, code] : others,\n }\n }),\n }))\n notify({\n type: \"payment_method.default_changed\",\n paymentMethodId: id,\n })\n return null\n } catch (err) {\n return toBillingError(err)\n } finally {\n mark(id, null)\n }\n },\n [client, mark, notify, replace]\n )\n\n return {\n methods: remote.data?.data ?? null,\n loading: remote.loading,\n error: remote.error,\n refetch: remote.refetch,\n pending,\n adding,\n add,\n remove,\n setDefault,\n }\n}\n\nexport interface PaymentsOptions {\n pageSize?: number\n /** Filter by rail. */\n rail?: string\n}\n\nexport interface PaymentsState {\n payments: Payment[] | null\n /** Zero-based. */\n page: number\n hasMore: boolean\n loading: boolean\n error: BillingError | null\n next: () => void\n previous: () => void\n refetch: () => void\n}\n\nexport function usePayments(options: PaymentsOptions = {}): PaymentsState {\n const { client, version } = useBillingContext()\n const pageSize = options.pageSize ?? 20\n // cursors[i] reads page i of this filter; page 0 is the newest payments.\n const filter = `${pageSize}|${options.rail ?? \"\"}`\n const [state, setState] = useState({\n filter,\n cursors: [null] as (string | null)[],\n })\n const cursors = useMemo(\n () => (state.filter === filter ? state.cursors : [null]),\n [state, filter]\n )\n const page = cursors.length - 1\n const cursor = cursors[page]\n const remote = useRemote(`${filter}|${cursor ?? \"\"}|${version}`, (signal) =>\n client.listPayments({\n limit: pageSize,\n cursor,\n rail: options.rail,\n signal,\n })\n )\n const data = remote.data\n const nextCursor = data?.next_cursor ?? null\n return {\n payments: data?.data ?? null,\n page,\n hasMore: nextCursor !== null,\n loading: remote.loading,\n error: remote.error,\n next: useCallback(() => {\n if (nextCursor !== null)\n setState({ filter, cursors: [...cursors, nextCursor] })\n }, [filter, cursors, nextCursor]),\n previous: useCallback(() => {\n if (cursors.length > 1)\n setState({ filter, cursors: cursors.slice(0, -1) })\n }, [filter, cursors]),\n refetch: remote.refetch,\n }\n}\n"],"mappings":";;;;;AAmEA,SAAgB,EACd,GACwB;CACxB,OAAO;AACT;AAEA,IAAa,IAAqC;AAIlD,SAAS,EAAU,GAAc,GAAoB;CACnD,IAAM,IAAY,EAAE,GAAG,EAAO;CAC9B,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAM,GAAG;EACjD,IAAI,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M,QAAQ;EAC9B,SAAS,EAAO;EAChB,OAAO,EAAO;EACd,SAAS,EAAO;EAChB;EACA;EACA;EACA;EACA;CACF;AACF;AAoBA,SAAgB,EAAY,IAA2B,CAAC,GAAkB;CACxE,IAAM,EAAE,WAAQ,eAAY,EAAkB,GACxC,IAAW,EAAQ,YAAY,IAE/B,IAAS,GAAG,EAAS,GAAG,EAAQ,QAAQ,MACxC,CAAC,GAAO,KAAY,EAAS;EACjC;EACA,SAAS,CAAC,IAAI;CAChB,CAAC,GACK,IAAU,QACP,EAAM,WAAW,IAAS,EAAM,UAAU,CAAC,IAAI,GACtD,CAAC,GAAO,CAAM,CAChB,GACM,IAAO,EAAQ,SAAS,GACxB,IAAS,EAAQ,IACjB,IAAS,EAAU,GAAG,EAAO,GAAG,KAAU,GAAG,GAAG,MAAY,MAChE,EAAO,aAAa;EAClB,OAAO;EACP;EACA,MAAM,EAAQ;EACd;CACF,CAAC,CACH,GACM,IAAO,EAAO,MACd,IAAa,GAAM,eAAe;CACxC,OAAO;EACL,UAAU,GAAM,QAAQ;EACxB;EACA,SAAS,MAAe;EACxB,SAAS,EAAO;EAChB,OAAO,EAAO;EACd,MAAM,QAAkB;GACtB,AAAI,MAAe,QACjB,EAAS;IAAE;IAAQ,SAAS,CAAC,GAAG,GAAS,CAAU;GAAE,CAAC;EAC1D,GAAG;GAAC;GAAQ;GAAS;EAAU,CAAC;EAChC,UAAU,QAAkB;GAC1B,AAAI,EAAQ,SAAS,KACnB,EAAS;IAAE;IAAQ,SAAS,EAAQ,MAAM,GAAG,EAAE;GAAE,CAAC;EACtD,GAAG,CAAC,GAAQ,CAAO,CAAC;EACpB,SAAS,EAAO;CAClB;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createBillingClient, type BillingClient, type BillingClientOptions, type ProductListOptions, } from './client/client';
|
|
2
|
+
export { redeemAssertion, tokenSource, type RedeemAssertionOptions, type TokenResponse, type TokenSource, type TokenSourceOptions, } from './client/token-source';
|
|
2
3
|
export { BillingProvider, type BillingProviderProps } from './react/provider';
|
|
3
4
|
export { BillingUiRoot } from './scope';
|
|
4
5
|
export type { Navigate } from './scope-context';
|
|
@@ -8,24 +9,20 @@ export { CancelSubscriptionDialog, type CancelSubscriptionDialogProps, } from '.
|
|
|
8
9
|
export { PaymentMethodsPanel, type PaymentMethodsPanelProps, } from './account/payment-methods-panel';
|
|
9
10
|
export { SavePaymentMethod, type SavePaymentMethodProps, } from './save-payment-method';
|
|
10
11
|
export { OrderCheckout, type OrderCheckoutProps } from './order-checkout';
|
|
12
|
+
export { CHECKOUT_COMPLETE_MESSAGE, CHECKOUT_RESIZE_MESSAGE, EmbeddedCheckout, type EmbeddedCheckoutCompletion, type EmbeddedCheckoutProps, } from './embedded-checkout';
|
|
11
13
|
export { Cart, type CartProps } from './cart';
|
|
12
|
-
export {
|
|
13
|
-
export { canAuthenticatePayment, canSavePaymentMethod, cardSetupDriver, checkoutPsps,
|
|
14
|
+
export { authenticateChange } from './authenticate';
|
|
15
|
+
export { canAuthenticatePayment, canSavePaymentMethod, cardSetupDriver, checkoutPsps, pspConfigSchema, type CardSetupDriver, type PspConfig, } from './psp';
|
|
14
16
|
export { PaymentHistory, type PaymentHistoryProps, } from './account/payment-history';
|
|
15
17
|
export { BillingStatusBadge, type BillingStatusBadgeProps, } from './account/status-badge';
|
|
16
18
|
export { statusTone, type StatusTone } from './account/format';
|
|
17
19
|
export { createTranslator, defaultMessages, defineMessages, interpolate, resolveMessages, useMessages, type BillingUiMessageBundle, type BillingUiMessages, type BillingUiTranslate, type MessageKey, type PluralKey, type PluralMessage, type MessageVars, type Translator, } from './i18n';
|
|
18
|
-
export type { CheckoutLayout } from './checkout';
|
|
19
20
|
export { BuyButton, type BuyButtonProps } from './buy-button';
|
|
20
21
|
export { Offers, type OffersProps } from './offers';
|
|
21
|
-
export { CheckoutPage, type CheckoutPageProps } from './checkout-page';
|
|
22
|
-
export { CheckoutFrame, type CheckoutFrameProps } from './checkout-frame';
|
|
23
|
-
export type { CheckoutFrameTheme } from './frame';
|
|
24
22
|
export { CardBrandPlate } from './components/card-brands';
|
|
25
23
|
export { resolveCardBrand, type CardBrand } from './lib/card-brands';
|
|
26
24
|
export { browserCountry, initialCountry } from './lib/billing';
|
|
27
25
|
export { addAmounts, amountToDecimal, formatAmount, isAmount, type Amount, } from './lib/money';
|
|
28
26
|
export { type CheckoutAppearance, type CheckoutAppearance as BillingAppearance, type CheckoutTheme, type CheckoutVariables, } from './appearance';
|
|
29
|
-
export type {
|
|
30
|
-
export { amountSchema, checkoutLineItemSchema, checkoutPlanSchema, checkoutSessionSchema, checkoutSessionStatusSchema, nextActionSchema, paymentFailureSchema, payRequestSchema, payResultSchema, paymentOptionSchema, savedPaymentMethodSchema, unitDecimalsSchema, } from './types';
|
|
27
|
+
export type { SavedPaymentMethod } from './types';
|
|
31
28
|
export { TokenizedCardForm, type TokenizedCardFormProps, type TokenizedCardData, } from './tokenized-card-form';
|