@openrails/billing-ui 0.235.0 → 0.237.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 +155 -0
- package/README.md +103 -103
- package/dist/account/account-billing.d.ts +2 -4
- package/dist/account/payment-methods-panel.d.ts +2 -4
- package/dist/buy-button.d.ts +40 -0
- package/dist/cart.d.ts +18 -0
- package/dist/client/client.d.ts +95 -59
- package/dist/client/errors.d.ts +4 -0
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +103 -272
- package/dist/client/generated/wire.d.ts +117 -246
- package/dist/client/index.d.ts +2 -2
- package/dist/client/types.d.ts +286 -142
- package/dist/client-D9G1Tgox.js +888 -0
- package/dist/client-D9G1Tgox.js.map +1 -0
- package/dist/client.js +2 -2
- package/dist/components/eyebrow.d.ts +5 -0
- package/dist/components/stripe-card.d.ts +8 -2
- package/dist/components/stripe-wallets.d.ts +12 -0
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/embedded-checkout.d.ts +22 -0
- package/dist/hooks-DYepYVMX.js +526 -0
- package/dist/hooks-DYepYVMX.js.map +1 -0
- package/dist/i18n/context.d.ts +1 -1
- package/dist/index.d.ts +9 -11
- package/dist/index.js +1470 -2178
- package/dist/index.js.map +1 -1
- package/dist/lib/money.d.ts +1 -0
- package/dist/lib/offer-label.d.ts +4 -0
- package/dist/locales/de.js +20 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.d.ts +20 -0
- package/dist/locales/en.js +20 -0
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +20 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/ja.js +11 -0
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.js +11 -0
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/zh.js +11 -0
- package/dist/locales/zh.js.map +1 -1
- package/dist/modal.d.ts +3 -9
- package/dist/offers.d.ts +32 -0
- package/dist/order-checkout.d.ts +30 -0
- package/dist/psp.d.ts +0 -8
- package/dist/react/hooks.d.ts +8 -7
- package/dist/react/index.d.ts +1 -1
- package/dist/react/provider.d.ts +24 -2
- package/dist/react.js +2 -33
- package/dist/save-payment-method.d.ts +0 -6
- 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 -24
- package/dist/client-BpzCZes3.js +0 -931
- package/dist/client-BpzCZes3.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/config-qLcHvK0Q.js +0 -341
- package/dist/config-qLcHvK0Q.js.map +0 -1
- package/dist/fixtures.d.ts +0 -9
- package/dist/frame.d.ts +0 -47
- package/dist/lib/rail-meta.d.ts +0 -15
- package/dist/lib/redirect.d.ts +0 -2
- package/dist/provider.d.ts +0 -18
- package/dist/react.js.map +0 -1
- package/dist/source.d.ts +0 -5
package/dist/client-BpzCZes3.js
DELETED
|
@@ -1,931 +0,0 @@
|
|
|
1
|
-
import { z as e } from "zod";
|
|
2
|
-
//#region src/lib/money.ts
|
|
3
|
-
var t = -(1n << 63n), n = (1n << 63n) - 1n;
|
|
4
|
-
function r(e) {
|
|
5
|
-
if (typeof e != "string" || !/^-?\d{1,19}$/.test(e)) return null;
|
|
6
|
-
let r = BigInt(e);
|
|
7
|
-
return r < t || r > n ? null : r;
|
|
8
|
-
}
|
|
9
|
-
function i(e) {
|
|
10
|
-
return r(e) !== null;
|
|
11
|
-
}
|
|
12
|
-
function a(e) {
|
|
13
|
-
return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= 18;
|
|
14
|
-
}
|
|
15
|
-
function o(...e) {
|
|
16
|
-
let i = 0n;
|
|
17
|
-
for (let t of e) {
|
|
18
|
-
let e = r(t);
|
|
19
|
-
if (e === null) return null;
|
|
20
|
-
i += e;
|
|
21
|
-
}
|
|
22
|
-
return i < t || i > n ? null : i.toString();
|
|
23
|
-
}
|
|
24
|
-
var s = (() => {
|
|
25
|
-
try {
|
|
26
|
-
return new Intl.NumberFormat("en", { useGrouping: !1 }).format("9007199254740993") === "9007199254740993";
|
|
27
|
-
} catch {
|
|
28
|
-
return !1;
|
|
29
|
-
}
|
|
30
|
-
})(), c = 10n ** 15n;
|
|
31
|
-
function l(e, t) {
|
|
32
|
-
let n = e < 0n ? -e : e, r = 10n ** BigInt(t), i = (n % r).toString().padStart(t, "0").replace(/0+$/, "");
|
|
33
|
-
return `${e < 0n ? "-" : ""}${n / r}${i ? `.${i}` : ""}`;
|
|
34
|
-
}
|
|
35
|
-
function u(e, t) {
|
|
36
|
-
let n = r(e);
|
|
37
|
-
return n === null || !a(t) ? null : l(n, t);
|
|
38
|
-
}
|
|
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();
|
|
47
|
-
}
|
|
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);
|
|
53
|
-
try {
|
|
54
|
-
return new Intl.NumberFormat(i, {
|
|
55
|
-
style: "currency",
|
|
56
|
-
currency: o,
|
|
57
|
-
maximumFractionDigits: n
|
|
58
|
-
}).format(d);
|
|
59
|
-
} catch {
|
|
60
|
-
return `${d} ${o}`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#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) => {
|
|
66
|
-
try {
|
|
67
|
-
let t = new URL(e);
|
|
68
|
-
return t.protocol === "https:" && !t.username && !t.password;
|
|
69
|
-
} catch {
|
|
70
|
-
return !1;
|
|
71
|
-
}
|
|
72
|
-
}, "redirect URL must be HTTPS"), te = e.string().url().refine((e) => {
|
|
73
|
-
try {
|
|
74
|
-
let t = new URL(e);
|
|
75
|
-
return (t.protocol === "https:" || t.protocol === "http:") && !t.username && !t.password;
|
|
76
|
-
} catch {
|
|
77
|
-
return !1;
|
|
78
|
-
}
|
|
79
|
-
}, "return URL must be HTTP(S)"), g = e.enum([
|
|
80
|
-
"created",
|
|
81
|
-
"requires_action",
|
|
82
|
-
"processing",
|
|
83
|
-
"succeeded",
|
|
84
|
-
"failed",
|
|
85
|
-
"blocked",
|
|
86
|
-
"expired",
|
|
87
|
-
"canceled"
|
|
88
|
-
]), _ = e.object({
|
|
89
|
-
reason: e.string(),
|
|
90
|
-
message: e.string(),
|
|
91
|
-
field: e.string().nullish()
|
|
92
|
-
}), v = e.object({
|
|
93
|
-
id: e.string(),
|
|
94
|
-
status: e.string()
|
|
95
|
-
}), y = e.object({
|
|
96
|
-
id: e.string().min(1),
|
|
97
|
-
psp_id: p(e.string()),
|
|
98
|
-
rail: e.string(),
|
|
99
|
-
mode: e.enum(["one_off", "subscription"]),
|
|
100
|
-
driver: e.enum([
|
|
101
|
-
"collect_js",
|
|
102
|
-
"card",
|
|
103
|
-
"stripe_elements",
|
|
104
|
-
"redirect",
|
|
105
|
-
"solana_pay"
|
|
106
|
-
]),
|
|
107
|
-
psp_key: p(e.string()),
|
|
108
|
-
public_config: p(e.record(e.string(), e.string()))
|
|
109
|
-
}), b = e.discriminatedUnion("type", [e.object({
|
|
110
|
-
type: e.literal("redirect_to_url"),
|
|
111
|
-
url: ee
|
|
112
|
-
}), e.object({
|
|
113
|
-
type: e.literal("solana_pay"),
|
|
114
|
-
url: e.string().startsWith("solana:")
|
|
115
|
-
})]), x = e.object({
|
|
116
|
-
id: e.string(),
|
|
117
|
-
option_id: e.string(),
|
|
118
|
-
rail: e.string(),
|
|
119
|
-
card: e.object({
|
|
120
|
-
brand: e.string().nullish(),
|
|
121
|
-
last4: e.string().nullish(),
|
|
122
|
-
exp_month: e.number().nullish(),
|
|
123
|
-
exp_year: e.number().nullish()
|
|
124
|
-
}).nullish()
|
|
125
|
-
}), S = e.object({
|
|
126
|
-
label: e.string(),
|
|
127
|
-
sublabel: p(e.string()),
|
|
128
|
-
amount: m
|
|
129
|
-
}), C = e.object({
|
|
130
|
-
auto_renew: e.boolean(),
|
|
131
|
-
display_name: e.string(),
|
|
132
|
-
unit_amount: m,
|
|
133
|
-
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({
|
|
138
|
-
id: e.string(),
|
|
139
|
-
status: g,
|
|
140
|
-
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())
|
|
156
|
-
}), ne = e.object({
|
|
157
|
-
option_id: e.string(),
|
|
158
|
-
payment_token: e.string().optional(),
|
|
159
|
-
payment_method_id: e.string().optional(),
|
|
160
|
-
card: e.object({
|
|
161
|
-
number: e.string(),
|
|
162
|
-
exp_month: e.number(),
|
|
163
|
-
exp_year: e.number(),
|
|
164
|
-
cvc: e.string()
|
|
165
|
-
}).optional(),
|
|
166
|
-
billing_details: e.object({
|
|
167
|
-
name: e.string().optional(),
|
|
168
|
-
email: e.string().optional(),
|
|
169
|
-
phone: e.string().optional(),
|
|
170
|
-
address: e.object({
|
|
171
|
-
line1: e.string().optional(),
|
|
172
|
-
line2: e.string().optional(),
|
|
173
|
-
city: e.string().optional(),
|
|
174
|
-
state: e.string().optional(),
|
|
175
|
-
postal_code: e.string().optional(),
|
|
176
|
-
country: e.string().optional()
|
|
177
|
-
}).optional()
|
|
178
|
-
}).optional(),
|
|
179
|
-
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 {
|
|
189
|
-
status;
|
|
190
|
-
type;
|
|
191
|
-
code;
|
|
192
|
-
param;
|
|
193
|
-
requestId;
|
|
194
|
-
metadata;
|
|
195
|
-
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 ?? {};
|
|
197
|
-
}
|
|
198
|
-
}, D = (e) => e instanceof E, re = (e) => {
|
|
199
|
-
let t = e?.status;
|
|
200
|
-
return typeof t == "number" && t >= 500 && t < 600;
|
|
201
|
-
};
|
|
202
|
-
function O(e, t) {
|
|
203
|
-
return new E(0, {
|
|
204
|
-
type: "local",
|
|
205
|
-
code: e,
|
|
206
|
-
message: t
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
async function k(e) {
|
|
210
|
-
let t;
|
|
211
|
-
try {
|
|
212
|
-
t = await e.json();
|
|
213
|
-
} catch {
|
|
214
|
-
t = void 0;
|
|
215
|
-
}
|
|
216
|
-
let n = t?.error;
|
|
217
|
-
if (n && typeof n == "object") {
|
|
218
|
-
let t = n;
|
|
219
|
-
if (typeof t.code == "string" && t.code) return new E(e.status, {
|
|
220
|
-
type: typeof t.type == "string" ? t.type : "",
|
|
221
|
-
code: t.code,
|
|
222
|
-
message: typeof t.message == "string" ? t.message : t.code,
|
|
223
|
-
request_id: typeof t.request_id == "string" ? t.request_id : e.headers.get("X-Request-ID") ?? void 0,
|
|
224
|
-
param: typeof t.param == "string" ? t.param : void 0,
|
|
225
|
-
metadata: t.metadata && typeof t.metadata == "object" ? t.metadata : void 0
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
return new E(e.status, {
|
|
229
|
-
type: e.status >= 500 ? "api_error" : "",
|
|
230
|
-
code: typeof n == "string" && n ? n : e.status >= 500 ? "server_error" : "unknown_error",
|
|
231
|
-
message: `HTTP ${e.status}`
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
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));
|
|
236
|
-
}
|
|
237
|
-
//#endregion
|
|
238
|
-
//#region src/client/generated/currencies.ts
|
|
239
|
-
var A = {
|
|
240
|
-
AED: 6,
|
|
241
|
-
AUD: 6,
|
|
242
|
-
BRL: 6,
|
|
243
|
-
CAD: 6,
|
|
244
|
-
CHF: 6,
|
|
245
|
-
CNY: 6,
|
|
246
|
-
CZK: 6,
|
|
247
|
-
DKK: 6,
|
|
248
|
-
EUR: 6,
|
|
249
|
-
GBP: 6,
|
|
250
|
-
HKD: 6,
|
|
251
|
-
ILS: 6,
|
|
252
|
-
INR: 6,
|
|
253
|
-
JPY: 4,
|
|
254
|
-
KRW: 4,
|
|
255
|
-
MXN: 6,
|
|
256
|
-
MYR: 6,
|
|
257
|
-
NOK: 6,
|
|
258
|
-
NZD: 6,
|
|
259
|
-
PHP: 6,
|
|
260
|
-
PLN: 6,
|
|
261
|
-
PYUSD: 6,
|
|
262
|
-
SAR: 6,
|
|
263
|
-
SEK: 6,
|
|
264
|
-
SGD: 6,
|
|
265
|
-
SOL: 9,
|
|
266
|
-
THB: 6,
|
|
267
|
-
TRY: 6,
|
|
268
|
-
USD: 6,
|
|
269
|
-
USD1: 6,
|
|
270
|
-
USDC: 6,
|
|
271
|
-
USDG: 6,
|
|
272
|
-
USDT: 6,
|
|
273
|
-
ZAR: 6
|
|
274
|
-
}, j = e.object({
|
|
275
|
-
psp_id: e.string().min(1),
|
|
276
|
-
key: e.string().min(1),
|
|
277
|
-
rail: e.string(),
|
|
278
|
-
custodian: e.string(),
|
|
279
|
-
display_name: e.string(),
|
|
280
|
-
flow: e.string(),
|
|
281
|
-
config: e.record(e.string(), e.string()).nullish(),
|
|
282
|
-
checkout: e.boolean().nullish(),
|
|
283
|
-
status: e.string().nullish(),
|
|
284
|
-
retry_after: e.number().int().nullish()
|
|
285
|
-
}), ae = /* @__PURE__ */ new Set([
|
|
286
|
-
"collect_js",
|
|
287
|
-
"card",
|
|
288
|
-
"stripe_elements"
|
|
289
|
-
]), M = (e) => ae.has(e.driver), oe = (e) => e.filter((e) => e.checkout !== !1), se = /* @__PURE__ */ new Set([
|
|
290
|
-
"tokenize",
|
|
291
|
-
"card",
|
|
292
|
-
"elements"
|
|
293
|
-
]);
|
|
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);
|
|
296
|
-
return t.length > 0 ? Math.min(...t) : null;
|
|
297
|
-
}
|
|
298
|
-
function le(e, t) {
|
|
299
|
-
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));
|
|
301
|
-
return !n || e.health?.active === !1 ? [] : [{
|
|
302
|
-
id: e.id,
|
|
303
|
-
option_id: n.id,
|
|
304
|
-
rail: n.rail,
|
|
305
|
-
card: e.card ?? null
|
|
306
|
-
}];
|
|
307
|
-
});
|
|
308
|
-
}
|
|
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;
|
|
312
|
-
}
|
|
313
|
-
var fe = (e) => N(e) !== null, pe = (e) => N(e) === "stripe_elements";
|
|
314
|
-
function me(e) {
|
|
315
|
-
return {
|
|
316
|
-
psp_id: e.psp_id ?? e.id,
|
|
317
|
-
key: e.psp_key ?? e.rail,
|
|
318
|
-
rail: e.rail,
|
|
319
|
-
custodian: "psp",
|
|
320
|
-
display_name: "",
|
|
321
|
-
flow: e.driver === "stripe_elements" ? "elements" : e.driver === "card" ? "card" : "tokenize",
|
|
322
|
-
config: e.public_config ?? null
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
//#endregion
|
|
326
|
-
//#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({
|
|
328
|
-
data: e.array(t).nullish().transform((e) => e ?? []),
|
|
329
|
-
total: e.number().nullish(),
|
|
330
|
-
limit: e.number().nullish(),
|
|
331
|
-
offset: e.number().nullish(),
|
|
332
|
-
has_more: e.boolean().nullish(),
|
|
333
|
-
next_cursor: e.string().nullish()
|
|
334
|
-
}), I = (t) => e.object({
|
|
335
|
-
data: e.array(t).nullish().transform((e) => e ?? []),
|
|
336
|
-
next_cursor: e.string().nullish().transform((e) => e ?? null)
|
|
337
|
-
}), L = e.string(), R = e.object({
|
|
338
|
-
status: e.string(),
|
|
339
|
-
ids: e.record(e.string(), e.string()).nullish(),
|
|
340
|
-
sync_status: e.string().nullish()
|
|
341
|
-
}), z = e.object({
|
|
342
|
-
id: e.string(),
|
|
343
|
-
key: e.string(),
|
|
344
|
-
revision: e.number().int().nonnegative().optional(),
|
|
345
|
-
version: e.number().int().nonnegative().optional(),
|
|
346
|
-
product_id: e.string(),
|
|
347
|
-
archived: e.boolean(),
|
|
348
|
-
unit_amount: P,
|
|
349
|
-
customer_amount: e.object({
|
|
350
|
-
min_amount: P,
|
|
351
|
-
max_amount: P
|
|
352
|
-
}).nullish(),
|
|
353
|
-
currency: e.string(),
|
|
354
|
-
access_duration_hours: e.number().nullable(),
|
|
355
|
-
billing_interval_hours: e.number().nullable(),
|
|
356
|
-
trial_unit_amount: P.nullable(),
|
|
357
|
-
trial_duration_hours: e.number().nullable(),
|
|
358
|
-
psps: e.record(e.string(), R).nullish(),
|
|
359
|
-
created_at: F,
|
|
360
|
-
updated_at: F
|
|
361
|
-
}), B = e.object({
|
|
362
|
-
id: e.string(),
|
|
363
|
-
key: e.string().nullish(),
|
|
364
|
-
revision: e.number().int().nonnegative().optional(),
|
|
365
|
-
display_name: e.string().nullish(),
|
|
366
|
-
description: e.string().nullish(),
|
|
367
|
-
tier_group: e.string().nullish(),
|
|
368
|
-
tier_rank: e.number().nullish()
|
|
369
|
-
}), V = e.object({
|
|
370
|
-
brand: e.string().nullish(),
|
|
371
|
-
last4: e.string().nullish(),
|
|
372
|
-
exp_month: e.number().nullish(),
|
|
373
|
-
exp_year: e.number().nullish()
|
|
374
|
-
}), ge = e.object({
|
|
375
|
-
id: e.string(),
|
|
376
|
-
status: e.string()
|
|
377
|
-
}), H = e.object({
|
|
378
|
-
last_failure_reason: e.string().nullish(),
|
|
379
|
-
retryable: e.boolean(),
|
|
380
|
-
blocked_reason: e.string().nullish(),
|
|
381
|
-
operation: ge.nullish()
|
|
382
|
-
}), U = e.object({
|
|
383
|
-
type: e.string(),
|
|
384
|
-
redirect_to_url: e.object({ url: e.string().nullish() }).nullish(),
|
|
385
|
-
transactions: e.array(e.string()).nullish()
|
|
386
|
-
}), _e = e.object({
|
|
387
|
-
attempts: e.number(),
|
|
388
|
-
retries_left: e.number().nullish(),
|
|
389
|
-
next_retry_at: F.nullish(),
|
|
390
|
-
final_retry_at: F.nullish(),
|
|
391
|
-
waiting_for_new_card: e.boolean(),
|
|
392
|
-
last_failure_reason: e.string().nullish()
|
|
393
|
-
}), W = e.object({
|
|
394
|
-
id: e.string(),
|
|
395
|
-
status: L,
|
|
396
|
-
rail: e.string().nullish(),
|
|
397
|
-
product_id: e.string().nullish(),
|
|
398
|
-
price_id: e.string().nullish(),
|
|
399
|
-
quantity: e.number().nullish(),
|
|
400
|
-
psp_id: e.string().nullish(),
|
|
401
|
-
collection_policy: e.string().nullish(),
|
|
402
|
-
payment_method_id: e.string().nullish(),
|
|
403
|
-
started_at: F.nullish(),
|
|
404
|
-
ended_at: F.nullish(),
|
|
405
|
-
current_period_starts_at: F.nullish(),
|
|
406
|
-
current_period_ends_at: F.nullish(),
|
|
407
|
-
canceled_at: F.nullish(),
|
|
408
|
-
cancel_type: e.string().nullish(),
|
|
409
|
-
resumable: e.boolean().nullish(),
|
|
410
|
-
cancel_scheduled: e.boolean().nullish(),
|
|
411
|
-
cancel_mode: e.string().nullish(),
|
|
412
|
-
cancel_portal_url: e.string().nullish(),
|
|
413
|
-
access: e.object({
|
|
414
|
-
starts_at: F,
|
|
415
|
-
ends_at: F.nullish()
|
|
416
|
-
}).nullish(),
|
|
417
|
-
dunning: _e.nullish(),
|
|
418
|
-
price: z.nullish(),
|
|
419
|
-
product: B.nullish(),
|
|
420
|
-
scheduled_change: e.object({
|
|
421
|
-
price_id: e.string(),
|
|
422
|
-
quantity: e.number().nullish(),
|
|
423
|
-
effective_at: F,
|
|
424
|
-
source: e.string(),
|
|
425
|
-
price: z.nullish(),
|
|
426
|
-
product: B.nullish()
|
|
427
|
-
}).nullish(),
|
|
428
|
-
card: V.nullish(),
|
|
429
|
-
recovery: H.nullish(),
|
|
430
|
-
next_action: U.nullish(),
|
|
431
|
-
created_at: F.nullish(),
|
|
432
|
-
updated_at: F.nullish()
|
|
433
|
-
}), ve = e.object({
|
|
434
|
-
name: e.string().nullish(),
|
|
435
|
-
email: e.string().nullish(),
|
|
436
|
-
phone: e.string().nullish(),
|
|
437
|
-
address: e.object({
|
|
438
|
-
line1: e.string().nullish(),
|
|
439
|
-
line2: e.string().nullish(),
|
|
440
|
-
city: e.string().nullish(),
|
|
441
|
-
state: e.string().nullish(),
|
|
442
|
-
postal_code: e.string().nullish(),
|
|
443
|
-
country: e.string().nullish()
|
|
444
|
-
}).nullish()
|
|
445
|
-
}), G = e.object({
|
|
446
|
-
id: e.string(),
|
|
447
|
-
rail: e.string().nullish(),
|
|
448
|
-
psp_id: e.string().nullish(),
|
|
449
|
-
card: V.nullish(),
|
|
450
|
-
billing_details: ve.nullish(),
|
|
451
|
-
health: e.object({
|
|
452
|
-
expiry_status: e.string().nullish(),
|
|
453
|
-
last_charged_at: F.nullish(),
|
|
454
|
-
last_charge_outcome: e.string().nullish(),
|
|
455
|
-
active: e.boolean().nullish()
|
|
456
|
-
}).nullish(),
|
|
457
|
-
subscriptions: e.array(e.object({
|
|
458
|
-
id: e.string(),
|
|
459
|
-
display_name: e.string().nullish()
|
|
460
|
-
})).nullish(),
|
|
461
|
-
default_currencies: e.array(e.string()).nullish(),
|
|
462
|
-
created_at: F.nullish()
|
|
463
|
-
}), ye = e.object({
|
|
464
|
-
id: e.string(),
|
|
465
|
-
key: e.string(),
|
|
466
|
-
revision: e.number().int().nonnegative().optional(),
|
|
467
|
-
display_name: e.string(),
|
|
468
|
-
description: e.string(),
|
|
469
|
-
entitlements: e.array(e.string()),
|
|
470
|
-
credit_grant: e.object({
|
|
471
|
-
currency: e.string(),
|
|
472
|
-
amount: P.nullish(),
|
|
473
|
-
from_payment: e.boolean().optional(),
|
|
474
|
-
expires_after_days: e.number().int().positive().nullish()
|
|
475
|
-
}).nullish(),
|
|
476
|
-
tier_group: e.string().nullable(),
|
|
477
|
-
tier_rank: e.number(),
|
|
478
|
-
archived: e.boolean(),
|
|
479
|
-
prices: e.array(z).nullish().transform((e) => e ?? []),
|
|
480
|
-
created_at: F,
|
|
481
|
-
updated_at: F
|
|
482
|
-
}), be = e.object({
|
|
483
|
-
id: e.string(),
|
|
484
|
-
kind: e.string(),
|
|
485
|
-
status: e.string(),
|
|
486
|
-
amount: P,
|
|
487
|
-
amount_refunded: P.nullish(),
|
|
488
|
-
currency: e.string(),
|
|
489
|
-
subscription_id: e.string().nullish(),
|
|
490
|
-
price_id: e.string().nullish(),
|
|
491
|
-
channel: e.string().nullish(),
|
|
492
|
-
rail: e.string().nullish(),
|
|
493
|
-
created_at: F,
|
|
494
|
-
price: z.nullish(),
|
|
495
|
-
product: B.nullish(),
|
|
496
|
-
card: V.nullish(),
|
|
497
|
-
failure: e.object({
|
|
498
|
-
reason: e.string(),
|
|
499
|
-
message: e.string(),
|
|
500
|
-
field: e.string().nullish()
|
|
501
|
-
}).nullish()
|
|
502
|
-
}), xe = e.object({
|
|
503
|
-
currency: e.string(),
|
|
504
|
-
billing_mode: e.string(),
|
|
505
|
-
balance_amount: P,
|
|
506
|
-
held_amount: P,
|
|
507
|
-
available_amount: P,
|
|
508
|
-
owed_amount: P
|
|
509
|
-
}), Se = e.object({
|
|
510
|
-
id: e.string(),
|
|
511
|
-
balances: e.array(xe),
|
|
512
|
-
default_payment_methods: e.array(e.object({
|
|
513
|
-
currency: e.string(),
|
|
514
|
-
payment_method_id: e.string()
|
|
515
|
-
})),
|
|
516
|
-
unread_notifications: e.number()
|
|
517
|
-
}), K = e.object({
|
|
518
|
-
id: e.string(),
|
|
519
|
-
currency: e.string(),
|
|
520
|
-
invoice_number: e.string().nullish(),
|
|
521
|
-
period_starts_at: F,
|
|
522
|
-
period_ends_at: F,
|
|
523
|
-
total_amount: P,
|
|
524
|
-
amount_paid: P,
|
|
525
|
-
amount_due: P,
|
|
526
|
-
status: e.string(),
|
|
527
|
-
issued_at: F.nullish(),
|
|
528
|
-
due_at: F.nullish(),
|
|
529
|
-
delinquent: e.boolean().nullish(),
|
|
530
|
-
paid_at: F.nullish(),
|
|
531
|
-
recovery: H.nullish(),
|
|
532
|
-
created_at: F
|
|
533
|
-
}), Ce = e.object({
|
|
534
|
-
code: e.string(),
|
|
535
|
-
decimals: e.number(),
|
|
536
|
-
minor_decimals: e.number().nullish()
|
|
537
|
-
}), we = e.object({
|
|
538
|
-
price_id: e.string(),
|
|
539
|
-
quantity: e.number().nullish(),
|
|
540
|
-
rail: e.string().nullish(),
|
|
541
|
-
currency: e.string(),
|
|
542
|
-
amount_due_now: P,
|
|
543
|
-
next_charge_amount: P,
|
|
544
|
-
next_charge_date: F.nullish(),
|
|
545
|
-
effective: e.string(),
|
|
546
|
-
is_estimate: e.boolean().nullish(),
|
|
547
|
-
message: e.string().nullish()
|
|
548
|
-
}), Te = e.object({
|
|
549
|
-
status: e.string(),
|
|
550
|
-
effective: e.string().nullish(),
|
|
551
|
-
price_id: e.string().nullish(),
|
|
552
|
-
quantity: e.number().nullish(),
|
|
553
|
-
subscription_id: e.string().nullish(),
|
|
554
|
-
next_action: U.nullish(),
|
|
555
|
-
delayed_start: F.nullish(),
|
|
556
|
-
currency: e.string().nullish(),
|
|
557
|
-
amount_due_now: P.nullish(),
|
|
558
|
-
next_charge_amount: P.nullish(),
|
|
559
|
-
next_charge_date: F.nullish(),
|
|
560
|
-
message: e.string().nullish(),
|
|
561
|
-
operation_id: e.string().nullish()
|
|
562
|
-
}), q = e.string().regex(/^\d+$/, "units must be a uint64 string"), Ee = e.object({
|
|
563
|
-
symbol: e.string(),
|
|
564
|
-
name: e.string().nullish(),
|
|
565
|
-
mint: e.string(),
|
|
566
|
-
decimals: e.number(),
|
|
567
|
-
price: e.string().nullish(),
|
|
568
|
-
preferred: e.boolean().nullish(),
|
|
569
|
-
recurring_eligible: e.boolean().nullish(),
|
|
570
|
-
quote: e.object({
|
|
571
|
-
amount: e.string(),
|
|
572
|
-
units: q,
|
|
573
|
-
token_price_usd: e.string().nullish(),
|
|
574
|
-
fx_rate: e.string().nullish(),
|
|
575
|
-
fx_currency: e.string().nullish(),
|
|
576
|
-
quoted_at: F.nullish(),
|
|
577
|
-
expires_at: F.nullish()
|
|
578
|
-
}).nullish(),
|
|
579
|
-
balance: e.object({
|
|
580
|
-
amount: e.string(),
|
|
581
|
-
units: q,
|
|
582
|
-
sufficient: e.boolean().nullish()
|
|
583
|
-
}).nullish()
|
|
584
|
-
}), De = e.object({ tokens: e.array(Ee).nullish().transform((e) => e ?? []) }), Oe = e.object({
|
|
585
|
-
psps: e.array(j).nullish().transform((e) => e ?? []),
|
|
586
|
-
solana: e.object({
|
|
587
|
-
network: e.string(),
|
|
588
|
-
chain: e.string(),
|
|
589
|
-
preferred_token: e.string().nullish(),
|
|
590
|
-
tokens: e.array(e.object({
|
|
591
|
-
symbol: e.string(),
|
|
592
|
-
name: e.string().nullish(),
|
|
593
|
-
mint: e.string(),
|
|
594
|
-
decimals: e.number().int(),
|
|
595
|
-
preferred: e.boolean().nullish(),
|
|
596
|
-
recurring_eligible: e.boolean().nullish()
|
|
597
|
-
})).nullish().transform((e) => e ?? [])
|
|
598
|
-
}).nullish()
|
|
599
|
-
}), ke = e.object({
|
|
600
|
-
provider: e.string(),
|
|
601
|
-
site_key: e.string(),
|
|
602
|
-
script_url: e.string(),
|
|
603
|
-
action: e.string(),
|
|
604
|
-
token_header: e.string()
|
|
605
|
-
}), Ae = e.object({
|
|
606
|
-
capabilities: e.object({
|
|
607
|
-
route_groups: e.record(e.string(), e.boolean()),
|
|
608
|
-
features: e.record(e.string(), e.boolean())
|
|
609
|
-
}),
|
|
610
|
-
currencies: e.array(Ce).nullish().transform((e) => e ?? []),
|
|
611
|
-
payment: Oe.nullish(),
|
|
612
|
-
captcha: ke.nullish()
|
|
613
|
-
}), J = e.object({
|
|
614
|
-
id: e.string(),
|
|
615
|
-
status: e.string(),
|
|
616
|
-
client_secret: e.string().nullish(),
|
|
617
|
-
payment_method_id: e.string().nullish()
|
|
618
|
-
}), je = e.object({ client_secret: e.string().nullish() }), Y = e.object({
|
|
619
|
-
id: e.string().startsWith("ocs_"),
|
|
620
|
-
url: e.string().url().nullish(),
|
|
621
|
-
expires_at: F
|
|
622
|
-
}), X = class extends Error {
|
|
623
|
-
constructor(e = "The wallet request was declined.") {
|
|
624
|
-
super(e), this.name = "WalletRejectedError";
|
|
625
|
-
}
|
|
626
|
-
}, Me = 4, Ne = 500, Pe = (e) => e?.type === "solana_sign_transactions" && !!e.transactions?.length;
|
|
627
|
-
async function Fe(e, t) {
|
|
628
|
-
let n = "";
|
|
629
|
-
for (let r of e.transactions ?? []) {
|
|
630
|
-
try {
|
|
631
|
-
n = await t(r);
|
|
632
|
-
} catch (e) {
|
|
633
|
-
throw $(e) ? O("wallet_rejected", "The wallet request was declined.") : e;
|
|
634
|
-
}
|
|
635
|
-
if (!n) throw O("wallet_no_signature", "The wallet returned no signature.");
|
|
636
|
-
}
|
|
637
|
-
if (!n) throw O("wallet_no_signature", "The wallet returned no signature.");
|
|
638
|
-
return n;
|
|
639
|
-
}
|
|
640
|
-
var Ie = 2e3, Z = 300;
|
|
641
|
-
function Le(e) {
|
|
642
|
-
let t = Re(e.headers.get("Retry-After"));
|
|
643
|
-
switch (e.status) {
|
|
644
|
-
case 429: return t;
|
|
645
|
-
case 503: return t ?? Z;
|
|
646
|
-
case 502:
|
|
647
|
-
case 504: return Z;
|
|
648
|
-
default: return null;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
function Re(e) {
|
|
652
|
-
if (!e) return null;
|
|
653
|
-
if (/^\d+$/.test(e.trim())) return Number(e.trim()) * 1e3;
|
|
654
|
-
let t = Date.parse(e);
|
|
655
|
-
return Number.isNaN(t) ? null : Math.max(0, t - Date.now());
|
|
656
|
-
}
|
|
657
|
-
function Q(e, t) {
|
|
658
|
-
return new Promise((n, r) => {
|
|
659
|
-
if (t?.aborted) return r(t.reason);
|
|
660
|
-
let i = setTimeout(() => {
|
|
661
|
-
t?.removeEventListener("abort", a), n(e);
|
|
662
|
-
}, e), a = () => {
|
|
663
|
-
clearTimeout(i), r(t?.reason);
|
|
664
|
-
};
|
|
665
|
-
t?.addEventListener("abort", a, { once: !0 });
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
function ze(e = {}) {
|
|
669
|
-
let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), n = e.fetch ?? ((e, t) => fetch(e, t)), r = Be({
|
|
670
|
-
...A,
|
|
671
|
-
...e.currencies
|
|
672
|
-
});
|
|
673
|
-
function i(e, n, r = t) {
|
|
674
|
-
let i = new URLSearchParams();
|
|
675
|
-
for (let [e, t] of Object.entries(n ?? {})) t !== void 0 && t !== "" && i.set(e, String(t));
|
|
676
|
-
let a = i.toString();
|
|
677
|
-
return `${r}${e}${a ? `?${a}` : ""}`;
|
|
678
|
-
}
|
|
679
|
-
async function a(t, r = {}) {
|
|
680
|
-
let a = new Headers({
|
|
681
|
-
Accept: "application/json",
|
|
682
|
-
...r.headers
|
|
683
|
-
});
|
|
684
|
-
r.body !== void 0 && a.set("Content-Type", "application/json");
|
|
685
|
-
let o = r.anonymous ? void 0 : await e.getToken?.();
|
|
686
|
-
o && a.set("Authorization", `Bearer ${o}`);
|
|
687
|
-
let s = e.language?.();
|
|
688
|
-
s && a.set("Accept-Language", s);
|
|
689
|
-
let c = r.method ?? "GET", l = {
|
|
690
|
-
method: c,
|
|
691
|
-
headers: a,
|
|
692
|
-
body: r.body === void 0 ? void 0 : JSON.stringify(r.body),
|
|
693
|
-
signal: r.signal
|
|
694
|
-
}, u = +(c === "GET"), d = 0;
|
|
695
|
-
for (let e = 0;; e++) {
|
|
696
|
-
let a;
|
|
697
|
-
try {
|
|
698
|
-
a = await n(i(t, r.query, r.root), l);
|
|
699
|
-
} catch (t) {
|
|
700
|
-
let n = Z;
|
|
701
|
-
if (e >= u || r.signal?.aborted || !(t instanceof TypeError) || d + n > 2e3) throw t;
|
|
702
|
-
d += await Q(n, r.signal);
|
|
703
|
-
continue;
|
|
704
|
-
}
|
|
705
|
-
if (a.ok) return a;
|
|
706
|
-
let o = Le(a);
|
|
707
|
-
if (e >= u || o === null || d + o > 2e3) throw await k(a);
|
|
708
|
-
await a.body?.cancel().catch(() => void 0), d += await Q(o, r.signal);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
async function o(e, t, n) {
|
|
712
|
-
let r = await a(t, n), i;
|
|
713
|
-
try {
|
|
714
|
-
i = await r.json();
|
|
715
|
-
} catch {
|
|
716
|
-
throw O("invalid_response", `${t}: body is not JSON`);
|
|
717
|
-
}
|
|
718
|
-
let o = e.safeParse(i);
|
|
719
|
-
if (!o.success) throw O("invalid_response", `${t}: ${o.error.issues[0]?.path.join(".")} ${o.error.issues[0]?.message}`);
|
|
720
|
-
return o.data;
|
|
721
|
-
}
|
|
722
|
-
let s = (e) => encodeURIComponent(e), c = I(W), l = I(G), u = I(be), d = I(K), f = (e, t) => ({
|
|
723
|
-
limit: e.limit ?? t,
|
|
724
|
-
cursor: e.cursor ?? void 0
|
|
725
|
-
}), p = he(ye);
|
|
726
|
-
return {
|
|
727
|
-
baseUrl: t,
|
|
728
|
-
listSubscriptions(e = {}) {
|
|
729
|
-
return o(c, "/me/subscriptions", {
|
|
730
|
-
query: {
|
|
731
|
-
status: e.status ?? "all",
|
|
732
|
-
...f(e, 100)
|
|
733
|
-
},
|
|
734
|
-
signal: e.signal
|
|
735
|
-
});
|
|
736
|
-
},
|
|
737
|
-
getSubscription(e, t) {
|
|
738
|
-
return o(W, `/me/subscriptions/${s(e)}`, { signal: t });
|
|
739
|
-
},
|
|
740
|
-
cancelSubscription(e, t) {
|
|
741
|
-
return o(W, `/me/subscriptions/${s(e)}/cancel`, {
|
|
742
|
-
method: "POST",
|
|
743
|
-
body: {
|
|
744
|
-
reason: t.reason.trim(),
|
|
745
|
-
signature: t.signature
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
},
|
|
749
|
-
resumeSubscription(e) {
|
|
750
|
-
return o(W, `/me/subscriptions/${s(e)}/resume`, {
|
|
751
|
-
method: "POST",
|
|
752
|
-
body: {}
|
|
753
|
-
});
|
|
754
|
-
},
|
|
755
|
-
setSubscriptionPaymentMethod(e, t) {
|
|
756
|
-
return o(W, `/me/subscriptions/${s(e)}/payment-method`, {
|
|
757
|
-
method: "PUT",
|
|
758
|
-
body: { payment_method_id: t }
|
|
759
|
-
});
|
|
760
|
-
},
|
|
761
|
-
previewSubscriptionChange(e, t, n) {
|
|
762
|
-
return o(we, `/me/subscriptions/${s(e)}/change/preview`, {
|
|
763
|
-
method: "POST",
|
|
764
|
-
body: {
|
|
765
|
-
price_id: t.priceId,
|
|
766
|
-
quantity: t.quantity
|
|
767
|
-
},
|
|
768
|
-
signal: n
|
|
769
|
-
});
|
|
770
|
-
},
|
|
771
|
-
changeSubscription(e, t) {
|
|
772
|
-
return o(Te, `/me/subscriptions/${s(e)}/change`, {
|
|
773
|
-
method: "POST",
|
|
774
|
-
body: {
|
|
775
|
-
price_id: t.priceId,
|
|
776
|
-
quantity: t.quantity,
|
|
777
|
-
signature: t.signature
|
|
778
|
-
},
|
|
779
|
-
headers: { "Idempotency-Key": t.idempotencyKey }
|
|
780
|
-
});
|
|
781
|
-
},
|
|
782
|
-
listPaymentMethods(e = {}) {
|
|
783
|
-
return o(l, "/me/payment-methods", {
|
|
784
|
-
query: f(e, 100),
|
|
785
|
-
signal: e.signal
|
|
786
|
-
});
|
|
787
|
-
},
|
|
788
|
-
addPaymentMethod(e) {
|
|
789
|
-
return o(G, "/me/payment-methods", {
|
|
790
|
-
method: "POST",
|
|
791
|
-
body: e
|
|
792
|
-
});
|
|
793
|
-
},
|
|
794
|
-
createCardSetup(e) {
|
|
795
|
-
return o(J, "/me/payment-method-setups", {
|
|
796
|
-
method: "POST",
|
|
797
|
-
body: {
|
|
798
|
-
psp_id: e.pspId,
|
|
799
|
-
consent: !0
|
|
800
|
-
},
|
|
801
|
-
headers: { "Idempotency-Key": e.idempotencyKey }
|
|
802
|
-
});
|
|
803
|
-
},
|
|
804
|
-
getCardSetup(e, t) {
|
|
805
|
-
return o(J, `/me/payment-method-setups/${s(e)}`, { signal: t });
|
|
806
|
-
},
|
|
807
|
-
confirmCardSetup(e) {
|
|
808
|
-
return o(J, `/me/payment-method-setups/${s(e)}/confirm`, {
|
|
809
|
-
method: "POST",
|
|
810
|
-
body: {}
|
|
811
|
-
});
|
|
812
|
-
},
|
|
813
|
-
getPaymentAuthentication(e) {
|
|
814
|
-
return o(je, `/me/payment-operations/${s(e)}/authentication`);
|
|
815
|
-
},
|
|
816
|
-
async confirmPaymentAuthentication(e) {
|
|
817
|
-
await a(`/me/payment-operations/${s(e)}/authentication/confirm`, {
|
|
818
|
-
method: "POST",
|
|
819
|
-
body: {}
|
|
820
|
-
});
|
|
821
|
-
},
|
|
822
|
-
async removePaymentMethod(e) {
|
|
823
|
-
return (await a(`/me/payment-methods/${s(e)}`, { method: "DELETE" })).status === 202 ? "pending" : "removed";
|
|
824
|
-
},
|
|
825
|
-
async setDefaultPaymentMethod(e) {
|
|
826
|
-
await a(`/me/default-payment-methods/${s(e.currency.toUpperCase())}`, {
|
|
827
|
-
method: "PUT",
|
|
828
|
-
body: { payment_method_id: e.paymentMethodId }
|
|
829
|
-
});
|
|
830
|
-
},
|
|
831
|
-
listPayments(e = {}) {
|
|
832
|
-
return o(u, "/me/payments", {
|
|
833
|
-
query: {
|
|
834
|
-
...f(e, 20),
|
|
835
|
-
rail: e.rail
|
|
836
|
-
},
|
|
837
|
-
signal: e.signal
|
|
838
|
-
});
|
|
839
|
-
},
|
|
840
|
-
listInvoices(e = {}) {
|
|
841
|
-
return o(d, "/me/invoices", {
|
|
842
|
-
query: f(e, 20),
|
|
843
|
-
signal: e.signal
|
|
844
|
-
});
|
|
845
|
-
},
|
|
846
|
-
getAccount(e) {
|
|
847
|
-
return o(Se, "/me", { signal: e });
|
|
848
|
-
},
|
|
849
|
-
getInvoice(e, t) {
|
|
850
|
-
return o(K, `/me/invoices/${s(e)}`, { signal: t });
|
|
851
|
-
},
|
|
852
|
-
listProducts(e = {}) {
|
|
853
|
-
return o(p, "/catalog/products", {
|
|
854
|
-
query: {
|
|
855
|
-
limit: e.limit ?? 100,
|
|
856
|
-
cursor: e.cursor
|
|
857
|
-
},
|
|
858
|
-
signal: e.signal
|
|
859
|
-
});
|
|
860
|
-
},
|
|
861
|
-
createCheckoutSession(e) {
|
|
862
|
-
return !e.priceKey == !e.priceId || !!e.priceKey != !!e.productKey ? Promise.reject(O("invalid_request", "Pass priceId, or both productKey and priceKey.")) : o(Y, "/me/checkout-sessions", {
|
|
863
|
-
method: "POST",
|
|
864
|
-
body: {
|
|
865
|
-
price_key: e.priceKey,
|
|
866
|
-
product_key: e.productKey,
|
|
867
|
-
price_id: e.priceId,
|
|
868
|
-
auto_renew: e.autoRenew,
|
|
869
|
-
amount: e.amount,
|
|
870
|
-
success_url: e.successUrl
|
|
871
|
-
}
|
|
872
|
-
});
|
|
873
|
-
},
|
|
874
|
-
checkoutSource(e, t = {}) {
|
|
875
|
-
let n = `/checkout-sessions/${s(e)}`, r = t.customerBase?.replace(/\/+$/, ""), i = r === void 0 ? { anonymous: !0 } : { root: r };
|
|
876
|
-
return {
|
|
877
|
-
getSession: () => o(w, n, i),
|
|
878
|
-
async pay(e) {
|
|
879
|
-
try {
|
|
880
|
-
return await o(T, `${n}/pay`, {
|
|
881
|
-
...i,
|
|
882
|
-
method: "POST",
|
|
883
|
-
body: e
|
|
884
|
-
});
|
|
885
|
-
} catch (e) {
|
|
886
|
-
if (!D(e)) throw e;
|
|
887
|
-
switch (e.status) {
|
|
888
|
-
case 404:
|
|
889
|
-
case 410: return { status: "expired" };
|
|
890
|
-
case 403: return {
|
|
891
|
-
status: "blocked",
|
|
892
|
-
failure_message: e.message
|
|
893
|
-
};
|
|
894
|
-
case 422:
|
|
895
|
-
case 429: return {
|
|
896
|
-
status: "failed",
|
|
897
|
-
failure_message: e.message
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
throw e;
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
},
|
|
905
|
-
getConfig(e) {
|
|
906
|
-
return o(Ae, "/config", {
|
|
907
|
-
signal: e,
|
|
908
|
-
anonymous: !0
|
|
909
|
-
});
|
|
910
|
-
},
|
|
911
|
-
async listSolanaTokens(e = {}) {
|
|
912
|
-
let { tokens: t } = await o(De, "/solana/tokens", {
|
|
913
|
-
query: {
|
|
914
|
-
price_id: e.priceId,
|
|
915
|
-
wallet: e.wallet
|
|
916
|
-
},
|
|
917
|
-
signal: e.signal
|
|
918
|
-
});
|
|
919
|
-
return t;
|
|
920
|
-
},
|
|
921
|
-
currencies: r
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
function Be(e) {
|
|
925
|
-
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e.toUpperCase(), t]));
|
|
926
|
-
}
|
|
927
|
-
var $ = (e) => e instanceof X || e instanceof Error && e.name === "WalletRejectedError" || e instanceof E && e.code === "wallet_rejected";
|
|
928
|
-
//#endregion
|
|
929
|
-
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 _, ze as a, re as b, Fe as c, ce as d, N as f, me as g, j as h, X as i, T as j, b as k, pe as l, M as m, Me as n, Pe as o, oe as p, Ie 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 };
|
|
930
|
-
|
|
931
|
-
//# sourceMappingURL=client-BpzCZes3.js.map
|