@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.
- package/CHANGELOG.md +142 -2
- package/README.md +119 -85
- package/dist/account/account-billing.d.ts +6 -5
- package/dist/account/change-card-dialog.d.ts +5 -2
- package/dist/account/payment-methods-panel.d.ts +6 -5
- package/dist/buy-button.d.ts +35 -0
- package/dist/cart.d.ts +18 -0
- package/dist/checkout.d.ts +1 -3
- package/dist/client/checkout.d.ts +28 -0
- package/dist/client/client.d.ts +98 -63
- package/dist/client/errors.d.ts +5 -4
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +142 -99
- package/dist/client/generated/wire.d.ts +185 -98
- package/dist/client/index.d.ts +2 -2
- package/dist/client/types.d.ts +272 -29
- package/dist/{client-CWX6QpLa.js → client-BuvolBPT.js} +498 -326
- package/dist/client-BuvolBPT.js.map +1 -0
- package/dist/client.js +2 -2
- 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/frame.d.ts +5 -5
- package/dist/hooks-2d-XjpuI.js +526 -0
- package/dist/hooks-2d-XjpuI.js.map +1 -0
- package/dist/i18n/context.d.ts +1 -1
- package/dist/i18n/messages.d.ts +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1985 -1667
- 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 +25 -4
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.d.ts +25 -4
- package/dist/locales/en.js +25 -4
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +25 -4
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/ja.js +16 -4
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.js +16 -4
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/zh.js +16 -4
- package/dist/locales/zh.js.map +1 -1
- package/dist/offers.d.ts +33 -0
- package/dist/order-checkout.d.ts +30 -0
- package/dist/react/context.d.ts +6 -5
- package/dist/react/hooks.d.ts +17 -16
- 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/types.d.ts +16 -16
- package/docs/payment-form-contract.md +6 -6
- package/package.json +2 -2
- package/dist/client-CWX6QpLa.js.map +0 -1
- package/dist/config-DZ97SQG2.js +0 -341
- package/dist/config-DZ97SQG2.js.map +0 -1
- package/dist/provider.d.ts +0 -18
- package/dist/react.js.map +0 -1
|
@@ -1,68 +1,87 @@
|
|
|
1
1
|
import { z as e } from "zod";
|
|
2
|
-
//#region src/
|
|
3
|
-
var t =
|
|
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
|
|
7
|
-
return
|
|
17
|
+
let t = BigInt(e);
|
|
18
|
+
return t < i || t > a ? null : t;
|
|
8
19
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
20
|
+
function s(e) {
|
|
21
|
+
return o(e) !== null;
|
|
11
22
|
}
|
|
12
|
-
function
|
|
23
|
+
function c(e) {
|
|
13
24
|
return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= 18;
|
|
14
25
|
}
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
for (let
|
|
18
|
-
let e =
|
|
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
|
-
|
|
31
|
+
t += e;
|
|
21
32
|
}
|
|
22
|
-
return
|
|
33
|
+
return t < i || t > a ? null : t.toString();
|
|
23
34
|
}
|
|
24
|
-
var
|
|
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
|
-
})(),
|
|
31
|
-
function
|
|
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
|
|
36
|
-
let n =
|
|
37
|
-
return n === null || !
|
|
46
|
+
function p(e, t) {
|
|
47
|
+
let n = o(e);
|
|
48
|
+
return n === null || !c(t) ? null : f(n, t);
|
|
38
49
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!
|
|
52
|
-
let
|
|
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(
|
|
73
|
+
return new Intl.NumberFormat(r, {
|
|
55
74
|
style: "currency",
|
|
56
|
-
currency:
|
|
75
|
+
currency: i,
|
|
57
76
|
maximumFractionDigits: n
|
|
58
|
-
}).format(
|
|
77
|
+
}).format(s);
|
|
59
78
|
} catch {
|
|
60
|
-
return `${
|
|
79
|
+
return `${s} ${i}`;
|
|
61
80
|
}
|
|
62
81
|
}
|
|
63
82
|
//#endregion
|
|
64
83
|
//#region src/types.ts
|
|
65
|
-
var
|
|
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)"),
|
|
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
|
-
]),
|
|
107
|
+
]), x = e.object({
|
|
89
108
|
reason: e.string(),
|
|
90
109
|
message: e.string(),
|
|
91
110
|
field: e.string().nullish()
|
|
92
|
-
}),
|
|
111
|
+
}), S = e.object({
|
|
93
112
|
id: e.string(),
|
|
94
113
|
status: e.string()
|
|
95
|
-
}),
|
|
114
|
+
}), C = e.object({
|
|
96
115
|
id: e.string().min(1),
|
|
97
|
-
psp_id:
|
|
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:
|
|
108
|
-
public_config:
|
|
109
|
-
}),
|
|
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
|
-
})]),
|
|
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
|
-
}),
|
|
144
|
+
}), E = e.object({
|
|
126
145
|
label: e.string(),
|
|
127
|
-
sublabel:
|
|
128
|
-
amount:
|
|
129
|
-
}),
|
|
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:
|
|
151
|
+
unit_amount: v,
|
|
133
152
|
currency: e.string().min(1),
|
|
134
|
-
unit_decimals:
|
|
135
|
-
billing_interval_hours:
|
|
136
|
-
access_duration_hours:
|
|
137
|
-
}),
|
|
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:
|
|
158
|
+
status: b,
|
|
140
159
|
merchant: e.object({ display_name: e.string() }),
|
|
141
|
-
plan:
|
|
142
|
-
line_items:
|
|
143
|
-
tax:
|
|
144
|
-
due_today:
|
|
145
|
-
options: e.array(
|
|
146
|
-
saved_methods:
|
|
147
|
-
next_action:
|
|
148
|
-
payment_id:
|
|
149
|
-
subscription_id:
|
|
150
|
-
failure_message:
|
|
151
|
-
failure:
|
|
152
|
-
operation:
|
|
153
|
-
success_url:
|
|
154
|
-
embed_origin:
|
|
155
|
-
expires_at:
|
|
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
|
-
}),
|
|
181
|
-
status:
|
|
182
|
-
next_action:
|
|
183
|
-
operation:
|
|
184
|
-
payment_id:
|
|
185
|
-
subscription_id:
|
|
186
|
-
failure_message:
|
|
187
|
-
failure:
|
|
188
|
-
}),
|
|
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
|
-
},
|
|
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
|
|
203
|
-
return new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
},
|
|
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
|
-
}),
|
|
306
|
+
}), oe = /* @__PURE__ */ new Set([
|
|
286
307
|
"collect_js",
|
|
287
308
|
"card",
|
|
288
309
|
"stripe_elements"
|
|
289
|
-
]),
|
|
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
|
|
295
|
-
let t = e.filter((e) => !!e.status && e.custodian === "psp" &&
|
|
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
|
|
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 &&
|
|
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
|
|
310
|
-
function
|
|
311
|
-
return e.custodian !== "psp" || e.status ? null : e.flow === "card" && e.rail === "nmi" ? "card" : e.flow === "tokenize" &&
|
|
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
|
|
314
|
-
function
|
|
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
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
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:
|
|
369
|
+
unit_amount: L,
|
|
348
370
|
customer_amount: e.object({
|
|
349
|
-
min_amount:
|
|
350
|
-
max_amount:
|
|
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:
|
|
377
|
+
trial_unit_amount: L.nullable(),
|
|
356
378
|
trial_duration_hours: e.number().nullable(),
|
|
357
|
-
psps: e.record(e.string(),
|
|
358
|
-
created_at:
|
|
359
|
-
updated_at:
|
|
360
|
-
}),
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
395
|
+
}), ye = e.object({
|
|
374
396
|
id: e.string(),
|
|
375
397
|
status: e.string()
|
|
376
|
-
}),
|
|
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:
|
|
381
|
-
|
|
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
|
-
}),
|
|
408
|
+
}), be = e.object({
|
|
386
409
|
attempts: e.number(),
|
|
387
410
|
retries_left: e.number().nullish(),
|
|
388
|
-
next_retry_at:
|
|
389
|
-
final_retry_at:
|
|
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
|
-
}),
|
|
415
|
+
}), G = e.object({
|
|
393
416
|
id: e.string(),
|
|
394
|
-
status:
|
|
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:
|
|
401
|
-
ended_at:
|
|
402
|
-
current_period_starts_at:
|
|
403
|
-
current_period_ends_at:
|
|
404
|
-
canceled_at:
|
|
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:
|
|
412
|
-
ends_at:
|
|
436
|
+
starts_at: R,
|
|
437
|
+
ends_at: R.nullish()
|
|
413
438
|
}).nullish(),
|
|
414
|
-
dunning:
|
|
415
|
-
price:
|
|
416
|
-
product:
|
|
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:
|
|
445
|
+
effective_at: R,
|
|
421
446
|
source: e.string(),
|
|
422
|
-
price:
|
|
423
|
-
product:
|
|
447
|
+
price: B.nullish(),
|
|
448
|
+
product: V.nullish()
|
|
424
449
|
}).nullish(),
|
|
425
|
-
card:
|
|
426
|
-
recovery:
|
|
427
|
-
next_action:
|
|
428
|
-
created_at:
|
|
429
|
-
updated_at:
|
|
430
|
-
}),
|
|
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
|
-
}),
|
|
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:
|
|
447
|
-
billing_details:
|
|
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:
|
|
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
|
-
|
|
459
|
-
created_at:
|
|
460
|
-
}),
|
|
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:
|
|
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(
|
|
477
|
-
created_at:
|
|
478
|
-
updated_at:
|
|
479
|
-
}),
|
|
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:
|
|
484
|
-
amount_refunded:
|
|
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:
|
|
491
|
-
price:
|
|
492
|
-
product:
|
|
493
|
-
card:
|
|
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
|
-
}),
|
|
615
|
+
}), ke = e.object({
|
|
500
616
|
currency: e.string(),
|
|
501
617
|
billing_mode: e.string(),
|
|
502
|
-
balance_amount:
|
|
503
|
-
held_amount:
|
|
504
|
-
available_amount:
|
|
505
|
-
owed_amount:
|
|
506
|
-
}),
|
|
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(
|
|
509
|
-
|
|
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
|
-
}),
|
|
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:
|
|
519
|
-
period_ends_at:
|
|
520
|
-
total_amount:
|
|
521
|
-
amount_paid:
|
|
522
|
-
amount_due:
|
|
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:
|
|
525
|
-
due_at:
|
|
640
|
+
issued_at: R.nullish(),
|
|
641
|
+
due_at: R.nullish(),
|
|
526
642
|
delinquent: e.boolean().nullish(),
|
|
527
|
-
paid_at:
|
|
528
|
-
recovery:
|
|
529
|
-
created_at:
|
|
530
|
-
}),
|
|
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
|
-
}),
|
|
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:
|
|
540
|
-
next_charge_amount:
|
|
541
|
-
next_charge_date:
|
|
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
|
-
}),
|
|
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:
|
|
552
|
-
delayed_start:
|
|
667
|
+
next_action: W.nullish(),
|
|
668
|
+
delayed_start: R.nullish(),
|
|
553
669
|
currency: e.string().nullish(),
|
|
554
|
-
amount_due_now:
|
|
555
|
-
next_charge_amount:
|
|
556
|
-
next_charge_date:
|
|
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
|
-
}),
|
|
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:
|
|
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:
|
|
574
|
-
expires_at:
|
|
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:
|
|
694
|
+
units: X,
|
|
579
695
|
sufficient: e.boolean().nullish()
|
|
580
696
|
}).nullish()
|
|
581
|
-
}),
|
|
582
|
-
psps: e.array(
|
|
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
|
-
}),
|
|
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(
|
|
602
|
-
payment:
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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:
|
|
612
|
-
}),
|
|
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
|
-
},
|
|
617
|
-
async function
|
|
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
|
|
746
|
+
throw Ze(e) ? M("wallet_rejected", "The wallet request was declined.") : e;
|
|
624
747
|
}
|
|
625
|
-
if (!n) throw
|
|
748
|
+
if (!n) throw M("wallet_no_signature", "The wallet returned no signature.");
|
|
626
749
|
}
|
|
627
|
-
if (!n) throw
|
|
750
|
+
if (!n) throw M("wallet_no_signature", "The wallet returned no signature.");
|
|
628
751
|
return n;
|
|
629
752
|
}
|
|
630
|
-
var
|
|
631
|
-
function
|
|
632
|
-
let t =
|
|
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 ??
|
|
758
|
+
case 503: return t ?? Q;
|
|
636
759
|
case 502:
|
|
637
|
-
case 504: return
|
|
760
|
+
case 504: return Q;
|
|
638
761
|
default: return null;
|
|
639
762
|
}
|
|
640
763
|
}
|
|
641
|
-
function
|
|
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
|
|
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
|
|
659
|
-
let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""),
|
|
660
|
-
...
|
|
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
|
|
786
|
+
function a(e, n, r = t) {
|
|
664
787
|
let i = new URLSearchParams();
|
|
665
|
-
for (let [e, t] of Object.entries(n ?? {})) 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
|
|
670
|
-
let
|
|
793
|
+
async function o(t, n = {}) {
|
|
794
|
+
let i = new Headers({
|
|
671
795
|
Accept: "application/json",
|
|
672
|
-
...
|
|
796
|
+
...n.headers
|
|
673
797
|
});
|
|
674
|
-
|
|
675
|
-
let o =
|
|
676
|
-
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 &&
|
|
679
|
-
let c =
|
|
802
|
+
s && i.set("Accept-Language", s);
|
|
803
|
+
let c = n.method ?? "GET", l = {
|
|
680
804
|
method: c,
|
|
681
|
-
headers:
|
|
682
|
-
body:
|
|
683
|
-
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
|
|
810
|
+
let i;
|
|
687
811
|
try {
|
|
688
|
-
|
|
812
|
+
i = await r(a(t, n.query, n.root), l);
|
|
689
813
|
} catch (t) {
|
|
690
|
-
let
|
|
691
|
-
if (e >= u ||
|
|
692
|
-
d += await
|
|
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 (
|
|
696
|
-
let o =
|
|
697
|
-
if (e >= u || o === null || d + o > 2e3) throw await
|
|
698
|
-
await
|
|
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
|
|
702
|
-
let r = await
|
|
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
|
|
830
|
+
throw M("invalid_response", `${t}: body is not JSON`);
|
|
707
831
|
}
|
|
708
|
-
let
|
|
709
|
-
if (!
|
|
710
|
-
return
|
|
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
|
|
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
|
-
}),
|
|
716
|
-
|
|
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
|
|
857
|
+
return s(l, "/me/subscriptions", {
|
|
720
858
|
query: {
|
|
721
859
|
status: e.status ?? "all",
|
|
722
|
-
...
|
|
860
|
+
...p(e, 100)
|
|
723
861
|
},
|
|
724
862
|
signal: e.signal
|
|
725
863
|
});
|
|
726
864
|
},
|
|
727
865
|
getSubscription(e, t) {
|
|
728
|
-
return
|
|
866
|
+
return s(G, `/me/subscriptions/${c(e)}`, { signal: t });
|
|
729
867
|
},
|
|
730
868
|
cancelSubscription(e, t) {
|
|
731
|
-
return
|
|
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
|
|
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
|
|
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
|
-
|
|
752
|
-
return
|
|
889
|
+
previewSubscriptionChange(e, t, n) {
|
|
890
|
+
return s(Me, `/me/subscriptions/${c(e)}/change/preview`, {
|
|
753
891
|
method: "POST",
|
|
754
|
-
body: {
|
|
892
|
+
body: {
|
|
893
|
+
price_id: t.priceId,
|
|
894
|
+
quantity: t.quantity
|
|
895
|
+
},
|
|
755
896
|
signal: n
|
|
756
897
|
});
|
|
757
898
|
},
|
|
758
|
-
|
|
759
|
-
return
|
|
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
|
|
770
|
-
query:
|
|
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
|
|
917
|
+
return s(K, "/me/payment-methods", {
|
|
776
918
|
method: "POST",
|
|
777
919
|
body: e
|
|
778
920
|
});
|
|
779
921
|
},
|
|
780
|
-
|
|
781
|
-
return
|
|
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
|
-
|
|
785
|
-
|
|
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
|
-
|
|
791
|
-
return
|
|
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
|
-
|
|
794
|
-
return
|
|
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
|
|
973
|
+
return s(Be, `/me/payment-operations/${c(e)}/authentication`);
|
|
801
974
|
},
|
|
802
975
|
async confirmPaymentAuthentication(e) {
|
|
803
|
-
await
|
|
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
|
|
982
|
+
return (await o(`/me/payment-methods/${c(e)}`, { method: "DELETE" })).status === 202 ? "pending" : "removed";
|
|
810
983
|
},
|
|
811
|
-
async
|
|
812
|
-
await
|
|
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
|
|
991
|
+
return s(d, "/me/payments", {
|
|
822
992
|
query: {
|
|
823
|
-
...
|
|
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
|
|
831
|
-
query:
|
|
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
|
|
1006
|
+
return s(Ae, "/me", { signal: e });
|
|
837
1007
|
},
|
|
838
1008
|
getInvoice(e, t) {
|
|
839
|
-
return
|
|
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
|
-
|
|
842
|
-
|
|
1026
|
+
async listSolanaTokens(e = {}) {
|
|
1027
|
+
let { tokens: t } = await s(Fe, "/solana/tokens", {
|
|
843
1028
|
query: {
|
|
844
|
-
|
|
845
|
-
|
|
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(
|
|
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/${
|
|
1053
|
+
let n = `/checkout-sessions/${c(e)}`, r = t.customerBase?.replace(/\/+$/, ""), i = r === void 0 ? { anonymous: !0 } : { root: r };
|
|
865
1054
|
return {
|
|
866
|
-
getSession: () =>
|
|
1055
|
+
getSession: () => s(O, n, i),
|
|
867
1056
|
async pay(e) {
|
|
868
1057
|
try {
|
|
869
|
-
return await
|
|
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 (!
|
|
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
|
-
|
|
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
|
|
1085
|
+
function Xe(e) {
|
|
914
1086
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e.toUpperCase(), t]));
|
|
915
1087
|
}
|
|
916
|
-
var
|
|
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,
|
|
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-
|
|
1092
|
+
//# sourceMappingURL=client-BuvolBPT.js.map
|