@openrails/billing-ui 0.234.0 → 0.236.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +142 -2
  2. package/README.md +119 -85
  3. package/dist/account/account-billing.d.ts +6 -5
  4. package/dist/account/change-card-dialog.d.ts +5 -2
  5. package/dist/account/payment-methods-panel.d.ts +6 -5
  6. package/dist/buy-button.d.ts +35 -0
  7. package/dist/cart.d.ts +18 -0
  8. package/dist/checkout.d.ts +1 -3
  9. package/dist/client/checkout.d.ts +28 -0
  10. package/dist/client/client.d.ts +98 -63
  11. package/dist/client/errors.d.ts +5 -4
  12. package/dist/client/generated/error-codes.d.ts +1 -1
  13. package/dist/client/generated/routes.d.ts +142 -99
  14. package/dist/client/generated/wire.d.ts +185 -98
  15. package/dist/client/index.d.ts +2 -2
  16. package/dist/client/types.d.ts +272 -29
  17. package/dist/{client-CWX6QpLa.js → client-BuvolBPT.js} +498 -326
  18. package/dist/client-BuvolBPT.js.map +1 -0
  19. package/dist/client.js +2 -2
  20. package/dist/components/stripe-card.d.ts +8 -2
  21. package/dist/components/stripe-wallets.d.ts +12 -0
  22. package/dist/components/ui/badge.d.ts +1 -1
  23. package/dist/components/ui/button.d.ts +1 -1
  24. package/dist/frame.d.ts +5 -5
  25. package/dist/hooks-2d-XjpuI.js +526 -0
  26. package/dist/hooks-2d-XjpuI.js.map +1 -0
  27. package/dist/i18n/context.d.ts +1 -1
  28. package/dist/i18n/messages.d.ts +1 -1
  29. package/dist/index.d.ts +7 -5
  30. package/dist/index.js +1985 -1667
  31. package/dist/index.js.map +1 -1
  32. package/dist/lib/money.d.ts +1 -0
  33. package/dist/lib/offer-label.d.ts +4 -0
  34. package/dist/locales/de.js +25 -4
  35. package/dist/locales/de.js.map +1 -1
  36. package/dist/locales/en.d.ts +25 -4
  37. package/dist/locales/en.js +25 -4
  38. package/dist/locales/en.js.map +1 -1
  39. package/dist/locales/es.js +25 -4
  40. package/dist/locales/es.js.map +1 -1
  41. package/dist/locales/ja.js +16 -4
  42. package/dist/locales/ja.js.map +1 -1
  43. package/dist/locales/ko.js +16 -4
  44. package/dist/locales/ko.js.map +1 -1
  45. package/dist/locales/zh.js +16 -4
  46. package/dist/locales/zh.js.map +1 -1
  47. package/dist/offers.d.ts +33 -0
  48. package/dist/order-checkout.d.ts +30 -0
  49. package/dist/react/context.d.ts +6 -5
  50. package/dist/react/hooks.d.ts +17 -16
  51. package/dist/react/index.d.ts +1 -1
  52. package/dist/react/provider.d.ts +24 -2
  53. package/dist/react.js +2 -33
  54. package/dist/save-payment-method.d.ts +0 -6
  55. package/dist/styles.css +1 -1
  56. package/dist/types.d.ts +16 -16
  57. package/docs/payment-form-contract.md +6 -6
  58. package/package.json +2 -2
  59. package/dist/client-CWX6QpLa.js.map +0 -1
  60. package/dist/config-DZ97SQG2.js +0 -341
  61. package/dist/config-DZ97SQG2.js.map +0 -1
  62. package/dist/provider.d.ts +0 -18
  63. package/dist/react.js.map +0 -1
@@ -1,68 +1,87 @@
1
1
  import { z as e } from "zod";
2
- //#region src/lib/money.ts
3
- var t = -(1n << 63n), n = (1n << 63n) - 1n;
2
+ //#region src/client/checkout.ts
3
+ var t = /* @__PURE__ */ new WeakMap();
4
+ function n(e, n) {
5
+ t.set(e, n);
6
+ }
4
7
  function r(e) {
8
+ let n = t.get(e);
9
+ if (!n) throw Error("billing-ui: the client must come from createBillingClient");
10
+ return n;
11
+ }
12
+ //#endregion
13
+ //#region src/lib/money.ts
14
+ var i = -(1n << 63n), a = (1n << 63n) - 1n;
15
+ function o(e) {
5
16
  if (typeof e != "string" || !/^-?\d{1,19}$/.test(e)) return null;
6
- let r = BigInt(e);
7
- return r < t || r > n ? null : r;
17
+ let t = BigInt(e);
18
+ return t < i || t > a ? null : t;
8
19
  }
