@openrails/billing-ui 0.237.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 +35 -9
- package/README.md +44 -19
- package/dist/account/payment-methods-panel.d.ts +1 -1
- package/dist/authenticate.d.ts +5 -4
- package/dist/buy-button.d.ts +4 -2
- package/dist/client/client.d.ts +30 -13
- package/dist/client/generated/routes.d.ts +34 -30
- package/dist/client/generated/wire.d.ts +5 -15
- package/dist/client/index.d.ts +2 -1
- package/dist/client/token-source.d.ts +60 -0
- package/dist/client/types.d.ts +43 -65
- package/dist/{client-D9G1Tgox.js → client-Bi_lP_M0.js} +251 -207
- package/dist/client-Bi_lP_M0.js.map +1 -0
- package/dist/client.js +2 -2
- package/dist/{hooks-DYepYVMX.js → hooks-Bk80rNv8.js} +99 -90
- package/dist/hooks-Bk80rNv8.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +989 -984
- package/dist/index.js.map +1 -1
- package/dist/offers.d.ts +6 -4
- 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/docs/payment-form-contract.md +1 -1
- package/package.json +1 -1
- package/dist/client-D9G1Tgox.js.map +0 -1
- package/dist/hooks-DYepYVMX.js.map +0 -1
|
@@ -88,7 +88,49 @@ var s = {
|
|
|
88
88
|
USDG: 6,
|
|
89
89
|
USDT: 6,
|
|
90
90
|
ZAR: 6
|
|
91
|
-
}
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/client/token-source.ts
|
|
94
|
+
function c({ fetchToken: e, skew: t = 60 }) {
|
|
95
|
+
let n, r, a = () => n && Date.now() < n.staleAt ? Promise.resolve(n.token) : (r ??= e().then((e) => {
|
|
96
|
+
if (typeof e?.access_token != "string" || !e.access_token || !Number.isFinite(e.expires_in)) throw i("invalid_response", "fetchToken answered no access_token and expires_in");
|
|
97
|
+
return n = {
|
|
98
|
+
token: e.access_token,
|
|
99
|
+
staleAt: Date.now() + (e.expires_in - t) * 1e3
|
|
100
|
+
}, e.access_token;
|
|
101
|
+
}).finally(() => {
|
|
102
|
+
r = void 0;
|
|
103
|
+
}), r);
|
|
104
|
+
return a.invalidate = (e) => {
|
|
105
|
+
(e === void 0 || n?.token === e) && (n = void 0);
|
|
106
|
+
}, a;
|
|
107
|
+
}
|
|
108
|
+
var ee = (e) => typeof e == "function" && typeof e.invalidate == "function";
|
|
109
|
+
async function l(e) {
|
|
110
|
+
let t = await (e.fetch ?? ((e, t) => fetch(e, t)))(e.tokenEndpoint, {
|
|
111
|
+
method: "POST",
|
|
112
|
+
headers: {
|
|
113
|
+
Accept: "application/json",
|
|
114
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
115
|
+
},
|
|
116
|
+
body: new URLSearchParams({
|
|
117
|
+
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
118
|
+
assertion: e.assertion,
|
|
119
|
+
scope: "openrails:self"
|
|
120
|
+
}).toString()
|
|
121
|
+
});
|
|
122
|
+
if (!t.ok) throw await a(t);
|
|
123
|
+
let n = await t.json().catch(() => null);
|
|
124
|
+
if (typeof n?.access_token != "string" || typeof n.expires_in != "number") throw i("invalid_response", "the token endpoint answered no access_token and expires_in");
|
|
125
|
+
return {
|
|
126
|
+
access_token: n.access_token,
|
|
127
|
+
expires_in: n.expires_in,
|
|
128
|
+
token_type: typeof n.token_type == "string" ? n.token_type : "Bearer"
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/psp.ts
|
|
133
|
+
var u = e.object({
|
|
92
134
|
psp_id: e.string().min(1),
|
|
93
135
|
key: e.string().min(1),
|
|
94
136
|
rail: e.string(),
|
|
@@ -99,77 +141,77 @@ var s = {
|
|
|
99
141
|
checkout: e.boolean().nullish(),
|
|
100
142
|
status: e.string().nullish(),
|
|
101
143
|
retry_after: e.number().int().nullish()
|
|
102
|
-
}),
|
|
144
|
+
}), d = (e) => e.filter((e) => e.checkout !== !1), f = /* @__PURE__ */ new Set([
|
|
103
145
|
"tokenize",
|
|
104
146
|
"card",
|
|
105
147
|
"elements"
|
|
106
148
|
]);
|
|
107
|
-
function
|
|
108
|
-
let t = e.filter((e) => !!e.status && e.custodian === "psp" &&
|
|
149
|
+
function p(e) {
|
|
150
|
+
let t = e.filter((e) => !!e.status && e.custodian === "psp" && f.has(e.flow)).map((e) => e.retry_after ?? 30);
|
|
109
151
|
return t.length > 0 ? Math.min(...t) : null;
|
|
110
152
|
}
|
|
111
|
-
var
|
|
112
|
-
function
|
|
113
|
-
return e.custodian !== "psp" || e.status ? null : e.flow === "card" && e.rail === "nmi" ? "card" : e.flow === "tokenize" &&
|
|
153
|
+
var m = (e) => !!e && !e.startsWith("preview_"), h = (e) => e.rail === "stripe" && !!e.config?.publishable_key?.startsWith("pk_");
|
|
154
|
+
function g(e) {
|
|
155
|
+
return e.custodian !== "psp" || e.status ? null : e.flow === "card" && e.rail === "nmi" ? "card" : e.flow === "tokenize" && m(e.config?.tokenization_key) && e.config?.tokenization_url ? "collect_js" : h(e) ? "stripe_elements" : null;
|
|
114
156
|
}
|
|
115
|
-
var
|
|
116
|
-
function
|
|
157
|
+
var _ = (e) => g(e) !== null, v = (e) => g(e) === "stripe_elements", y = -(1n << 63n), b = (1n << 63n) - 1n;
|
|
158
|
+
function x(e) {
|
|
117
159
|
if (typeof e != "string" || !/^-?\d{1,19}$/.test(e)) return null;
|
|
118
160
|
let t = BigInt(e);
|
|
119
|
-
return t <
|
|
161
|
+
return t < y || t > b ? null : t;
|
|
120
162
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
163
|
+
function S(e) {
|
|
164
|
+
return x(e) !== null;
|
|
123
165
|
}
|
|
124
|
-
function
|
|
166
|
+
function C(e) {
|
|
125
167
|
return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= 18;
|
|
126
168
|
}
|
|
127
|
-
function
|
|
169
|
+
function w(...e) {
|
|
128
170
|
let t = 0n;
|
|
129
171
|
for (let n of e) {
|
|
130
|
-
let e =
|
|
172
|
+
let e = x(n);
|
|
131
173
|
if (e === null) return null;
|
|
132
174
|
t += e;
|
|
133
175
|
}
|
|
134
|
-
return t <
|
|
176
|
+
return t < y || t > b ? null : t.toString();
|
|
135
177
|
}
|
|
136
|
-
var
|
|
178
|
+
var te = (() => {
|
|
137
179
|
try {
|
|
138
180
|
return new Intl.NumberFormat("en", { useGrouping: !1 }).format("9007199254740993") === "9007199254740993";
|
|
139
181
|
} catch {
|
|
140
182
|
return !1;
|
|
141
183
|
}
|
|
142
|
-
})(),
|
|
143
|
-
function
|
|
184
|
+
})(), T = 10n ** 15n;
|
|
185
|
+
function E(e, t) {
|
|
144
186
|
let n = e < 0n ? -e : e, r = 10n ** BigInt(t), i = (n % r).toString().padStart(t, "0").replace(/0+$/, "");
|
|
145
187
|
return `${e < 0n ? "-" : ""}${n / r}${i ? `.${i}` : ""}`;
|
|
146
188
|
}
|
|
147
|
-
function
|
|
148
|
-
let n =
|
|
149
|
-
return n === null || !
|
|
189
|
+
function ne(e, t) {
|
|
190
|
+
let n = x(e);
|
|
191
|
+
return n === null || !C(t) ? null : E(n, t);
|
|
150
192
|
}
|
|
151
|
-
function
|
|
152
|
-
let r =
|
|
153
|
-
if (r === null || !
|
|
193
|
+
function re(e, t, n) {
|
|
194
|
+
let r = x(e);
|
|
195
|
+
if (r === null || !C(t) || !C(n) || n > t) return null;
|
|
154
196
|
let i = 10n ** BigInt(t - n);
|
|
155
197
|
if (r % i !== 0n) return null;
|
|
156
198
|
let a = r / i;
|
|
157
199
|
return a > BigInt(2 ** 53 - 1) || a < -BigInt(2 ** 53 - 1) ? null : Number(a);
|
|
158
200
|
}
|
|
159
|
-
function
|
|
160
|
-
if (!
|
|
201
|
+
function D(e, t) {
|
|
202
|
+
if (!C(t) || e.length > 40) return null;
|
|
161
203
|
let n = /^(-?)(\d+)(?:\.(\d+))?$/.exec(e);
|
|
162
204
|
if (!n) return null;
|
|
163
205
|
let r = n[3] ?? "";
|
|
164
206
|
if (r.length > t) return null;
|
|
165
207
|
let i = BigInt(n[2]) * 10n ** BigInt(t) + BigInt(r.padEnd(t, "0") || "0"), a = n[1] ? -i : i;
|
|
166
|
-
return a <
|
|
208
|
+
return a < y || a > b ? null : a.toString();
|
|
167
209
|
}
|
|
168
|
-
function
|
|
169
|
-
let i = t.trim().toUpperCase(), a =
|
|
170
|
-
if (a === null || !
|
|
171
|
-
if (!
|
|
172
|
-
let o =
|
|
210
|
+
function ie(e, t, n, r) {
|
|
211
|
+
let i = t.trim().toUpperCase(), a = x(e);
|
|
212
|
+
if (a === null || !C(n)) return `${i} amount exceeds the exact display range`;
|
|
213
|
+
if (!te && (a >= T || a <= -T)) return `${i} amount exceeds this browser's exact display range`;
|
|
214
|
+
let o = E(a, n);
|
|
173
215
|
try {
|
|
174
216
|
return new Intl.NumberFormat(r, {
|
|
175
217
|
style: "currency",
|
|
@@ -182,7 +224,7 @@ function ne(e, t, n, r) {
|
|
|
182
224
|
}
|
|
183
225
|
//#endregion
|
|
184
226
|
//#region src/client/types.ts
|
|
185
|
-
var
|
|
227
|
+
var O = e.string().refine(S, "amount must be an int64 string"), k = e.string(), ae = (t) => e.object({
|
|
186
228
|
data: e.array(t).nullish().transform((e) => e ?? []),
|
|
187
229
|
total: e.number().nullish(),
|
|
188
230
|
limit: e.number().nullish(),
|
|
@@ -192,31 +234,31 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
192
234
|
}), A = (t) => e.object({
|
|
193
235
|
data: e.array(t).nullish().transform((e) => e ?? []),
|
|
194
236
|
next_cursor: e.string().nullish().transform((e) => e ?? null)
|
|
195
|
-
}), j = e.string(),
|
|
237
|
+
}), j = e.string(), M = e.object({
|
|
196
238
|
status: e.string(),
|
|
197
239
|
ids: e.record(e.string(), e.string()).nullish(),
|
|
198
240
|
sync_status: e.string().nullish()
|
|
199
|
-
}),
|
|
241
|
+
}), N = e.object({
|
|
200
242
|
id: e.string(),
|
|
201
243
|
key: e.string(),
|
|
202
244
|
revision: e.number().int().nonnegative().optional(),
|
|
203
245
|
version: e.number().int().nonnegative().optional(),
|
|
204
246
|
product_id: e.string(),
|
|
205
247
|
archived: e.boolean(),
|
|
206
|
-
unit_amount:
|
|
248
|
+
unit_amount: O,
|
|
207
249
|
customer_amount: e.object({
|
|
208
|
-
min_amount:
|
|
209
|
-
max_amount:
|
|
250
|
+
min_amount: O,
|
|
251
|
+
max_amount: O
|
|
210
252
|
}).nullish(),
|
|
211
253
|
currency: e.string(),
|
|
212
254
|
access_duration_hours: e.number().nullable(),
|
|
213
255
|
billing_interval_hours: e.number().nullable(),
|
|
214
|
-
trial_unit_amount:
|
|
256
|
+
trial_unit_amount: O.nullable(),
|
|
215
257
|
trial_duration_hours: e.number().nullable(),
|
|
216
|
-
psps: e.record(e.string(),
|
|
217
|
-
created_at:
|
|
218
|
-
updated_at:
|
|
219
|
-
}),
|
|
258
|
+
psps: e.record(e.string(), M).nullish(),
|
|
259
|
+
created_at: k,
|
|
260
|
+
updated_at: k
|
|
261
|
+
}), P = e.object({
|
|
220
262
|
id: e.string(),
|
|
221
263
|
key: e.string().nullish(),
|
|
222
264
|
revision: e.number().int().nonnegative().optional(),
|
|
@@ -224,32 +266,30 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
224
266
|
description: e.string().nullish(),
|
|
225
267
|
tier_group: e.string().nullish(),
|
|
226
268
|
tier_rank: e.number().nullish()
|
|
227
|
-
}),
|
|
269
|
+
}), F = e.object({
|
|
228
270
|
brand: e.string().nullish(),
|
|
229
271
|
last4: e.string().nullish(),
|
|
230
272
|
exp_month: e.number().nullish(),
|
|
231
273
|
exp_year: e.number().nullish()
|
|
232
|
-
}),
|
|
233
|
-
id: e.string(),
|
|
234
|
-
status: e.string()
|
|
235
|
-
}), ae = e.object({
|
|
274
|
+
}), oe = e.object({
|
|
236
275
|
last_failure_reason: e.string().nullish(),
|
|
237
276
|
retryable: e.boolean(),
|
|
238
277
|
blocked_reason: e.string().nullish(),
|
|
239
|
-
operation: ie.nullish(),
|
|
240
278
|
order_id: e.string().nullish()
|
|
241
|
-
}), F = e.object({
|
|
242
|
-
type: e.string(),
|
|
243
|
-
redirect_to_url: e.object({ url: e.string().nullish() }).nullish(),
|
|
244
|
-
transactions: e.array(e.string()).nullish()
|
|
245
279
|
}), I = e.object({
|
|
280
|
+
type: e.string(),
|
|
281
|
+
url: e.string().nullish(),
|
|
282
|
+
psp_id: e.string().nullish(),
|
|
283
|
+
transactions: e.array(e.string()).nullish(),
|
|
284
|
+
payload: e.record(e.string(), e.string()).nullish()
|
|
285
|
+
}), L = e.object({
|
|
246
286
|
attempts: e.number(),
|
|
247
287
|
retries_left: e.number().nullish(),
|
|
248
|
-
next_retry_at:
|
|
249
|
-
final_retry_at:
|
|
288
|
+
next_retry_at: k.nullish(),
|
|
289
|
+
final_retry_at: k.nullish(),
|
|
250
290
|
waiting_for_new_card: e.boolean(),
|
|
251
291
|
last_failure_reason: e.string().nullish()
|
|
252
|
-
}),
|
|
292
|
+
}), R = e.object({
|
|
253
293
|
id: e.string(),
|
|
254
294
|
status: j,
|
|
255
295
|
rail: e.string().nullish(),
|
|
@@ -259,37 +299,37 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
259
299
|
psp_id: e.string().nullish(),
|
|
260
300
|
collection_policy: e.string().nullish(),
|
|
261
301
|
payment_method_id: e.string().nullish(),
|
|
262
|
-
started_at:
|
|
263
|
-
ended_at:
|
|
264
|
-
current_period_starts_at:
|
|
265
|
-
current_period_ends_at:
|
|
266
|
-
canceled_at:
|
|
302
|
+
started_at: k.nullish(),
|
|
303
|
+
ended_at: k.nullish(),
|
|
304
|
+
current_period_starts_at: k.nullish(),
|
|
305
|
+
current_period_ends_at: k.nullish(),
|
|
306
|
+
canceled_at: k.nullish(),
|
|
267
307
|
cancel_type: e.string().nullish(),
|
|
268
308
|
resumable: e.boolean().nullish(),
|
|
269
309
|
cancel_scheduled: e.boolean().nullish(),
|
|
270
310
|
cancel_mode: e.string().nullish(),
|
|
271
311
|
cancel_portal_url: e.string().nullish(),
|
|
272
312
|
access: e.object({
|
|
273
|
-
starts_at:
|
|
274
|
-
ends_at:
|
|
313
|
+
starts_at: k,
|
|
314
|
+
ends_at: k.nullish()
|
|
275
315
|
}).nullish(),
|
|
276
|
-
dunning:
|
|
277
|
-
price:
|
|
278
|
-
product:
|
|
316
|
+
dunning: L.nullish(),
|
|
317
|
+
price: N.nullish(),
|
|
318
|
+
product: P.nullish(),
|
|
279
319
|
scheduled_change: e.object({
|
|
280
320
|
price_id: e.string(),
|
|
281
321
|
quantity: e.number().nullish(),
|
|
282
|
-
effective_at:
|
|
322
|
+
effective_at: k,
|
|
283
323
|
source: e.string(),
|
|
284
|
-
price:
|
|
285
|
-
product:
|
|
324
|
+
price: N.nullish(),
|
|
325
|
+
product: P.nullish()
|
|
286
326
|
}).nullish(),
|
|
287
|
-
card:
|
|
288
|
-
recovery:
|
|
289
|
-
next_action:
|
|
290
|
-
created_at:
|
|
291
|
-
updated_at:
|
|
292
|
-
}),
|
|
327
|
+
card: F.nullish(),
|
|
328
|
+
recovery: oe.nullish(),
|
|
329
|
+
next_action: I.nullish(),
|
|
330
|
+
created_at: k.nullish(),
|
|
331
|
+
updated_at: k.nullish()
|
|
332
|
+
}), z = e.object({
|
|
293
333
|
name: e.string().nullish(),
|
|
294
334
|
email: e.string().nullish(),
|
|
295
335
|
phone: e.string().nullish(),
|
|
@@ -301,7 +341,7 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
301
341
|
postal_code: e.string().nullish(),
|
|
302
342
|
country: e.string().nullish()
|
|
303
343
|
}).nullish()
|
|
304
|
-
}),
|
|
344
|
+
}), B = e.object({
|
|
305
345
|
id: e.string(),
|
|
306
346
|
status: e.string().nullish(),
|
|
307
347
|
next_action: e.object({
|
|
@@ -311,12 +351,12 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
311
351
|
}).nullish(),
|
|
312
352
|
rail: e.string().nullish(),
|
|
313
353
|
psp_id: e.string().nullish(),
|
|
314
|
-
card:
|
|
315
|
-
billing_details:
|
|
354
|
+
card: F.nullish(),
|
|
355
|
+
billing_details: z.nullish(),
|
|
316
356
|
reusable: e.boolean().nullish(),
|
|
317
357
|
health: e.object({
|
|
318
358
|
expiry_status: e.string().nullish(),
|
|
319
|
-
last_charged_at:
|
|
359
|
+
last_charged_at: k.nullish(),
|
|
320
360
|
last_charge_outcome: e.string().nullish(),
|
|
321
361
|
active: e.boolean().nullish()
|
|
322
362
|
}).nullish(),
|
|
@@ -325,17 +365,11 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
325
365
|
display_name: e.string().nullish()
|
|
326
366
|
})).nullish(),
|
|
327
367
|
default_currencies: e.array(e.string()).nullish(),
|
|
328
|
-
created_at:
|
|
329
|
-
}),
|
|
368
|
+
created_at: k.nullish()
|
|
369
|
+
}), V = e.object({
|
|
330
370
|
reason: e.string(),
|
|
331
371
|
message: e.string(),
|
|
332
372
|
field: e.string().nullish()
|
|
333
|
-
}), V = e.object({
|
|
334
|
-
type: e.string(),
|
|
335
|
-
url: e.string().nullish(),
|
|
336
|
-
psp_id: e.string().nullish(),
|
|
337
|
-
transactions: e.array(e.string()).nullish(),
|
|
338
|
-
payload: e.record(e.string(), e.string()).nullish()
|
|
339
373
|
}), H = e.object({
|
|
340
374
|
id: e.string(),
|
|
341
375
|
price_id: e.string().nullish(),
|
|
@@ -343,8 +377,8 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
343
377
|
source: e.string().nullish(),
|
|
344
378
|
description: e.string(),
|
|
345
379
|
quantity: e.number().nullish(),
|
|
346
|
-
unit_amount:
|
|
347
|
-
amount:
|
|
380
|
+
unit_amount: O,
|
|
381
|
+
amount: O,
|
|
348
382
|
billing_interval_hours: e.number().nullish(),
|
|
349
383
|
access_duration_hours: e.number().nullish(),
|
|
350
384
|
subscription_id: e.string().nullish(),
|
|
@@ -356,12 +390,12 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
356
390
|
status: e.string(),
|
|
357
391
|
number: e.string().nullish(),
|
|
358
392
|
currency: e.string(),
|
|
359
|
-
total:
|
|
393
|
+
total: O,
|
|
360
394
|
lines: e.array(H),
|
|
361
395
|
payment: e.object({
|
|
362
396
|
status: e.string(),
|
|
363
|
-
next_action:
|
|
364
|
-
last_payment_error:
|
|
397
|
+
next_action: I.nullish(),
|
|
398
|
+
last_payment_error: V.nullish(),
|
|
365
399
|
payment_method_id: e.string().nullish(),
|
|
366
400
|
payment_id: e.string().nullish()
|
|
367
401
|
}),
|
|
@@ -373,36 +407,36 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
373
407
|
checkout: e.object({
|
|
374
408
|
url: e.string().nullish(),
|
|
375
409
|
ui_mode: e.enum(["hosted", "embedded"]).catch("hosted"),
|
|
376
|
-
expires_at:
|
|
410
|
+
expires_at: k,
|
|
377
411
|
success_url: e.string(),
|
|
378
412
|
cancel_url: e.string().nullish(),
|
|
379
413
|
saved_payment_methods: e.boolean()
|
|
380
414
|
}).nullish(),
|
|
381
415
|
renewal: e.object({
|
|
382
416
|
subscription_id: e.string(),
|
|
383
|
-
period_starts_at:
|
|
384
|
-
period_ends_at:
|
|
385
|
-
due_at:
|
|
417
|
+
period_starts_at: k,
|
|
418
|
+
period_ends_at: k,
|
|
419
|
+
due_at: k
|
|
386
420
|
}).nullish(),
|
|
387
421
|
usage: e.object({
|
|
388
|
-
period_starts_at:
|
|
389
|
-
period_ends_at:
|
|
390
|
-
due_at:
|
|
391
|
-
amount_paid:
|
|
392
|
-
amount_due:
|
|
422
|
+
period_starts_at: k,
|
|
423
|
+
period_ends_at: k,
|
|
424
|
+
due_at: k,
|
|
425
|
+
amount_paid: O,
|
|
426
|
+
amount_due: O,
|
|
393
427
|
collection_method: e.string(),
|
|
394
|
-
next_collection_attempt_at:
|
|
428
|
+
next_collection_attempt_at: k.nullish(),
|
|
395
429
|
po_number: e.string().nullish(),
|
|
396
430
|
memo: e.string().nullish(),
|
|
397
431
|
delinquent: e.boolean()
|
|
398
432
|
}).nullish(),
|
|
399
|
-
expires_at:
|
|
400
|
-
completed_at:
|
|
401
|
-
canceled_at:
|
|
402
|
-
expired_at:
|
|
403
|
-
voided_at:
|
|
404
|
-
uncollectible_at:
|
|
405
|
-
created_at:
|
|
433
|
+
expires_at: k.nullish(),
|
|
434
|
+
completed_at: k.nullish(),
|
|
435
|
+
canceled_at: k.nullish(),
|
|
436
|
+
expired_at: k.nullish(),
|
|
437
|
+
voided_at: k.nullish(),
|
|
438
|
+
uncollectible_at: k.nullish(),
|
|
439
|
+
created_at: k
|
|
406
440
|
}), W = e.object({
|
|
407
441
|
code: e.string(),
|
|
408
442
|
message: e.string(),
|
|
@@ -413,19 +447,19 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
413
447
|
product_id: e.string(),
|
|
414
448
|
description: e.string(),
|
|
415
449
|
quantity: e.number().nullish(),
|
|
416
|
-
unit_amount:
|
|
417
|
-
amount:
|
|
450
|
+
unit_amount: O,
|
|
451
|
+
amount: O,
|
|
418
452
|
ownership: e.string(),
|
|
419
453
|
billing_interval_hours: e.number().nullish(),
|
|
420
454
|
access_duration_hours: e.number().nullish(),
|
|
421
455
|
refusal: W.nullish()
|
|
422
456
|
}), K = e.object({
|
|
423
457
|
currency: e.string(),
|
|
424
|
-
total:
|
|
458
|
+
total: O,
|
|
425
459
|
lines: e.array(G),
|
|
426
460
|
payment_options: U.shape.payment_options,
|
|
427
|
-
last_changed_at:
|
|
428
|
-
expires_at:
|
|
461
|
+
last_changed_at: k.nullish(),
|
|
462
|
+
expires_at: k.nullish()
|
|
429
463
|
}), q = e.object({
|
|
430
464
|
id: e.string(),
|
|
431
465
|
key: e.string(),
|
|
@@ -435,86 +469,85 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
435
469
|
entitlements: e.array(e.string()),
|
|
436
470
|
credit_grant: e.object({
|
|
437
471
|
currency: e.string(),
|
|
438
|
-
amount:
|
|
472
|
+
amount: O.nullish(),
|
|
439
473
|
from_payment: e.boolean().optional(),
|
|
440
474
|
expires_after_days: e.number().int().positive().nullish()
|
|
441
475
|
}).nullish(),
|
|
442
476
|
tier_group: e.string().nullable(),
|
|
443
477
|
tier_rank: e.number(),
|
|
444
478
|
archived: e.boolean(),
|
|
445
|
-
prices: e.array(
|
|
446
|
-
created_at:
|
|
447
|
-
updated_at:
|
|
448
|
-
}),
|
|
479
|
+
prices: e.array(N).nullish().transform((e) => e ?? []),
|
|
480
|
+
created_at: k,
|
|
481
|
+
updated_at: k
|
|
482
|
+
}), se = e.object({
|
|
449
483
|
id: e.string(),
|
|
450
484
|
kind: e.string(),
|
|
451
485
|
status: e.string(),
|
|
452
|
-
amount:
|
|
453
|
-
amount_refunded:
|
|
486
|
+
amount: O,
|
|
487
|
+
amount_refunded: O.nullish(),
|
|
454
488
|
currency: e.string(),
|
|
455
489
|
subscription_id: e.string().nullish(),
|
|
456
490
|
price_id: e.string().nullish(),
|
|
457
491
|
channel: e.string().nullish(),
|
|
458
492
|
rail: e.string().nullish(),
|
|
459
|
-
created_at:
|
|
460
|
-
price:
|
|
461
|
-
product:
|
|
462
|
-
card:
|
|
493
|
+
created_at: k,
|
|
494
|
+
price: N.nullish(),
|
|
495
|
+
product: P.nullish(),
|
|
496
|
+
card: F.nullish(),
|
|
463
497
|
failure: e.object({
|
|
464
498
|
reason: e.string(),
|
|
465
499
|
message: e.string(),
|
|
466
500
|
field: e.string().nullish()
|
|
467
501
|
}).nullish()
|
|
468
|
-
}),
|
|
502
|
+
}), J = e.object({
|
|
469
503
|
currency: e.string(),
|
|
470
504
|
billing_mode: e.string(),
|
|
471
|
-
balance_amount:
|
|
472
|
-
held_amount:
|
|
473
|
-
accrued_amount:
|
|
474
|
-
available_amount:
|
|
475
|
-
owed_amount:
|
|
476
|
-
accrual_rate_per_hour:
|
|
505
|
+
balance_amount: O,
|
|
506
|
+
held_amount: O,
|
|
507
|
+
accrued_amount: O,
|
|
508
|
+
available_amount: O,
|
|
509
|
+
owed_amount: O,
|
|
510
|
+
accrual_rate_per_hour: O,
|
|
477
511
|
as_of: e.string(),
|
|
478
512
|
depletes_at: e.string().nullable()
|
|
479
|
-
}),
|
|
513
|
+
}), ce = e.object({
|
|
480
514
|
id: e.string(),
|
|
481
|
-
balances: e.array(
|
|
515
|
+
balances: e.array(J),
|
|
482
516
|
default_payment_methods: e.array(e.object({
|
|
483
517
|
currency: e.string(),
|
|
484
518
|
payment_method_id: e.string()
|
|
485
519
|
})),
|
|
486
520
|
unread_notifications: e.number()
|
|
487
|
-
}),
|
|
521
|
+
}), le = e.object({
|
|
488
522
|
code: e.string(),
|
|
489
523
|
decimals: e.number(),
|
|
490
524
|
minor_decimals: e.number().nullish()
|
|
491
|
-
}),
|
|
525
|
+
}), ue = e.object({
|
|
492
526
|
price_id: e.string(),
|
|
493
527
|
quantity: e.number().nullish(),
|
|
494
528
|
rail: e.string().nullish(),
|
|
495
529
|
currency: e.string(),
|
|
496
|
-
amount_due_now:
|
|
497
|
-
next_charge_amount:
|
|
498
|
-
next_charge_date:
|
|
530
|
+
amount_due_now: O,
|
|
531
|
+
next_charge_amount: O,
|
|
532
|
+
next_charge_date: k.nullish(),
|
|
499
533
|
effective: e.string(),
|
|
500
534
|
is_estimate: e.boolean().nullish(),
|
|
501
535
|
message: e.string().nullish()
|
|
502
|
-
}),
|
|
536
|
+
}), Y = e.object({
|
|
503
537
|
status: e.string(),
|
|
504
538
|
effective: e.string().nullish(),
|
|
505
539
|
price_id: e.string().nullish(),
|
|
506
540
|
quantity: e.number().nullish(),
|
|
507
541
|
subscription_id: e.string().nullish(),
|
|
508
|
-
next_action:
|
|
509
|
-
delayed_start:
|
|
542
|
+
next_action: I.nullish(),
|
|
543
|
+
delayed_start: k.nullish(),
|
|
510
544
|
currency: e.string().nullish(),
|
|
511
|
-
amount_due_now:
|
|
512
|
-
next_charge_amount:
|
|
513
|
-
next_charge_date:
|
|
514
|
-
message: e.string().nullish()
|
|
515
|
-
operation_id: e.string().nullish()
|
|
545
|
+
amount_due_now: O.nullish(),
|
|
546
|
+
next_charge_amount: O.nullish(),
|
|
547
|
+
next_charge_date: k.nullish(),
|
|
548
|
+
message: e.string().nullish()
|
|
516
549
|
}), de = e.object({
|
|
517
|
-
psps: e.array(
|
|
550
|
+
psps: e.array(u).nullish().transform((e) => e ?? []),
|
|
518
551
|
solana: e.object({
|
|
519
552
|
network: e.string(),
|
|
520
553
|
chain: e.string(),
|
|
@@ -544,29 +577,30 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
|
|
|
544
577
|
route_groups: e.record(e.string(), e.boolean()),
|
|
545
578
|
features: e.record(e.string(), e.boolean())
|
|
546
579
|
}),
|
|
547
|
-
currencies: e.array(
|
|
548
|
-
payment: de.nullish(),
|
|
549
|
-
merchant: pe.nullish(),
|
|
580
|
+
currencies: e.array(le).nullish().transform((e) => e ?? []),
|
|
550
581
|
captcha: fe.nullish(),
|
|
551
582
|
network: e.object({
|
|
552
583
|
issuer: e.string(),
|
|
553
584
|
client_id: e.string()
|
|
554
585
|
}).nullish()
|
|
555
586
|
}), he = e.object({
|
|
587
|
+
payment: de,
|
|
588
|
+
merchant: pe
|
|
589
|
+
}), ge = e.object({
|
|
556
590
|
id: e.string(),
|
|
557
591
|
nonce: e.string(),
|
|
558
|
-
expires_at:
|
|
559
|
-
}),
|
|
592
|
+
expires_at: k
|
|
593
|
+
}), _e = e.object({
|
|
560
594
|
id: e.string(),
|
|
561
595
|
merchant_id: e.string(),
|
|
562
596
|
customer_id: e.string(),
|
|
563
597
|
account_id: e.string(),
|
|
564
598
|
method: e.string(),
|
|
565
599
|
status: e.string(),
|
|
566
|
-
linked_at:
|
|
567
|
-
revoked_at:
|
|
600
|
+
linked_at: k,
|
|
601
|
+
revoked_at: k.nullish(),
|
|
568
602
|
revoked_by: e.string().nullish()
|
|
569
|
-
}),
|
|
603
|
+
}), X = class extends Error {
|
|
570
604
|
constructor(e = "The wallet request was declined.") {
|
|
571
605
|
super(e), this.name = "WalletRejectedError";
|
|
572
606
|
}
|
|
@@ -584,18 +618,18 @@ async function xe(e, t) {
|
|
|
584
618
|
if (!n) throw i("wallet_no_signature", "The wallet returned no signature.");
|
|
585
619
|
return n;
|
|
586
620
|
}
|
|
587
|
-
var Se = 2e3,
|
|
588
|
-
function
|
|
589
|
-
let t =
|
|
621
|
+
var Se = 2e3, Z = 300;
|
|
622
|
+
function Ce(e) {
|
|
623
|
+
let t = we(e.headers.get("Retry-After"));
|
|
590
624
|
switch (e.status) {
|
|
591
625
|
case 429: return t;
|
|
592
|
-
case 503: return t ??
|
|
626
|
+
case 503: return t ?? Z;
|
|
593
627
|
case 502:
|
|
594
|
-
case 504: return
|
|
628
|
+
case 504: return Z;
|
|
595
629
|
default: return null;
|
|
596
630
|
}
|
|
597
631
|
}
|
|
598
|
-
function
|
|
632
|
+
function we(e) {
|
|
599
633
|
if (!e) return null;
|
|
600
634
|
if (/^\d+$/.test(e.trim())) return Number(e.trim()) * 1e3;
|
|
601
635
|
let t = Date.parse(e);
|
|
@@ -612,8 +646,8 @@ function Q(e, t) {
|
|
|
612
646
|
t?.addEventListener("abort", a, { once: !0 });
|
|
613
647
|
});
|
|
614
648
|
}
|
|
615
|
-
function
|
|
616
|
-
let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), r = e.fetch ?? ((e, t) => fetch(e, t)), o =
|
|
649
|
+
function Te(e = {}) {
|
|
650
|
+
let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), r = e.fetch ?? ((e, t) => fetch(e, t)), o = Ee({
|
|
617
651
|
...s,
|
|
618
652
|
...e.currencies
|
|
619
653
|
});
|
|
@@ -630,7 +664,7 @@ function we(e = {}) {
|
|
|
630
664
|
...n.headers
|
|
631
665
|
});
|
|
632
666
|
n.body !== void 0 && i.set("Content-Type", "application/json");
|
|
633
|
-
let o = n.
|
|
667
|
+
let o = n.public ? void 0 : await e.getToken?.();
|
|
634
668
|
o && i.set("Authorization", `Bearer ${o}`);
|
|
635
669
|
let s = e.language?.();
|
|
636
670
|
s && i.set("Accept-Language", s);
|
|
@@ -639,21 +673,27 @@ function we(e = {}) {
|
|
|
639
673
|
headers: i,
|
|
640
674
|
body: n.body === void 0 ? void 0 : JSON.stringify(n.body),
|
|
641
675
|
signal: n.signal
|
|
642
|
-
}, d = +(l === "GET"), f = 0;
|
|
643
|
-
for (let
|
|
644
|
-
let
|
|
676
|
+
}, d = +(l === "GET"), f = 0, p = !1;
|
|
677
|
+
for (let s = 0;; s++) {
|
|
678
|
+
let l;
|
|
645
679
|
try {
|
|
646
|
-
|
|
647
|
-
} catch (
|
|
648
|
-
let
|
|
649
|
-
if (
|
|
650
|
-
f += await Q(
|
|
680
|
+
l = await r(c(t, n.query), u);
|
|
681
|
+
} catch (e) {
|
|
682
|
+
let t = Z;
|
|
683
|
+
if (s >= d || n.signal?.aborted || !(e instanceof TypeError) || f + t > 2e3) throw e;
|
|
684
|
+
f += await Q(t, n.signal);
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
if (l.ok) return l;
|
|
688
|
+
if (l.status === 401 && o && !p && ee(e.getToken)) {
|
|
689
|
+
let t = await a(l);
|
|
690
|
+
if (t.code !== "credential_expired") throw t;
|
|
691
|
+
e.getToken.invalidate(o), o = await e.getToken(), i.set("Authorization", `Bearer ${o}`), p = !0, s--;
|
|
651
692
|
continue;
|
|
652
693
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
await i.body?.cancel().catch(() => void 0), f += await Q(o, n.signal);
|
|
694
|
+
let m = Ce(l);
|
|
695
|
+
if (s >= d || m === null || f + m > 2e3) throw await a(l);
|
|
696
|
+
await l.body?.cancel().catch(() => void 0), f += await Q(m, n.signal);
|
|
657
697
|
}
|
|
658
698
|
}
|
|
659
699
|
async function u(e, t, n) {
|
|
@@ -667,10 +707,10 @@ function we(e = {}) {
|
|
|
667
707
|
if (!o.success) throw i("invalid_response", `${t}: ${o.error.issues[0]?.path.join(".")} ${o.error.issues[0]?.message}`);
|
|
668
708
|
return o.data;
|
|
669
709
|
}
|
|
670
|
-
let d = (e) => encodeURIComponent(e), f = A(
|
|
710
|
+
let d = (e) => encodeURIComponent(e), f = A(R), p = A(B), m = A(se), h = A(U), g = (e, t) => ({
|
|
671
711
|
limit: e.limit ?? t,
|
|
672
712
|
cursor: e.cursor ?? void 0
|
|
673
|
-
}), _ =
|
|
713
|
+
}), _ = ae(q);
|
|
674
714
|
async function v(e, t) {
|
|
675
715
|
try {
|
|
676
716
|
return { order: await u(U, e, t) };
|
|
@@ -697,10 +737,10 @@ function we(e = {}) {
|
|
|
697
737
|
});
|
|
698
738
|
},
|
|
699
739
|
getSubscription(e, t) {
|
|
700
|
-
return u(
|
|
740
|
+
return u(R, `/me/subscriptions/${d(e)}`, { signal: t });
|
|
701
741
|
},
|
|
702
742
|
cancelSubscription(e, t) {
|
|
703
|
-
return u(
|
|
743
|
+
return u(R, `/me/subscriptions/${d(e)}/cancel`, {
|
|
704
744
|
method: "POST",
|
|
705
745
|
body: {
|
|
706
746
|
reason: t.reason.trim(),
|
|
@@ -709,19 +749,19 @@ function we(e = {}) {
|
|
|
709
749
|
});
|
|
710
750
|
},
|
|
711
751
|
resumeSubscription(e) {
|
|
712
|
-
return u(
|
|
752
|
+
return u(R, `/me/subscriptions/${d(e)}/resume`, {
|
|
713
753
|
method: "POST",
|
|
714
754
|
body: {}
|
|
715
755
|
});
|
|
716
756
|
},
|
|
717
757
|
setSubscriptionPaymentMethod(e, t) {
|
|
718
|
-
return u(
|
|
758
|
+
return u(R, `/me/subscriptions/${d(e)}/payment-method`, {
|
|
719
759
|
method: "PUT",
|
|
720
760
|
body: { payment_method_id: t }
|
|
721
761
|
});
|
|
722
762
|
},
|
|
723
763
|
previewSubscriptionChange(e, t, n) {
|
|
724
|
-
return u(
|
|
764
|
+
return u(ue, `/me/subscriptions/${d(e)}/change/preview`, {
|
|
725
765
|
method: "POST",
|
|
726
766
|
body: {
|
|
727
767
|
price_id: t.priceId,
|
|
@@ -730,8 +770,14 @@ function we(e = {}) {
|
|
|
730
770
|
signal: n
|
|
731
771
|
});
|
|
732
772
|
},
|
|
773
|
+
confirmSubscriptionChange(e) {
|
|
774
|
+
return u(Y, `/me/subscriptions/${d(e)}/confirm`, {
|
|
775
|
+
method: "POST",
|
|
776
|
+
body: {}
|
|
777
|
+
});
|
|
778
|
+
},
|
|
733
779
|
changeSubscription(e, t) {
|
|
734
|
-
return u(
|
|
780
|
+
return u(Y, `/me/subscriptions/${d(e)}/change`, {
|
|
735
781
|
method: "POST",
|
|
736
782
|
body: {
|
|
737
783
|
price_id: t.priceId,
|
|
@@ -748,7 +794,7 @@ function we(e = {}) {
|
|
|
748
794
|
});
|
|
749
795
|
},
|
|
750
796
|
addPaymentMethod(e) {
|
|
751
|
-
return u(
|
|
797
|
+
return u(B, "/me/payment-methods", {
|
|
752
798
|
method: "POST",
|
|
753
799
|
body: e
|
|
754
800
|
});
|
|
@@ -810,16 +856,7 @@ function we(e = {}) {
|
|
|
810
856
|
});
|
|
811
857
|
},
|
|
812
858
|
confirmPaymentMethod(e) {
|
|
813
|
-
return u(
|
|
814
|
-
method: "POST",
|
|
815
|
-
body: {}
|
|
816
|
-
});
|
|
817
|
-
},
|
|
818
|
-
getPaymentAuthentication(e) {
|
|
819
|
-
return u(_e, `/me/payment-operations/${d(e)}/authentication`);
|
|
820
|
-
},
|
|
821
|
-
async confirmPaymentAuthentication(e) {
|
|
822
|
-
await l(`/me/payment-operations/${d(e)}/authentication/confirm`, {
|
|
859
|
+
return u(B, `/me/payment-methods/${d(e)}/confirm`, {
|
|
823
860
|
method: "POST",
|
|
824
861
|
body: {}
|
|
825
862
|
});
|
|
@@ -843,25 +880,29 @@ function we(e = {}) {
|
|
|
843
880
|
});
|
|
844
881
|
},
|
|
845
882
|
getAccount(e) {
|
|
846
|
-
return u(
|
|
883
|
+
return u(ce, "/me", { signal: e });
|
|
847
884
|
},
|
|
848
885
|
async listProducts(e) {
|
|
849
886
|
return e.keys.length === 0 ? {
|
|
850
887
|
data: [],
|
|
851
888
|
next_cursor: null
|
|
852
889
|
} : u(_, "/catalog/products", {
|
|
853
|
-
query: {
|
|
854
|
-
|
|
890
|
+
query: {
|
|
891
|
+
merchant: e.merchant,
|
|
892
|
+
keys: e.keys
|
|
893
|
+
},
|
|
894
|
+
signal: e.signal,
|
|
895
|
+
public: !0
|
|
855
896
|
});
|
|
856
897
|
},
|
|
857
898
|
createNetworkLinkChallenge() {
|
|
858
|
-
return u(
|
|
899
|
+
return u(ge, "/me/network-link/challenges", {
|
|
859
900
|
method: "POST",
|
|
860
901
|
body: {}
|
|
861
902
|
});
|
|
862
903
|
},
|
|
863
904
|
createNetworkLink(e) {
|
|
864
|
-
return u(
|
|
905
|
+
return u(_e, "/me/network-link", {
|
|
865
906
|
method: "POST",
|
|
866
907
|
body: {
|
|
867
908
|
challenge_id: e.challengeId,
|
|
@@ -872,17 +913,20 @@ function we(e = {}) {
|
|
|
872
913
|
getConfig(e) {
|
|
873
914
|
return u(me, "/config", {
|
|
874
915
|
signal: e,
|
|
875
|
-
|
|
916
|
+
public: !0
|
|
876
917
|
});
|
|
877
918
|
},
|
|
919
|
+
getCustomerConfig(e) {
|
|
920
|
+
return u(he, "/me/config", { signal: e });
|
|
921
|
+
},
|
|
878
922
|
currencies: o
|
|
879
923
|
};
|
|
880
924
|
}
|
|
881
|
-
function
|
|
925
|
+
function Ee(e) {
|
|
882
926
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e.toUpperCase(), t]));
|
|
883
927
|
}
|
|
884
|
-
var $ = (e) => e instanceof
|
|
928
|
+
var $ = (e) => e instanceof X || e instanceof Error && e.name === "WalletRejectedError" || e instanceof t && e.code === "wallet_rejected";
|
|
885
929
|
//#endregion
|
|
886
|
-
export {
|
|
930
|
+
export { t as C, a as D, i as E, o as O, c as S, r as T, p as _, Te as a, u as b, xe as c, re as d, D as f, _ as g, v as h, X as i, w as l, S as m, ve as n, be as o, ie as p, Se as r, $ as s, ye as t, ne as u, g as v, n as w, l as x, d as y };
|
|
887
931
|
|
|
888
|
-
//# sourceMappingURL=client-
|
|
932
|
+
//# sourceMappingURL=client-Bi_lP_M0.js.map
|