@txgw/payout-components 0.1.7 → 0.2.1
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/dist/{amis-bclZq1Od.js → amis-CjYQbrSm.js} +26 -26
- package/dist/component-beneficiary-form-DIpi8Ma-.js +370 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +7 -7
- package/dist/{vendor-C7cpyYhi.js → vendor-fKhExfo_.js} +61941 -60584
- package/package.json +2 -1
- package/dist/component-beneficiary-form-BFa6ZStw.js +0 -326
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@txgw/payout-components",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"registry": "https://registry.npmjs.org/"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@mi18n/react": "^5.16.4",
|
|
23
24
|
"amis": "^6.13.0",
|
|
24
25
|
"amis-ui": "^6.13.0",
|
|
25
26
|
"mitt": "^3.0.1",
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import { bX as g, ab as p } from "./vendor-C7cpyYhi.js";
|
|
2
|
-
import { t as E, d as j, r as w, T as x } from "./amis-bclZq1Od.js";
|
|
3
|
-
const O = "bankDetails";
|
|
4
|
-
async function b(r, t, s, u = 0) {
|
|
5
|
-
if (u < 0)
|
|
6
|
-
throw new Error("[payout-sdk] fetchWithAuth retries exceeded");
|
|
7
|
-
const { headers: n, authCode: f, domain: a, codeVerifier: _ } = s, e = localStorage.getItem("access_token");
|
|
8
|
-
if (e)
|
|
9
|
-
t.access_token = e;
|
|
10
|
-
else {
|
|
11
|
-
const o = await R(
|
|
12
|
-
f,
|
|
13
|
-
a,
|
|
14
|
-
_
|
|
15
|
-
);
|
|
16
|
-
if (!o.access_token || !o.refresh_token)
|
|
17
|
-
throw localStorage.removeItem("access_token"), localStorage.removeItem("refresh_token"), new Error(
|
|
18
|
-
"[payout-sdk] getAccessToken failed, check authCode validity"
|
|
19
|
-
);
|
|
20
|
-
t.access_token = o.access_token, localStorage.setItem("access_token", o.access_token), localStorage.setItem("refresh_token", o.refresh_token);
|
|
21
|
-
}
|
|
22
|
-
const m = await fetch(r, {
|
|
23
|
-
...s,
|
|
24
|
-
body: JSON.stringify(t),
|
|
25
|
-
headers: {
|
|
26
|
-
...n,
|
|
27
|
-
"Content-Type": "application/json"
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
if (m.status === 400) {
|
|
31
|
-
const o = await m.json();
|
|
32
|
-
if (o.name != "INTERNAL_ERROR")
|
|
33
|
-
throw E.error(`${o.name}: ${o.message}`), new Error(`[payout-sdk] ${o.name}: ${o.message}`);
|
|
34
|
-
const h = localStorage.getItem("refresh_token");
|
|
35
|
-
if (h) {
|
|
36
|
-
const d = await M(
|
|
37
|
-
h,
|
|
38
|
-
a
|
|
39
|
-
);
|
|
40
|
-
if (!d.access_token || !d.refresh_token)
|
|
41
|
-
localStorage.removeItem("access_token"), localStorage.removeItem("refresh_token");
|
|
42
|
-
else
|
|
43
|
-
return localStorage.setItem(
|
|
44
|
-
"refresh_token",
|
|
45
|
-
d.refresh_token
|
|
46
|
-
), localStorage.setItem("access_token", d.access_token), b(r, t, s, --u);
|
|
47
|
-
}
|
|
48
|
-
const l = await R(
|
|
49
|
-
f,
|
|
50
|
-
a,
|
|
51
|
-
_
|
|
52
|
-
);
|
|
53
|
-
if (!l.access_token || !l.refresh_token)
|
|
54
|
-
throw new Error(
|
|
55
|
-
"[payout-sdk] getAccessToken failed, check authCode validity"
|
|
56
|
-
);
|
|
57
|
-
return localStorage.setItem("refresh_token", l.refresh_token), localStorage.setItem("access_token", l.access_token), b(r, t, s, --u);
|
|
58
|
-
}
|
|
59
|
-
return m;
|
|
60
|
-
}
|
|
61
|
-
async function R(r, t, s) {
|
|
62
|
-
const u = {
|
|
63
|
-
authorization_code: r,
|
|
64
|
-
code_verifier: s
|
|
65
|
-
};
|
|
66
|
-
return await (await fetch(`${t}/v1/payout/auth/token`, {
|
|
67
|
-
method: "POST",
|
|
68
|
-
body: JSON.stringify(u),
|
|
69
|
-
headers: {
|
|
70
|
-
"Content-Type": "application/json"
|
|
71
|
-
}
|
|
72
|
-
})).json();
|
|
73
|
-
}
|
|
74
|
-
async function M(r, t) {
|
|
75
|
-
const s = {
|
|
76
|
-
refresh_token: r
|
|
77
|
-
};
|
|
78
|
-
return await (await fetch(`${t}/v1/payout/auth/token/refresh`, {
|
|
79
|
-
method: "POST",
|
|
80
|
-
body: JSON.stringify(s),
|
|
81
|
-
headers: {
|
|
82
|
-
"Content-Type": "application/json"
|
|
83
|
-
}
|
|
84
|
-
})).json();
|
|
85
|
-
}
|
|
86
|
-
async function A(r, t, s) {
|
|
87
|
-
return (await (await b(
|
|
88
|
-
"/v1/payout/beneficiary/token/countryinfos",
|
|
89
|
-
{},
|
|
90
|
-
{
|
|
91
|
-
method: "POST",
|
|
92
|
-
authCode: r,
|
|
93
|
-
domain: t,
|
|
94
|
-
codeVerifier: s
|
|
95
|
-
}
|
|
96
|
-
)).json()).country_infos || [];
|
|
97
|
-
}
|
|
98
|
-
async function B({ inputRegionCode: r, inputPayoutType: t, inputCurrency: s }, u, n, f, a) {
|
|
99
|
-
const e = await (await b(
|
|
100
|
-
"/v1/payout/beneficiary/token/paymentmethodinfos",
|
|
101
|
-
{
|
|
102
|
-
region_code: r
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
method: "POST",
|
|
106
|
-
authCode: u,
|
|
107
|
-
domain: n,
|
|
108
|
-
codeVerifier: f
|
|
109
|
-
}
|
|
110
|
-
)).json(), m = [];
|
|
111
|
-
for (const o of Object.values(e.countries)) {
|
|
112
|
-
const h = o.payoutTypes?.[t]?.currencies;
|
|
113
|
-
if (h)
|
|
114
|
-
for (const [l, d] of Object.entries(h))
|
|
115
|
-
l === s && m.push(d);
|
|
116
|
-
}
|
|
117
|
-
if (m.length !== 0)
|
|
118
|
-
return {
|
|
119
|
-
type: "list-select",
|
|
120
|
-
name: "inputPaymentMethod",
|
|
121
|
-
label: "Transfer method",
|
|
122
|
-
options: m.map((o) => ({
|
|
123
|
-
value: o.payment_method,
|
|
124
|
-
body: /* @__PURE__ */ g.jsxs("div", { children: [
|
|
125
|
-
/* @__PURE__ */ g.jsx("span", { className: "flex font-bold", children: o.display_name }),
|
|
126
|
-
/* @__PURE__ */ g.jsx("span", { className: "flex mt-1", children: o.description })
|
|
127
|
-
] })
|
|
128
|
-
})),
|
|
129
|
-
value: a?.payment_method
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
async function N({
|
|
133
|
-
inputRegionCode: r,
|
|
134
|
-
inputCurrency: t,
|
|
135
|
-
inputPaymentMethod: s
|
|
136
|
-
}, u, n, f) {
|
|
137
|
-
const e = await (await b(
|
|
138
|
-
"/v1/payout/beneficiary/form/schema/token/query",
|
|
139
|
-
{
|
|
140
|
-
payment_method: s,
|
|
141
|
-
region: r,
|
|
142
|
-
currency: t,
|
|
143
|
-
local_clearing_system: "",
|
|
144
|
-
version: "v1",
|
|
145
|
-
entity_type: "ENTITY_TYPE_PERSONAL"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
method: "POST",
|
|
149
|
-
authCode: u,
|
|
150
|
-
domain: n,
|
|
151
|
-
codeVerifier: f
|
|
152
|
-
}
|
|
153
|
-
)).json();
|
|
154
|
-
return JSON.parse(
|
|
155
|
-
e.beneficiary_schema.amis_page.replace(/Area Code/g, "AREA_CODE")
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
function q({
|
|
159
|
-
authCode: r,
|
|
160
|
-
domain: t,
|
|
161
|
-
codeVerifier: s,
|
|
162
|
-
emitter: u,
|
|
163
|
-
defaultValues: n,
|
|
164
|
-
customizations: f
|
|
165
|
-
}) {
|
|
166
|
-
const [a, _] = p.useState([]), [e, m] = p.useState(), [o, h] = p.useState(), [l, d] = p.useState(), C = p.useMemo(() => !f?.layout?.find(
|
|
167
|
-
(c) => c.name === O
|
|
168
|
-
)?.hidden, [f?.layout]), S = p.useCallback(
|
|
169
|
-
(i) => {
|
|
170
|
-
const c = i.body.findIndex(
|
|
171
|
-
(k) => k.type === "form"
|
|
172
|
-
), y = i.body[c];
|
|
173
|
-
i.body[c].onFinished = (k) => {
|
|
174
|
-
const P = j(y.api.data, k, void 0, !0);
|
|
175
|
-
u.emit("submit", P.value);
|
|
176
|
-
}, d(i);
|
|
177
|
-
},
|
|
178
|
-
[u]
|
|
179
|
-
), T = p.useMemo(() => {
|
|
180
|
-
const i = /* @__PURE__ */ new Set();
|
|
181
|
-
return a.filter(
|
|
182
|
-
(y) => y.country_number && !i.has(y.country_number) && i.add(y.country_number)
|
|
183
|
-
).map((y) => ({
|
|
184
|
-
label: y.country_name_standard || y.country_name,
|
|
185
|
-
value: y.country_code
|
|
186
|
-
})).sort((y, k) => y.label.localeCompare(k.label));
|
|
187
|
-
}, [a]), v = p.useMemo(() => Array.from(
|
|
188
|
-
new Set(a.map((c) => c.currency_code))
|
|
189
|
-
).map((c) => ({
|
|
190
|
-
label: c,
|
|
191
|
-
value: c
|
|
192
|
-
})).filter((c) => !!c.label && c.label !== "-").sort((c, y) => c.label.localeCompare(y.label)), [a]);
|
|
193
|
-
p.useEffect(() => {
|
|
194
|
-
a.length !== 0 && e?.inputRegionCode && e?.inputCurrency && e?.inputPayoutType && B(
|
|
195
|
-
{
|
|
196
|
-
inputRegionCode: e.inputRegionCode,
|
|
197
|
-
inputCurrency: e.inputCurrency,
|
|
198
|
-
inputPayoutType: e.inputPayoutType
|
|
199
|
-
},
|
|
200
|
-
r,
|
|
201
|
-
t,
|
|
202
|
-
s,
|
|
203
|
-
n
|
|
204
|
-
).then(h);
|
|
205
|
-
}, [
|
|
206
|
-
a,
|
|
207
|
-
r,
|
|
208
|
-
t,
|
|
209
|
-
e?.inputRegionCode,
|
|
210
|
-
e?.inputCurrency,
|
|
211
|
-
e?.inputPayoutType,
|
|
212
|
-
n,
|
|
213
|
-
s
|
|
214
|
-
]), p.useEffect(() => {
|
|
215
|
-
a.length !== 0 && o && e?.inputPaymentMethod && e?.inputRegionCode && e?.inputCurrency && N(
|
|
216
|
-
{
|
|
217
|
-
inputPaymentMethod: e.inputPaymentMethod,
|
|
218
|
-
inputRegionCode: e.inputRegionCode,
|
|
219
|
-
inputCurrency: e.inputCurrency
|
|
220
|
-
},
|
|
221
|
-
r,
|
|
222
|
-
t,
|
|
223
|
-
s
|
|
224
|
-
).then((i) => i && S(i));
|
|
225
|
-
}, [
|
|
226
|
-
a,
|
|
227
|
-
o,
|
|
228
|
-
r,
|
|
229
|
-
t,
|
|
230
|
-
s,
|
|
231
|
-
e?.inputPaymentMethod,
|
|
232
|
-
e?.inputRegionCode,
|
|
233
|
-
e?.inputCurrency,
|
|
234
|
-
S
|
|
235
|
-
]), p.useEffect(() => {
|
|
236
|
-
e?.inputCurrency || h(void 0);
|
|
237
|
-
}, [e?.inputCurrency]), p.useEffect(() => {
|
|
238
|
-
n && m({
|
|
239
|
-
inputPayoutType: n.payout_type || "B2P",
|
|
240
|
-
inputPaymentMethod: n.payment_method,
|
|
241
|
-
inputRegionCode: n.region_code,
|
|
242
|
-
inputCurrency: n.currency
|
|
243
|
-
});
|
|
244
|
-
}, [n]);
|
|
245
|
-
const I = p.useMemo(
|
|
246
|
-
() => ({
|
|
247
|
-
type: "page",
|
|
248
|
-
visible: C,
|
|
249
|
-
body: {
|
|
250
|
-
type: "spinner",
|
|
251
|
-
show: a.length === 0,
|
|
252
|
-
overlay: !0,
|
|
253
|
-
body: [
|
|
254
|
-
{
|
|
255
|
-
type: "form",
|
|
256
|
-
title: "Bank Details",
|
|
257
|
-
submitText: "",
|
|
258
|
-
onChange: (i) => {
|
|
259
|
-
m(i);
|
|
260
|
-
},
|
|
261
|
-
body: [
|
|
262
|
-
{
|
|
263
|
-
label: "Bank Location",
|
|
264
|
-
type: "input-text",
|
|
265
|
-
creatable: !1,
|
|
266
|
-
name: "inputRegionCode",
|
|
267
|
-
options: T,
|
|
268
|
-
value: n?.region_code
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
label: "Bank account type",
|
|
272
|
-
type: "radios",
|
|
273
|
-
name: "inputPayoutType",
|
|
274
|
-
selectFirst: !0,
|
|
275
|
-
options: [
|
|
276
|
-
{
|
|
277
|
-
label: "Individual",
|
|
278
|
-
value: "B2P"
|
|
279
|
-
}
|
|
280
|
-
],
|
|
281
|
-
value: n?.payout_type
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
label: "Account currency",
|
|
285
|
-
type: "input-text",
|
|
286
|
-
creatable: !1,
|
|
287
|
-
name: "inputCurrency",
|
|
288
|
-
options: v,
|
|
289
|
-
value: n?.currency
|
|
290
|
-
},
|
|
291
|
-
o
|
|
292
|
-
]
|
|
293
|
-
}
|
|
294
|
-
]
|
|
295
|
-
}
|
|
296
|
-
}),
|
|
297
|
-
[
|
|
298
|
-
C,
|
|
299
|
-
a.length,
|
|
300
|
-
T,
|
|
301
|
-
n?.region_code,
|
|
302
|
-
n?.payout_type,
|
|
303
|
-
n?.currency,
|
|
304
|
-
v,
|
|
305
|
-
o
|
|
306
|
-
]
|
|
307
|
-
);
|
|
308
|
-
return p.useEffect(() => {
|
|
309
|
-
async function i() {
|
|
310
|
-
const c = await A(
|
|
311
|
-
r,
|
|
312
|
-
t,
|
|
313
|
-
s
|
|
314
|
-
);
|
|
315
|
-
_(c);
|
|
316
|
-
}
|
|
317
|
-
i();
|
|
318
|
-
}, [r, s, t]), /* @__PURE__ */ g.jsxs(g.Fragment, { children: [
|
|
319
|
-
/* @__PURE__ */ g.jsx(x, {}),
|
|
320
|
-
w(I),
|
|
321
|
-
l && w(l)
|
|
322
|
-
] });
|
|
323
|
-
}
|
|
324
|
-
export {
|
|
325
|
-
q as default
|
|
326
|
-
};
|