9
- function i(e) {
10
- return r(e) !== null;
20
+ function s(e) {
21
+ return o(e) !== null;
11
22
  }
12
- function a(e) {
23
+ function c(e) {
13
24
  return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= 18;
14
25
  }
15
- function o(...e) {
16
- let i = 0n;
17
- for (let t of e) {
18
- let e = r(t);
26
+ function l(...e) {
27
+ let t = 0n;
28
+ for (let n of e) {
29
+ let e = o(n);
19
30
  if (e === null) return null;
20
- i += e;
31
+ t += e;
21
32
  }
22
- return i < t || i > n ? null : i.toString();
33
+ return t < i || t > a ? null : t.toString();
23
34
  }
24
- var s = (() => {
35
+ var u = (() => {
25
36
  try {
26
37
  return new Intl.NumberFormat("en", { useGrouping: !1 }).format("9007199254740993") === "9007199254740993";
27
38
  } catch {
28
39
  return !1;
29
40
  }
30
- })(), c = 10n ** 15n;
31
- function l(e, t) {
41
+ })(), d = 10n ** 15n;
42
+ function f(e, t) {
32
43
  let n = e < 0n ? -e : e, r = 10n ** BigInt(t), i = (n % r).toString().padStart(t, "0").replace(/0+$/, "");
33
44
  return `${e < 0n ? "-" : ""}${n / r}${i ? `.${i}` : ""}`;
34
45
  }
35
- function u(e, t) {
36
- let n = r(e);
37
- return n === null || !a(t) ? null : l(n, t);
46
+ function p(e, t) {
47
+ let n = o(e);
48
+ return n === null || !c(t) ? null : f(n, t);
38
49
  }
39
- function d(e, r) {
40
- if (!a(r) || e.length > 40) return null;
41
- let i = /^(-?)(\d+)(?:\.(\d+))?$/.exec(e);
42
- if (!i) return null;
43
- let o = i[3] ?? "";
44
- if (o.length > r) return null;
45
- let s = BigInt(i[2]) * 10n ** BigInt(r) + BigInt(o.padEnd(r, "0") || "0"), c = i[1] ? -s : s;
46
- return c < t || c > n ? null : c.toString();
50
+ function m(e, t, n) {
51
+ let r = o(e);
52
+ if (r === null || !c(t) || !c(n) || n > t) return null;
53
+ let i = 10n ** BigInt(t - n);
54
+ if (r % i !== 0n) return null;
55
+ let a = r / i;
56
+ return a > BigInt(2 ** 53 - 1) || a < -BigInt(2 ** 53 - 1) ? null : Number(a);
47
57
  }
48
- function f(e, t, n, i) {
49
- let o = t.trim().toUpperCase(), u = r(e);
50
- if (u === null || !a(n)) return `${o} amount exceeds the exact display range`;
51
- if (!s && (u >= c || u <= -c)) return `${o} amount exceeds this browser's exact display range`;
52
- let d = l(u, n);
58
+ function h(e, t) {
59
+ if (!c(t) || e.length > 40) return null;
60
+ let n = /^(-?)(\d+)(?:\.(\d+))?$/.exec(e);
61
+ if (!n) return null;
62
+ let r = n[3] ?? "";
63
+ if (r.length > t) return null;
64
+ let o = BigInt(n[2]) * 10n ** BigInt(t) + BigInt(r.padEnd(t, "0") || "0"), s = n[1] ? -o : o;
65
+ return s < i || s > a ? null : s.toString();
66
+ }
67
+ function g(e, t, n, r) {
68
+ let i = t.trim().toUpperCase(), a = o(e);
69
+ if (a === null || !c(n)) return `${i} amount exceeds the exact display range`;
70
+ if (!u && (a >= d || a <= -d)) return `${i} amount exceeds this browser's exact display range`;
71
+ let s = f(a, n);
53
72
  try {
54
- return new Intl.NumberFormat(i, {
73
+ return new Intl.NumberFormat(r, {
55
74
  style: "currency",
56
- currency: o,
75
+ currency: i,
57
76
  maximumFractionDigits: n
58
- }).format(d);
77
+ }).format(s);
59
78
  } catch {
60
- return `${d} ${o}`;
79
+ return `${s} ${i}`;
61
80
  }
62
81
  }
63
82
  //#endregion
64
83
  //#region src/types.ts
65
- var p = (e) => e.nullish().transform((e) => e ?? void 0).optional(), m = e.string().refine(i, "amount must be an int64 decimal string"), h = e.number().refine(a, "unit_decimals must be an integer from 0 to 18"), ee = e.string().url().refine((e) => {
84
+ var _ = (e) => e.nullish().transform((e) => e ?? void 0).optional(), v = e.string().refine(s, "amount must be an int64 decimal string"), y = e.number().refine(c, "unit_decimals must be an integer from 0 to 18"), ee = e.string().url().refine((e) => {
66
85
  try {
67
86
  let t = new URL(e);
68
87
  return t.protocol === "https:" && !t.username && !t.password;
@@ -76,7 +95,7 @@ var p = (e) => e.nullish().transform((e) => e ?? void 0).optional(), m = e.strin
76
95
  } catch {
77
96
  return !1;
78
97
  }
79
- }, "return URL must be HTTP(S)"), g = e.enum([
98
+ }, "return URL must be HTTP(S)"), b = e.enum([
80
99
  "created",
81
100
  "requires_action",
82
101
  "processing",
@@ -85,16 +104,16 @@ var p = (e) => e.nullish().transform((e) => e ?? void 0).optional(), m = e.strin
85
104
  "blocked",
86
105
  "expired",
87
106
  "canceled"
88
- ]), _ = e.object({
107
+ ]), x = e.object({
89
108
  reason: e.string(),
90
109
  message: e.string(),
91
110
  field: e.string().nullish()
92
- }), v = e.object({
111
+ }), S = e.object({
93
112
  id: e.string(),
94
113
  status: e.string()
95
- }), y = e.object({
114
+ }), C = e.object({
96
115
  id: e.string().min(1),
97
- psp_id: p(e.string()),
116
+ psp_id: _(e.string()),
98
117
  rail: e.string(),
99
118
  mode: e.enum(["one_off", "subscription"]),
100
119
  driver: e.enum([
@@ -104,15 +123,15 @@ var p = (e) => e.nullish().transform((e) => e ?? void 0).optional(), m = e.strin
104
123
  "redirect",
105
124
  "solana_pay"
106
125
  ]),
107
- psp_key: p(e.string()),
108
- public_config: p(e.record(e.string(), e.string()))
109
- }), b = e.discriminatedUnion("type", [e.object({
126
+ psp_key: _(e.string()),
127
+ public_config: _(e.record(e.string(), e.string()))
128
+ }), w = e.discriminatedUnion("type", [e.object({
110
129
  type: e.literal("redirect_to_url"),
111
130
  url: ee
112
131
  }), e.object({
113
132
  type: e.literal("solana_pay"),
114
133
  url: e.string().startsWith("solana:")
115
- })]), x = e.object({
134
+ })]), T = e.object({
116
135
  id: e.string(),
117
136
  option_id: e.string(),
118
137
  rail: e.string(),
@@ -122,37 +141,37 @@ var p = (e) => e.nullish().transform((e) => e ?? void 0).optional(), m = e.strin
122
141
  exp_month: e.number().nullish(),
123
142
  exp_year: e.number().nullish()
124
143
  }).nullish()
125
- }), S = e.object({
144
+ }), E = e.object({
126
145
  label: e.string(),
127
- sublabel: p(e.string()),
128
- amount: m
129
- }), C = e.object({
146
+ sublabel: _(e.string()),
147
+ amount: v
148
+ }), D = e.object({
130
149
  auto_renew: e.boolean(),
131
150
  display_name: e.string(),
132
- unit_amount: m,
151
+ unit_amount: v,
133
152
  currency: e.string().min(1),
134
- unit_decimals: h,
135
- billing_interval_hours: p(e.number()),
136
- access_duration_hours: p(e.number())
137
- }), w = e.object({
153
+ unit_decimals: y,
154
+ billing_interval_hours: _(e.number()),
155
+ access_duration_hours: _(e.number())
156
+ }), O = e.object({
138
157
  id: e.string(),
139
- status: g,
158
+ status: b,
140
159
  merchant: e.object({ display_name: e.string() }),
141
- plan: C,
142
- line_items: p(e.array(S)),
143
- tax: p(m),
144
- due_today: p(m),
145
- options: e.array(y),
146
- saved_methods: p(e.array(x)),
147
- next_action: b.nullish(),
148
- payment_id: p(e.string()),
149
- subscription_id: p(e.string()),
150
- failure_message: p(e.string()),
151
- failure: _.nullish(),
152
- operation: v.nullish(),
153
- success_url: p(te),
154
- embed_origin: p(e.string().url()),
155
- expires_at: p(e.string())
160
+ plan: D,
161
+ line_items: _(e.array(E)),
162
+ tax: _(v),
163
+ due_today: _(v),
164
+ options: e.array(C),
165
+ saved_methods: _(e.array(T)),
166
+ next_action: w.nullish(),
167
+ payment_id: _(e.string()),
168
+ subscription_id: _(e.string()),
169
+ failure_message: _(e.string()),
170
+ failure: x.nullish(),
171
+ operation: S.nullish(),
172
+ success_url: _(te),
173
+ embed_origin: _(e.string().url()),
174
+ expires_at: _(e.string())
156
175
  }), ne = e.object({
157
176
  option_id: e.string(),
158
177
  payment_token: e.string().optional(),
@@ -177,36 +196,37 @@ var p = (e) => e.nullish().transform((e) => e ?? void 0).optional(), m = e.strin
177
196
  }).optional()
178
197
  }).optional(),
179
198
  token_symbol: e.string().optional()
180
- }), T = e.object({
181
- status: g,
182
- next_action: b.nullish(),
183
- operation: v.nullish(),
184
- payment_id: p(e.string()),
185
- subscription_id: p(e.string()),
186
- failure_message: p(e.string()),
187
- failure: _.nullish()
188
- }), E = class extends Error {
199
+ }), k = e.object({
200
+ status: b,
201
+ next_action: w.nullish(),
202
+ operation: S.nullish(),
203
+ payment_id: _(e.string()),
204
+ subscription_id: _(e.string()),
205
+ failure_message: _(e.string()),
206
+ failure: x.nullish()
207
+ }), A = class extends Error {
189
208
  status;
190
209
  type;
191
210
  code;
192
211
  param;
193
212
  requestId;
194
213
  metadata;
214
+ order;
195
215
  constructor(e, t) {
196
- super(t.message), this.name = "BillingError", this.status = e, this.type = t.type, this.code = t.code, this.param = t.param, this.requestId = t.request_id, this.metadata = t.metadata ?? {};
216
+ super(t.message), this.name = "BillingError", this.status = e, this.type = t.type, this.code = t.code, this.param = t.param, this.requestId = t.request_id, this.metadata = t.metadata ?? {}, this.order = t.order;
197
217
  }
198
- }, D = (e) => e instanceof E, re = (e) => {
218
+ }, j = (e) => e instanceof A, re = (e) => {
199
219
  let t = e?.status;
200
220
  return typeof t == "number" && t >= 500 && t < 600;
201
221
  };
202
- function O(e, t) {
203
- return new E(0, {
222
+ function M(e, t) {
223
+ return new A(0, {
204
224
  type: "local",
205
225
  code: e,
206
226
  message: t
207
227
  });
208
228
  }
209
- async function k(e) {
229
+ async function N(e) {
210
230
  let t;
211
231
  try {
212
232
  t = await e.json();
@@ -216,27 +236,28 @@ async function k(e) {
216
236
  let n = t?.error;
217
237
  if (n && typeof n == "object") {
218
238
  let t = n;
219
- if (typeof t.code == "string" && t.code) return new E(e.status, {
239
+ if (typeof t.code == "string" && t.code) return new A(e.status, {
220
240
  type: typeof t.type == "string" ? t.type : "",
221
241
  code: t.code,
222
242
  message: typeof t.message == "string" ? t.message : t.code,
223
243
  request_id: typeof t.request_id == "string" ? t.request_id : e.headers.get("X-Request-ID") ?? void 0,
224
244
  param: typeof t.param == "string" ? t.param : void 0,
225
- metadata: t.metadata && typeof t.metadata == "object" ? t.metadata : void 0
245
+ metadata: t.metadata && typeof t.metadata == "object" ? t.metadata : void 0,
246
+ order: t.order
226
247
  });
227
248
  }
228
- return new E(e.status, {
249
+ return new A(e.status, {
229
250
  type: e.status >= 500 ? "api_error" : "",
230
251
  code: typeof n == "string" && n ? n : e.status >= 500 ? "server_error" : "unknown_error",
231
252
  message: `HTTP ${e.status}`
232
253
  });
233
254
  }
234
255
  function ie(e) {
235
- return e instanceof E ? e : e instanceof TypeError ? O("network_error", e.message) : O("unknown_error", e instanceof Error ? e.message : String(e));
256
+ return e instanceof A ? e : e instanceof TypeError ? M("network_error", e.message) : M("unknown_error", e instanceof Error ? e.message : String(e));
236
257
  }
237
258
  //#endregion
238
259
  //#region src/client/generated/currencies.ts
239
- var A = {
260
+ var ae = {
240
261
  AED: 6,
241
262
  AUD: 6,
242
263
  BRL: 6,
@@ -271,7 +292,7 @@ var A = {
271
292
  USDG: 6,
272
293
  USDT: 6,
273
294
  ZAR: 6
274
- }, j = e.object({
295
+ }, P = e.object({
275
296
  psp_id: e.string().min(1),
276
297
  key: e.string().min(1),
277
298
  rail: e.string(),
@@ -282,22 +303,22 @@ var A = {
282
303
  checkout: e.boolean().nullish(),
283
304
  status: e.string().nullish(),
284
305
  retry_after: e.number().int().nullish()
285
- }), ae = /* @__PURE__ */ new Set([
306
+ }), oe = /* @__PURE__ */ new Set([
286
307
  "collect_js",
287
308
  "card",
288
309
  "stripe_elements"
289
- ]), M = (e) => ae.has(e.driver), oe = (e) => e.filter((e) => e.checkout !== !1), se = /* @__PURE__ */ new Set([
310
+ ]), F = (e) => oe.has(e.driver), se = (e) => e.filter((e) => e.checkout !== !1), ce = /* @__PURE__ */ new Set([
290
311
  "tokenize",
291
312
  "card",
292
313
  "elements"
293
314
  ]);
294
- function ce(e) {
295
- let t = e.filter((e) => !!e.status && e.custodian === "psp" && se.has(e.flow)).map((e) => e.retry_after ?? 30);
315
+ function le(e) {
316
+ let t = e.filter((e) => !!e.status && e.custodian === "psp" && ce.has(e.flow)).map((e) => e.retry_after ?? 30);
296
317
  return t.length > 0 ? Math.min(...t) : null;
297
318
  }
298
- function le(e, t) {
319
+ function ue(e, t) {
299
320
  return [...e].sort((e, t) => (t.created_at ?? "").localeCompare(e.created_at ?? "")).flatMap((e) => {
300
- let n = t.find((t) => (t.psp_id ?? t.id) === e.psp_id && M(t));
321
+ let n = t.find((t) => (t.psp_id ?? t.id) === e.psp_id && F(t));
301
322
  return !n || e.health?.active === !1 ? [] : [{
302
323
  id: e.id,
303
324
  option_id: n.id,
@@ -306,12 +327,12 @@ function le(e, t) {
306
327
  }];
307
328
  });
308
329
  }
309
- var ue = (e) => !!e && !e.startsWith("preview_"), de = (e) => e.rail === "stripe" && !!e.config?.publishable_key?.startsWith("pk_");
310
- function N(e) {
311
- return e.custodian !== "psp" || e.status ? null : e.flow === "card" && e.rail === "nmi" ? "card" : e.flow === "tokenize" && ue(e.config?.tokenization_key) && e.config?.tokenization_url ? "collect_js" : de(e) ? "stripe_elements" : null;
330
+ var de = (e) => !!e && !e.startsWith("preview_"), fe = (e) => e.rail === "stripe" && !!e.config?.publishable_key?.startsWith("pk_");
331
+ function I(e) {
332
+ return e.custodian !== "psp" || e.status ? null : e.flow === "card" && e.rail === "nmi" ? "card" : e.flow === "tokenize" && de(e.config?.tokenization_key) && e.config?.tokenization_url ? "collect_js" : fe(e) ? "stripe_elements" : null;
312
333
  }
313
- var fe = (e) => N(e) !== null, pe = (e) => N(e) === "stripe_elements";
314
- function me(e) {
334
+ var pe = (e) => I(e) !== null, me = (e) => I(e) === "stripe_elements";
335
+ function he(e) {
315
336
  return {
316
337
  psp_id: e.psp_id ?? e.id,
317
338
  key: e.psp_key ?? e.rail,
@@ -324,40 +345,41 @@ function me(e) {
324
345
  }
325
346
  //#endregion
326
347
  //#region src/client/types.ts
327
- var P = e.string().refine(i, "amount must be an int64 string"), F = e.string(), he = (t) => e.object({
348
+ var L = e.string().refine(s, "amount must be an int64 string"), R = e.string(), ge = (t) => e.object({
328
349
  data: e.array(t).nullish().transform((e) => e ?? []),
329
350
  total: e.number().nullish(),
330
351
  limit: e.number().nullish(),
331
352
  offset: e.number().nullish(),
332
353
  has_more: e.boolean().nullish(),
333
354
  next_cursor: e.string().nullish()
334
- }), I = (t) => e.object({
355
+ }), z = (t) => e.object({
335
356
  data: e.array(t).nullish().transform((e) => e ?? []),
336
357
  next_cursor: e.string().nullish().transform((e) => e ?? null)
337
- }), L = e.string(), R = e.object({
358
+ }), _e = e.string(), ve = e.object({
338
359
  status: e.string(),
339
360
  ids: e.record(e.string(), e.string()).nullish(),
340
361
  sync_status: e.string().nullish()
341
- }), z = e.object({
362
+ }), B = e.object({
342
363
  id: e.string(),
343
364
  key: e.string(),
344
365
  revision: e.number().int().nonnegative().optional(),
366
+ version: e.number().int().nonnegative().optional(),
345
367
  product_id: e.string(),
346
368
  archived: e.boolean(),
347
- unit_amount: P,
369
+ unit_amount: L,
348
370
  customer_amount: e.object({
349
- min_amount: P,
350
- max_amount: P
371
+ min_amount: L,
372
+ max_amount: L
351
373
  }).nullish(),
352
374
  currency: e.string(),
353
375
  access_duration_hours: e.number().nullable(),
354
376
  billing_interval_hours: e.number().nullable(),
355
- trial_unit_amount: P.nullable(),
377
+ trial_unit_amount: L.nullable(),
356
378
  trial_duration_hours: e.number().nullable(),
357
- psps: e.record(e.string(), R).nullish(),
358
- created_at: F,
359
- updated_at: F
360
- }), B = e.object({
379
+ psps: e.record(e.string(), ve).nullish(),
380
+ created_at: R,
381
+ updated_at: R
382
+ }), V = e.object({
361
383
  id: e.string(),
362
384
  key: e.string().nullish(),
363
385
  revision: e.number().int().nonnegative().optional(),
@@ -365,69 +387,72 @@ var P = e.string().refine(i, "amount must be an int64 string"), F = e.string(),
365
387
  description: e.string().nullish(),
366
388
  tier_group: e.string().nullish(),
367
389
  tier_rank: e.number().nullish()
368
- }), V = e.object({
390
+ }), H = e.object({
369
391
  brand: e.string().nullish(),
370
392
  last4: e.string().nullish(),
371
393
  exp_month: e.number().nullish(),
372
394
  exp_year: e.number().nullish()
373
- }), ge = e.object({
395
+ }), ye = e.object({
374
396
  id: e.string(),
375
397
  status: e.string()
376
- }), H = e.object({
398
+ }), U = e.object({
377
399
  last_failure_reason: e.string().nullish(),
378
400
  retryable: e.boolean(),
379
401
  blocked_reason: e.string().nullish(),
380
- operation: ge.nullish()
381
- }), U = e.object({
402
+ operation: ye.nullish(),
403
+ order_id: e.string().nullish()
404
+ }), W = e.object({
382
405
  type: e.string(),
383
406
  redirect_to_url: e.object({ url: e.string().nullish() }).nullish(),
384
407
  transactions: e.array(e.string()).nullish()
385
- }), _e = e.object({
408
+ }), be = e.object({
386
409
  attempts: e.number(),
387
410
  retries_left: e.number().nullish(),
388
- next_retry_at: F.nullish(),
389
- final_retry_at: F.nullish(),
411
+ next_retry_at: R.nullish(),
412
+ final_retry_at: R.nullish(),
390
413
  waiting_for_new_card: e.boolean(),
391
414
  last_failure_reason: e.string().nullish()
392
- }), W = e.object({
415
+ }), G = e.object({
393
416
  id: e.string(),
394
- status: L,
417
+ status: _e,
395
418
  rail: e.string().nullish(),
396
419
  product_id: e.string().nullish(),
397
420
  price_id: e.string().nullish(),
421
+ quantity: e.number().nullish(),
398
422
  psp_id: e.string().nullish(),
423
+ collection_policy: e.string().nullish(),
399
424
  payment_method_id: e.string().nullish(),
400
- started_at: F.nullish(),
401
- ended_at: F.nullish(),
402
- current_period_starts_at: F.nullish(),
403
- current_period_ends_at: F.nullish(),
404
- canceled_at: F.nullish(),
425
+ started_at: R.nullish(),
426
+ ended_at: R.nullish(),
427
+ current_period_starts_at: R.nullish(),
428
+ current_period_ends_at: R.nullish(),
429
+ canceled_at: R.nullish(),
405
430
  cancel_type: e.string().nullish(),
406
431
  resumable: e.boolean().nullish(),
407
432
  cancel_scheduled: e.boolean().nullish(),
408
433
  cancel_mode: e.string().nullish(),
409
434
  cancel_portal_url: e.string().nullish(),
410
435
  access: e.object({
411
- starts_at: F,
412
- ends_at: F.nullish()
436
+ starts_at: R,
437
+ ends_at: R.nullish()
413
438
  }).nullish(),
414
- dunning: _e.nullish(),
415
- price: z.nullish(),
416
- product: B.nullish(),
439
+ dunning: be.nullish(),
440
+ price: B.nullish(),
441
+ product: V.nullish(),
417
442
  scheduled_change: e.object({
418
443
  price_id: e.string(),
419
444
  quantity: e.number().nullish(),
420
- effective_at: F,
445
+ effective_at: R,
421
446
  source: e.string(),
422
- price: z.nullish(),
423
- product: B.nullish()
447
+ price: B.nullish(),
448
+ product: V.nullish()
424
449
  }).nullish(),
425
- card: V.nullish(),
426
- recovery: H.nullish(),
427
- next_action: U.nullish(),
428
- created_at: F.nullish(),
429
- updated_at: F.nullish()
430
- }), ve = e.object({
450
+ card: H.nullish(),
451
+ recovery: U.nullish(),
452
+ next_action: W.nullish(),
453
+ created_at: R.nullish(),
454
+ updated_at: R.nullish()
455
+ }), xe = e.object({
431
456
  name: e.string().nullish(),
432
457
  email: e.string().nullish(),
433
458
  phone: e.string().nullish(),
@@ -439,15 +464,22 @@ var P = e.string().refine(i, "amount must be an int64 string"), F = e.string(),
439
464
  postal_code: e.string().nullish(),
440
465
  country: e.string().nullish()
441
466
  }).nullish()
442
- }), G = e.object({
467
+ }), K = e.object({
443
468
  id: e.string(),
469
+ status: e.string().nullish(),
470
+ next_action: e.object({
471
+ type: e.string(),
472
+ psp_id: e.string().nullish(),
473
+ payload: e.record(e.string(), e.string()).nullish()
474
+ }).nullish(),
444
475
  rail: e.string().nullish(),
445
476
  psp_id: e.string().nullish(),
446
- card: V.nullish(),
447
- billing_details: ve.nullish(),
477
+ card: H.nullish(),
478
+ billing_details: xe.nullish(),
479
+ reusable: e.boolean().nullish(),
448
480
  health: e.object({
449
481
  expiry_status: e.string().nullish(),
450
- last_charged_at: F.nullish(),
482
+ last_charged_at: R.nullish(),
451
483
  last_charge_outcome: e.string().nullish(),
452
484
  active: e.boolean().nullish()
453
485
  }).nullish(),
@@ -455,9 +487,93 @@ var P = e.string().refine(i, "amount must be an int64 string"), F = e.string(),
455
487
  id: e.string(),
456
488
  display_name: e.string().nullish()
457
489
  })).nullish(),
458
- collection_currencies: e.array(e.string()).nullish(),
459
- created_at: F.nullish()
460
- }), ye = e.object({
490
+ default_currencies: e.array(e.string()).nullish(),
491
+ created_at: R.nullish()
492
+ }), Se = e.object({
493
+ reason: e.string(),
494
+ message: e.string(),
495
+ field: e.string().nullish()
496
+ }), Ce = e.object({
497
+ type: e.string(),
498
+ url: e.string().nullish(),
499
+ psp_id: e.string().nullish(),
500
+ transactions: e.array(e.string()).nullish(),
501
+ payload: e.record(e.string(), e.string()).nullish()
502
+ }), we = e.object({
503
+ id: e.string(),
504
+ price_id: e.string(),
505
+ product_id: e.string(),
506
+ description: e.string(),
507
+ quantity: e.number().nullish(),
508
+ unit_amount: L,
509
+ amount: L,
510
+ billing_interval_hours: e.number().nullish(),
511
+ access_duration_hours: e.number().nullish(),
512
+ subscription_id: e.string().nullish(),
513
+ product_access_id: e.string().nullish()
514
+ }), q = e.object({
515
+ id: e.string(),
516
+ customer_id: e.string(),
517
+ origin: e.string(),
518
+ status: e.string(),
519
+ number: e.string().nullish(),
520
+ currency: e.string(),
521
+ total: L,
522
+ lines: e.array(we),
523
+ payment: e.object({
524
+ status: e.string(),
525
+ next_action: Ce.nullish(),
526
+ last_payment_error: Se.nullish(),
527
+ payment_method_id: e.string().nullish(),
528
+ payment_id: e.string().nullish()
529
+ }),
530
+ payment_options: e.array(e.object({
531
+ psp_id: e.string(),
532
+ rail: e.string(),
533
+ accepts: e.array(e.string())
534
+ })).nullish().transform((e) => e ?? []),
535
+ checkout: e.object({
536
+ url: e.string().nullish(),
537
+ success_url: e.string(),
538
+ cancel_url: e.string().nullish(),
539
+ saved_payment_methods: e.boolean()
540
+ }).nullish(),
541
+ renewal: e.object({
542
+ subscription_id: e.string(),
543
+ period_starts_at: R,
544
+ period_ends_at: R,
545
+ due_at: R
546
+ }).nullish(),
547
+ expires_at: R.nullish(),
548
+ completed_at: R.nullish(),
549
+ canceled_at: R.nullish(),
550
+ expired_at: R.nullish(),
551
+ voided_at: R.nullish(),
552
+ created_at: R
553
+ }), Te = e.object({
554
+ code: e.string(),
555
+ message: e.string(),
556
+ owned_by: e.string().nullish(),
557
+ hint: e.string().nullish()
558
+ }), Ee = e.object({
559
+ price_id: e.string(),
560
+ product_id: e.string(),
561
+ description: e.string(),
562
+ quantity: e.number().nullish(),
563
+ unit_amount: L,
564
+ amount: L,
565
+ ownership: e.string(),
566
+ billing_interval_hours: e.number().nullish(),
567
+ access_duration_hours: e.number().nullish(),
568
+ refusal: Te.nullish()
569
+ }), J = e.object({
570
+ currency: e.string(),
571
+ total: L,
572
+ lines: e.array(Ee),
573
+ payment_options: q.shape.payment_options,
574
+ last_changed_at: R.nullish(),
575
+ expires_at: R.nullish()
576
+ }), De = e.object({
461
577
  id: e.string(),
462
578
  key: e.string(),
463
579
  revision: e.number().int().nonnegative().optional(),
@@ -466,97 +582,97 @@ var P = e.string().refine(i, "amount must be an int64 string"), F = e.string(),
466
582
  entitlements: e.array(e.string()),
467
583
  credit_grant: e.object({
468
584
  currency: e.string(),
469
- amount: P.nullish(),
585
+ amount: L.nullish(),
470
586
  from_payment: e.boolean().optional(),
471
587
  expires_after_days: e.number().int().positive().nullish()
472
588
  }).nullish(),
473
589
  tier_group: e.string().nullable(),
474
590
  tier_rank: e.number(),
475
591
  archived: e.boolean(),
476
- prices: e.array(z).nullish().transform((e) => e ?? []),
477
- created_at: F,
478
- updated_at: F
479
- }), be = e.object({
592
+ prices: e.array(B).nullish().transform((e) => e ?? []),
593
+ created_at: R,
594
+ updated_at: R
595
+ }), Oe = e.object({
480
596
  id: e.string(),
481
597
  kind: e.string(),
482
598
  status: e.string(),
483
- amount: P,
484
- amount_refunded: P.nullish(),
599
+ amount: L,
600
+ amount_refunded: L.nullish(),
485
601
  currency: e.string(),
486
602
  subscription_id: e.string().nullish(),
487
603
  price_id: e.string().nullish(),
488
604
  channel: e.string().nullish(),
489
605
  rail: e.string().nullish(),
490
- created_at: F,
491
- price: z.nullish(),
492
- product: B.nullish(),
493
- card: V.nullish(),
606
+ created_at: R,
607
+ price: B.nullish(),
608
+ product: V.nullish(),
609
+ card: H.nullish(),
494
610
  failure: e.object({
495
611
  reason: e.string(),
496
612
  message: e.string(),
497
613
  field: e.string().nullish()
498
614
  }).nullish()
499
- }), xe = e.object({
615
+ }), ke = e.object({
500
616
  currency: e.string(),
501
617
  billing_mode: e.string(),
502
- balance_amount: P,
503
- held_amount: P,
504
- available_amount: P,
505
- owed_amount: P
506
- }), Se = e.object({
618
+ balance_amount: L,
619
+ held_amount: L,
620
+ available_amount: L,
621
+ owed_amount: L
622
+ }), Ae = e.object({
507
623
  id: e.string(),
508
- balances: e.array(xe),
509
- collection_payment_methods: e.array(e.object({
624
+ balances: e.array(ke),
625
+ default_payment_methods: e.array(e.object({
510
626
  currency: e.string(),
511
627
  payment_method_id: e.string()
512
628
  })),
513
629
  unread_notifications: e.number()
514
- }), K = e.object({
630
+ }), Y = e.object({
515
631
  id: e.string(),
516
632
  currency: e.string(),
517
633
  invoice_number: e.string().nullish(),
518
- period_starts_at: F,
519
- period_ends_at: F,
520
- total_amount: P,
521
- amount_paid: P,
522
- amount_due: P,
634
+ period_starts_at: R,
635
+ period_ends_at: R,
636
+ total_amount: L,
637
+ amount_paid: L,
638
+ amount_due: L,
523
639
  status: e.string(),
524
- issued_at: F.nullish(),
525
- due_at: F.nullish(),
640
+ issued_at: R.nullish(),
641
+ due_at: R.nullish(),
526
642
  delinquent: e.boolean().nullish(),
527
- paid_at: F.nullish(),
528
- recovery: H.nullish(),
529
- created_at: F
530
- }), Ce = e.object({
643
+ paid_at: R.nullish(),
644
+ recovery: U.nullish(),
645
+ created_at: R
646
+ }), je = e.object({
531
647
  code: e.string(),
532
648
  decimals: e.number(),
533
649
  minor_decimals: e.number().nullish()
534
- }), we = e.object({
535
- action: e.string(),
650
+ }), Me = e.object({
536
651
  price_id: e.string(),
652
+ quantity: e.number().nullish(),
537
653
  rail: e.string().nullish(),
538
654
  currency: e.string(),
539
- amount_due_now: P,
540
- next_charge_amount: P,
541
- next_charge_date: F.nullish(),
655
+ amount_due_now: L,
656
+ next_charge_amount: L,
657
+ next_charge_date: R.nullish(),
542
658
  effective: e.string(),
543
659
  is_estimate: e.boolean().nullish(),
544
660
  message: e.string().nullish()
545
- }), Te = e.object({
661
+ }), Ne = e.object({
546
662
  status: e.string(),
547
- action: e.string().nullish(),
548
663
  effective: e.string().nullish(),
549
664
  price_id: e.string().nullish(),
665
+ quantity: e.number().nullish(),
550
666
  subscription_id: e.string().nullish(),
551
- next_action: U.nullish(),
552
- delayed_start: F.nullish(),
667
+ next_action: W.nullish(),
668
+ delayed_start: R.nullish(),
553
669
  currency: e.string().nullish(),
554
- amount_due_now: P.nullish(),
555
- next_charge_amount: P.nullish(),
556
- next_charge_date: F.nullish(),
670
+ amount_due_now: L.nullish(),
671
+ next_charge_amount: L.nullish(),
672
+ next_charge_date: R.nullish(),
557
673
  message: e.string().nullish(),
558
674
  operation_id: e.string().nullish()
559
- }), q = e.string().regex(/^\d+$/, "units must be a uint64 string"), Ee = e.object({
675
+ }), X = e.string().regex(/^\d+$/, "units must be a uint64 string"), Pe = e.object({
560
676
  symbol: e.string(),
561
677
  name: e.string().nullish(),
562
678
  mint: e.string(),
@@ -566,20 +682,20 @@ var P = e.string().refine(i, "amount must be an int64 string"), F = e.string(),
566
682
  recurring_eligible: e.boolean().nullish(),
567
683
  quote: e.object({
568
684
  amount: e.string(),
569
- units: q,
685
+ units: X,
570
686
  token_price_usd: e.string().nullish(),
571
687
  fx_rate: e.string().nullish(),
572
688
  fx_currency: e.string().nullish(),
573
- quoted_at: F.nullish(),
574
- expires_at: F.nullish()
689
+ quoted_at: R.nullish(),
690
+ expires_at: R.nullish()
575
691
  }).nullish(),
576
692
  balance: e.object({
577
693
  amount: e.string(),
578
- units: q,
694
+ units: X,
579
695
  sufficient: e.boolean().nullish()
580
696
  }).nullish()
581
- }), De = e.object({ tokens: e.array(Ee).nullish().transform((e) => e ?? []) }), Oe = e.object({
582
- psps: e.array(j).nullish().transform((e) => e ?? []),
697
+ }), Fe = e.object({ tokens: e.array(Pe).nullish().transform((e) => e ?? []) }), Ie = e.object({
698
+ psps: e.array(P).nullish().transform((e) => e ?? []),
583
699
  solana: e.object({
584
700
  network: e.string(),
585
701
  chain: e.string(),
@@ -593,58 +709,65 @@ var P = e.string().refine(i, "amount must be an int64 string"), F = e.string(),
593
709
  recurring_eligible: e.boolean().nullish()
594
710
  })).nullish().transform((e) => e ?? [])
595
711
  }).nullish()
596
- }), ke = e.object({
712
+ }), Le = e.object({
713
+ provider: e.string(),
714
+ site_key: e.string(),
715
+ script_url: e.string(),
716
+ action: e.string(),
717
+ token_header: e.string()
718
+ }), Re = e.object({
719
+ display_name: e.string(),
720
+ logo_url: e.string().nullish(),
721
+ support_url: e.string().nullish()
722
+ }), ze = e.object({
597
723
  capabilities: e.object({
598
724
  route_groups: e.record(e.string(), e.boolean()),
599
725
  features: e.record(e.string(), e.boolean())
600
726
  }),
601
- currencies: e.array(Ce).nullish().transform((e) => e ?? []),
602
- payment: Oe.nullish()
603
- }), J = e.object({
604
- id: e.string(),
605
- status: e.string(),
606
- client_secret: e.string().nullish(),
607
- payment_method_id: e.string().nullish()
608
- }), Ae = e.object({ client_secret: e.string().nullish() }), je = e.object({
727
+ currencies: e.array(je).nullish().transform((e) => e ?? []),
728
+ payment: Ie.nullish(),
729
+ merchant: Re.nullish(),
730
+ captcha: Le.nullish()
731
+ }), Be = e.object({ client_secret: e.string().nullish() }), Ve = e.object({
609
732
  id: e.string().startsWith("ocs_"),
610
733
  url: e.string().url().nullish(),
611
- expires_at: F
612
- }), Y = class extends Error {
734
+ expires_at: R
735
+ }), Z = class extends Error {
613
736
  constructor(e = "The wallet request was declined.") {
614
737
  super(e), this.name = "WalletRejectedError";
615
738
  }
616
- }, Me = 4, Ne = 500, X = (e) => e?.type === "solana_sign_transactions" && !!e.transactions?.length;
617
- async function Pe(e, t) {
739
+ }, He = 4, Ue = 500, We = (e) => e?.type === "solana_sign_transactions" && !!e.transactions?.length;
740
+ async function Ge(e, t) {
618
741
  let n = "";
619
742
  for (let r of e.transactions ?? []) {
620
743
  try {
621
744
  n = await t(r);
622
745
  } catch (e) {
623
- throw $(e) ? O("wallet_rejected", "The wallet request was declined.") : e;
746
+ throw Ze(e) ? M("wallet_rejected", "The wallet request was declined.") : e;
624
747
  }
625
- if (!n) throw O("wallet_no_signature", "The wallet returned no signature.");
748
+ if (!n) throw M("wallet_no_signature", "The wallet returned no signature.");
626
749
  }
627
- if (!n) throw O("wallet_no_signature", "The wallet returned no signature.");
750
+ if (!n) throw M("wallet_no_signature", "The wallet returned no signature.");
628
751
  return n;
629
752
  }
630
- var Fe = 2e3, Z = 300;
631
- function Ie(e) {
632
- let t = Le(e.headers.get("Retry-After"));
753
+ var Ke = 2e3, Q = 300;
754
+ function qe(e) {
755
+ let t = Je(e.headers.get("Retry-After"));
633
756
  switch (e.status) {
634
757
  case 429: return t;
635
- case 503: return t ?? Z;
758
+ case 503: return t ?? Q;
636
759
  case 502:
637
- case 504: return Z;
760
+ case 504: return Q;
638
761
  default: return null;
639
762
  }
640
763
  }
641
- function Le(e) {
764
+ function Je(e) {
642
765
  if (!e) return null;
643
766
  if (/^\d+$/.test(e.trim())) return Number(e.trim()) * 1e3;
644
767
  let t = Date.parse(e);
645
768
  return Number.isNaN(t) ? null : Math.max(0, t - Date.now());
646
769
  }
647
- function Q(e, t) {
770
+ function $(e, t) {
648
771
  return new Promise((n, r) => {
649
772
  if (t?.aborted) return r(t.reason);
650
773
  let i = setTimeout(() => {
@@ -655,80 +778,95 @@ function Q(e, t) {
655
778
  t?.addEventListener("abort", a, { once: !0 });
656
779
  });
657
780
  }
658
- function Re(e = {}) {
659
- let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), n = e.fetch ?? ((e, t) => fetch(e, t)), r = ze({
660
- ...A,
781
+ function Ye(e = {}) {
782
+ let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), r = e.fetch ?? ((e, t) => fetch(e, t)), i = Xe({
783
+ ...ae,
661
784
  ...e.currencies
662
785
  });
663
- function i(e, n, r = t) {
786
+ function a(e, n, r = t) {
664
787
  let i = new URLSearchParams();
665
- for (let [e, t] of Object.entries(n ?? {})) t !== void 0 && t !== "" && i.set(e, String(t));
788
+ for (let [e, t] of Object.entries(n ?? {})) if (Array.isArray(t)) for (let n of t) i.append(e, n);
789
+ else t !== void 0 && t !== "" && i.set(e, String(t));
666
790
  let a = i.toString();
667
791
  return `${r}${e}${a ? `?${a}` : ""}`;
668
792
  }
669
- async function a(t, r = {}) {
670
- let a = new Headers({
793
+ async function o(t, n = {}) {
794
+ let i = new Headers({
671
795
  Accept: "application/json",
672
- ...r.headers
796
+ ...n.headers
673
797
  });
674
- r.body !== void 0 && a.set("Content-Type", "application/json");
675
- let o = r.anonymous ? void 0 : await e.getToken?.();
676
- o && a.set("Authorization", `Bearer ${o}`);
798
+ n.body !== void 0 && i.set("Content-Type", "application/json");
799
+ let o = n.anonymous ? void 0 : await e.getToken?.();
800
+ o && i.set("Authorization", `Bearer ${o}`);
677
801
  let s = e.language?.();
678
- s && a.set("Accept-Language", s);
679
- let c = r.method ?? "GET", l = {
802
+ s && i.set("Accept-Language", s);
803
+ let c = n.method ?? "GET", l = {
680
804
  method: c,
681
- headers: a,
682
- body: r.body === void 0 ? void 0 : JSON.stringify(r.body),
683
- signal: r.signal
805
+ headers: i,
806
+ body: n.body === void 0 ? void 0 : JSON.stringify(n.body),
807
+ signal: n.signal
684
808
  }, u = +(c === "GET"), d = 0;
685
809
  for (let e = 0;; e++) {
686
- let a;
810
+ let i;
687
811
  try {
688
- a = await n(i(t, r.query, r.root), l);
812
+ i = await r(a(t, n.query, n.root), l);
689
813
  } catch (t) {
690
- let n = Z;
691
- if (e >= u || r.signal?.aborted || !(t instanceof TypeError) || d + n > 2e3) throw t;
692
- d += await Q(n, r.signal);
814
+ let r = Q;
815
+ if (e >= u || n.signal?.aborted || !(t instanceof TypeError) || d + r > 2e3) throw t;
816
+ d += await $(r, n.signal);
693
817
  continue;
694
818
  }
695
- if (a.ok) return a;
696
- let o = Ie(a);
697
- if (e >= u || o === null || d + o > 2e3) throw await k(a);
698
- await a.body?.cancel().catch(() => void 0), d += await Q(o, r.signal);
819
+ if (i.ok) return i;
820
+ let o = qe(i);
821
+ if (e >= u || o === null || d + o > 2e3) throw await N(i);
822
+ await i.body?.cancel().catch(() => void 0), d += await $(o, n.signal);
699
823
  }
700
824
  }
701
- async function o(e, t, n) {
702
- let r = await a(t, n), i;
825
+ async function s(e, t, n) {
826
+ let r = await o(t, n), i;
703
827
  try {
704
828
  i = await r.json();
705
829
  } catch {
706
- throw O("invalid_response", `${t}: body is not JSON`);
830
+ throw M("invalid_response", `${t}: body is not JSON`);
707
831
  }
708
- let o = e.safeParse(i);
709
- if (!o.success) throw O("invalid_response", `${t}: ${o.error.issues[0]?.path.join(".")} ${o.error.issues[0]?.message}`);
710
- return o.data;
832
+ let a = e.safeParse(i);
833
+ if (!a.success) throw M("invalid_response", `${t}: ${a.error.issues[0]?.path.join(".")} ${a.error.issues[0]?.message}`);
834
+ return a.data;
711
835
  }
712
- let s = (e) => encodeURIComponent(e), c = I(W), l = I(G), u = I(be), d = I(K), f = (e, t) => ({
836
+ let c = (e) => encodeURIComponent(e), l = z(G), u = z(K), d = z(Oe), f = z(Y), p = (e, t) => ({
713
837
  limit: e.limit ?? t,
714
838
  cursor: e.cursor ?? void 0
715
- }), p = he(ye);
716
- return {
839
+ }), m = ge(De);
840
+ async function h(e, t) {
841
+ try {
842
+ return { order: await s(q, e, t) };
843
+ } catch (e) {
844
+ if (j(e) && e.status === 402 && e.order) {
845
+ let t = q.safeParse(e.order);
846
+ if (t.success) return {
847
+ order: t.data,
848
+ error: e
849
+ };
850
+ }
851
+ throw e;
852
+ }
853
+ }
854
+ let g = {
717
855
  baseUrl: t,
718
856
  listSubscriptions(e = {}) {
719
- return o(c, "/me/subscriptions", {
857
+ return s(l, "/me/subscriptions", {
720
858
  query: {
721
859
  status: e.status ?? "all",
722
- ...f(e, 100)
860
+ ...p(e, 100)
723
861
  },
724
862
  signal: e.signal
725
863
  });
726
864
  },
727
865
  getSubscription(e, t) {
728
- return o(W, `/me/subscriptions/${s(e)}`, { signal: t });
866
+ return s(G, `/me/subscriptions/${c(e)}`, { signal: t });
729
867
  },
730
868
  cancelSubscription(e, t) {
731
- return o(W, `/me/subscriptions/${s(e)}/cancel`, {
869
+ return s(G, `/me/subscriptions/${c(e)}/cancel`, {
732
870
  method: "POST",
733
871
  body: {
734
872
  reason: t.reason.trim(),
@@ -737,118 +875,169 @@ function Re(e = {}) {
737
875
  });
738
876
  },
739
877
  resumeSubscription(e) {
740
- return o(W, `/me/subscriptions/${s(e)}/resume`, {
878
+ return s(G, `/me/subscriptions/${c(e)}/resume`, {
741
879
  method: "POST",
742
880
  body: {}
743
881
  });
744
882
  },
745
883
  setSubscriptionPaymentMethod(e, t) {
746
- return o(W, `/me/subscriptions/${s(e)}/payment-method`, {
884
+ return s(G, `/me/subscriptions/${c(e)}/payment-method`, {
747
885
  method: "PUT",
748
886
  body: { payment_method_id: t }
749
887
  });
750
888
  },
751
- previewTierChange(e, t, n) {
752
- return o(we, `/me/subscriptions/${s(e)}/change-tier/preview`, {
889
+ previewSubscriptionChange(e, t, n) {
890
+ return s(Me, `/me/subscriptions/${c(e)}/change/preview`, {
753
891
  method: "POST",
754
- body: { price_id: t },
892
+ body: {
893
+ price_id: t.priceId,
894
+ quantity: t.quantity
895
+ },
755
896
  signal: n
756
897
  });
757
898
  },
758
- changeTier(e, t) {
759
- return o(Te, `/me/subscriptions/${s(e)}/change-tier`, {
899
+ changeSubscription(e, t) {
900
+ return s(Ne, `/me/subscriptions/${c(e)}/change`, {
760
901
  method: "POST",
761
902
  body: {
762
903
  price_id: t.priceId,
904
+ quantity: t.quantity,
763
905
  signature: t.signature
764
906
  },
765
907
  headers: { "Idempotency-Key": t.idempotencyKey }
766
908
  });
767
909
  },
768
910
  listPaymentMethods(e = {}) {
769
- return o(l, "/me/payment-methods", {
770
- query: f(e, 100),
911
+ return s(u, "/me/payment-methods", {
912
+ query: p(e, 100),
771
913
  signal: e.signal
772
914
  });
773
915
  },
774
916
  addPaymentMethod(e) {
775
- return o(G, "/me/payment-methods", {
917
+ return s(K, "/me/payment-methods", {
776
918
  method: "POST",
777
919
  body: e
778
920
  });
779
921
  },
780
- createCardSetup(e) {
781
- return o(J, "/me/payment-method-setups", {
922
+ getCart(e) {
923
+ return s(J, "/me/cart", { signal: e });
924
+ },
925
+ setCartLine(e, t = {}) {
926
+ return s(J, `/me/cart/lines/${c(e)}`, {
927
+ method: "PUT",
928
+ body: t
929
+ });
930
+ },
931
+ async clearCart() {
932
+ await o("/me/cart", { method: "DELETE" });
933
+ },
934
+ createOrder(e) {
935
+ return h("/me/orders", {
782
936
  method: "POST",
783
937
  body: {
784
- psp_id: e.pspId,
785
- consent: !0
938
+ ...e.cart ? { cart: !0 } : { lines: e.lines ?? [] },
939
+ ...e.expectedTotal === void 0 ? {} : { expected_total: e.expectedTotal },
940
+ ...e.payment === void 0 ? {} : { payment: e.payment },
941
+ ...e.reusable === void 0 ? {} : { reusable: e.reusable }
786
942
  },
787
943
  headers: { "Idempotency-Key": e.idempotencyKey }
788
944
  });
789
945
  },
790
- getCardSetup(e, t) {
791
- return o(J, `/me/payment-method-setups/${s(e)}`, { signal: t });
946
+ getOrder(e, t) {
947
+ return s(q, `/me/orders/${c(e)}`, { signal: t });
948
+ },
949
+ payOrder(e, t) {
950
+ return h(`/me/orders/${c(e)}/pay`, {
951
+ method: "POST",
952
+ body: {
953
+ payment: t.payment,
954
+ expected_total: t.expectedTotal,
955
+ ...t.reusable === void 0 ? {} : { reusable: t.reusable }
956
+ },
957
+ headers: { "Idempotency-Key": t.idempotencyKey }
958
+ });
959
+ },
960
+ confirmOrder(e) {
961
+ return h(`/me/orders/${c(e)}/confirm`, {
962
+ method: "POST",
963
+ body: {}
964
+ });
792
965
  },
793
- confirmCardSetup(e) {
794
- return o(J, `/me/payment-method-setups/${s(e)}/confirm`, {
966
+ confirmPaymentMethod(e) {
967
+ return s(K, `/me/payment-methods/${c(e)}/confirm`, {
795
968
  method: "POST",
796
969
  body: {}
797
970
  });
798
971
  },
799
972
  getPaymentAuthentication(e) {
800
- return o(Ae, `/me/payment-operations/${s(e)}/authentication`);
973
+ return s(Be, `/me/payment-operations/${c(e)}/authentication`);
801
974
  },
802
975
  async confirmPaymentAuthentication(e) {
803
- await a(`/me/payment-operations/${s(e)}/authentication/confirm`, {
976
+ await o(`/me/payment-operations/${c(e)}/authentication/confirm`, {
804
977
  method: "POST",
805
978
  body: {}
806
979
  });
807
980
  },
808
981
  async removePaymentMethod(e) {
809
- return (await a(`/me/payment-methods/${s(e)}`, { method: "DELETE" })).status === 202 ? "pending" : "removed";
982
+ return (await o(`/me/payment-methods/${c(e)}`, { method: "DELETE" })).status === 202 ? "pending" : "removed";
810
983
  },
811
- async setCollectionPaymentMethod(e) {
812
- await a("/me/collection-payment-method", {
984
+ async setDefaultPaymentMethod(e) {
985
+ await o(`/me/default-payment-methods/${c(e.currency.toUpperCase())}`, {
813
986
  method: "PUT",
814
- body: {
815
- currency: e.currency.toUpperCase(),
816
- payment_method_id: e.paymentMethodId
817
- }
987
+ body: { payment_method_id: e.paymentMethodId }
818
988
  });
819
989
  },
820
990
  listPayments(e = {}) {
821
- return o(u, "/me/payments", {
991
+ return s(d, "/me/payments", {
822
992
  query: {
823
- ...f(e, 20),
993
+ ...p(e, 20),
824
994
  rail: e.rail
825
995
  },
826
996
  signal: e.signal
827
997
  });
828
998
  },
829
999
  listInvoices(e = {}) {
830
- return o(d, "/me/invoices", {
831
- query: f(e, 20),
1000
+ return s(f, "/me/invoices", {
1001
+ query: p(e, 20),
832
1002
  signal: e.signal
833
1003
  });
834
1004
  },
835
1005
  getAccount(e) {
836
- return o(Se, "/me", { signal: e });
1006
+ return s(Ae, "/me", { signal: e });
837
1007
  },
838
1008
  getInvoice(e, t) {
839
- return o(K, `/me/invoices/${s(e)}`, { signal: t });
1009
+ return s(Y, `/me/invoices/${c(e)}`, { signal: t });
1010
+ },
1011
+ async listProducts(e) {
1012
+ return e.keys.length === 0 ? {
1013
+ data: [],
1014
+ next_cursor: null
1015
+ } : s(m, "/catalog/products", {
1016
+ query: { keys: e.keys },
1017
+ signal: e.signal
1018
+ });
1019
+ },
1020
+ getConfig(e) {
1021
+ return s(ze, "/config", {
1022
+ signal: e,
1023
+ anonymous: !0
1024
+ });
840
1025
  },
841
- listProducts(e = {}) {
842
- return o(p, "/catalog/products", {
1026
+ async listSolanaTokens(e = {}) {
1027
+ let { tokens: t } = await s(Fe, "/solana/tokens", {
843
1028
  query: {
844
- limit: e.limit ?? 100,
845
- cursor: e.cursor
1029
+ price_id: e.priceId,
1030
+ wallet: e.wallet
846
1031
  },
847
1032
  signal: e.signal
848
1033
  });
1034
+ return t;
849
1035
  },
1036
+ currencies: i
1037
+ };
1038
+ return n(g, {
850
1039
  createCheckoutSession(e) {
851
- return !e.priceKey == !e.priceId || !!e.priceKey != !!e.productKey ? Promise.reject(O("invalid_request", "Pass priceId, or both productKey and priceKey.")) : o(je, "/me/checkout-sessions", {
1040
+ return !e.priceKey == !e.priceId || !!e.priceKey != !!e.productKey ? Promise.reject(M("invalid_request", "Pass priceId, or both productKey and priceKey.")) : s(Ve, "/me/checkout-sessions", {
852
1041
  method: "POST",
853
1042
  body: {
854
1043
  price_key: e.priceKey,
@@ -861,18 +1050,18 @@ function Re(e = {}) {
861
1050
  });
862
1051
  },
863
1052
  checkoutSource(e, t = {}) {
864
- let n = `/checkout-sessions/${s(e)}`, r = t.customerBase?.replace(/\/+$/, ""), i = r === void 0 ? { anonymous: !0 } : { root: r };
1053
+ let n = `/checkout-sessions/${c(e)}`, r = t.customerBase?.replace(/\/+$/, ""), i = r === void 0 ? { anonymous: !0 } : { root: r };
865
1054
  return {
866
- getSession: () => o(w, n, i),
1055
+ getSession: () => s(O, n, i),
867
1056
  async pay(e) {
868
1057
  try {
869
- return await o(T, `${n}/pay`, {
1058
+ return await s(k, `${n}/pay`, {
870
1059
  ...i,
871
1060
  method: "POST",
872
1061
  body: e
873
1062
  });
874
1063
  } catch (e) {
875
- if (!D(e)) throw e;
1064
+ if (!j(e)) throw e;
876
1065
  switch (e.status) {
877
1066
  case 404:
878
1067
  case 410: return { status: "expired" };
@@ -890,31 +1079,14 @@ function Re(e = {}) {
890
1079
  }
891
1080
  }
892
1081
  };
893
- },
894
- getConfig(e) {
895
- return o(ke, "/config", {
896
- signal: e,
897
- anonymous: !0
898
- });
899
- },
900
- async listSolanaTokens(e = {}) {
901
- let { tokens: t } = await o(De, "/solana/tokens", {
902
- query: {
903
- price_id: e.priceId,
904
- wallet: e.wallet
905
- },
906
- signal: e.signal
907
- });
908
- return t;
909
- },
910
- currencies: r
911
- };
1082
+ }
1083
+ }), g;
912
1084
  }
913
- function ze(e) {
1085
+ function Xe(e) {
914
1086
  return Object.fromEntries(Object.entries(e).map(([e, t]) => [e.toUpperCase(), t]));
915
1087
  }
916
- var $ = (e) => e instanceof Y || e instanceof Error && e.name === "WalletRejectedError" || e instanceof E && e.code === "wallet_rejected";
1088
+ var Ze = (e) => e instanceof Z || e instanceof Error && e.name === "WalletRejectedError" || e instanceof A && e.code === "wallet_rejected";
917
1089
  //#endregion
918
- export { ne as A, i as B, ie as C, w as D, C as E, h as F, o as I, u as L, _ as M, y as N, g as O, x as P, d as R, k as S, S as T, le as _, Re as a, re as b, Pe as c, ce as d, N as f, me as g, j as h, Y as i, T as j, b as k, pe as l, M as m, Me as n, X as o, oe as p, Fe as r, $ as s, Ne as t, fe as u, E as v, m as w, O as x, D as y, f as z };
1090
+ export { ne as A, g as B, ie as C, O as D, D as E, y as F, r as H, l as I, p as L, x as M, C as N, b as O, T as P, m as R, N as S, E as T, s as V, ue as _, Ye as a, re as b, Ge as c, le as d, I as f, he as g, P as h, Z as i, k as j, w as k, me as l, F as m, He as n, We as o, se as p, Ke as r, Ze as s, Ue as t, pe as u, A as v, v as w, M as x, j as y, h as z };
919
1091
 
920
- //# sourceMappingURL=client-CWX6QpLa.js.map
1092
+ //# sourceMappingURL=client-BuvolBPT.js.map