@jetthai/cuora 1.1.13-4 → 1.1.13
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 +0 -8
- package/dist/bundle.mjs +34 -590
- package/package.json +1 -1
- package/src/api/payment.js +0 -9
- package/src/machine/deposit/crypto_button.js +9 -137
- package/src/machine/deposit/loadcard_vn.js +13 -142
- package/src/machine/deposit/qrcode_v2.js +12 -168
- package/src/machine/index.js +0 -2
- package/src/machine/promotions.js +0 -139
package/package.json
CHANGED
package/src/api/payment.js
CHANGED
|
@@ -114,13 +114,4 @@ export default {
|
|
|
114
114
|
method: 'post',
|
|
115
115
|
params: { transferType: 'WITHDRAW', amount },
|
|
116
116
|
}),
|
|
117
|
-
getPromotionsList: () => ({ url: `payment/v2/bankWallet/promotions`, method: 'get' }),
|
|
118
|
-
applyPromotions: ({ promotionsNo, amount }) => ({
|
|
119
|
-
url: `payment/v2/bankWallet/promotion/apply`,
|
|
120
|
-
method: 'post',
|
|
121
|
-
params: {
|
|
122
|
-
promotionsNo,
|
|
123
|
-
amount,
|
|
124
|
-
},
|
|
125
|
-
}),
|
|
126
117
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import padStart from 'lodash/padStart.js'
|
|
3
3
|
import payment from '../../api/payment.js'
|
|
4
|
-
import common from '../../api/common.js'
|
|
5
4
|
|
|
6
5
|
export default function (request) {
|
|
7
|
-
const { appSecret } = request.config
|
|
8
6
|
return createMachine(
|
|
9
7
|
{
|
|
10
8
|
id: 'crypro_button',
|
|
11
9
|
initial: 'loading',
|
|
12
10
|
context: {
|
|
13
|
-
siteConfig: null,
|
|
14
11
|
paymentDetails: [],
|
|
15
12
|
|
|
16
13
|
channels: [],
|
|
@@ -34,127 +31,17 @@ export default function (request) {
|
|
|
34
31
|
states: {
|
|
35
32
|
loading: {
|
|
36
33
|
invoke: {
|
|
37
|
-
src: '
|
|
34
|
+
src: 'fetchPayments',
|
|
38
35
|
onDone: {
|
|
39
|
-
target: '
|
|
40
|
-
actions:
|
|
36
|
+
target: 'loaded',
|
|
37
|
+
actions: 'setCryptos',
|
|
41
38
|
},
|
|
42
39
|
onError: {
|
|
43
40
|
target: 'fail',
|
|
44
41
|
},
|
|
45
42
|
},
|
|
46
43
|
},
|
|
47
|
-
|
|
48
|
-
always: [{ target: 'promotionApplyMode', cond: 'isPromotionApplyMode' }, { target: 'defaultMode' }],
|
|
49
|
-
},
|
|
50
|
-
promotionApplyMode: {
|
|
51
|
-
initial: 'loaded',
|
|
52
|
-
states: {
|
|
53
|
-
loaded: {
|
|
54
|
-
entry: 'reset',
|
|
55
|
-
on: {
|
|
56
|
-
SET_CHANNEL: {
|
|
57
|
-
actions: 'setChannel',
|
|
58
|
-
},
|
|
59
|
-
SET_CRYPTO: {
|
|
60
|
-
actions: 'setCrypto',
|
|
61
|
-
},
|
|
62
|
-
SET_NETWORK: {
|
|
63
|
-
actions: 'setNetwork',
|
|
64
|
-
},
|
|
65
|
-
SET_ADDRESS: {
|
|
66
|
-
actions: 'setAddress',
|
|
67
|
-
},
|
|
68
|
-
CONFIRM: {
|
|
69
|
-
target: 'selecting',
|
|
70
|
-
cond: 'isConfirmable',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
selecting: {
|
|
75
|
-
entry: 'reset',
|
|
76
|
-
on: {
|
|
77
|
-
SELECT_AMOUNT: [
|
|
78
|
-
{
|
|
79
|
-
actions: 'addAmount',
|
|
80
|
-
cond: (context, event) => context.grandTotalEnable === 1,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
actions: 'setAmount',
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
KEY_IN: {
|
|
87
|
-
actions: 'setAmount',
|
|
88
|
-
},
|
|
89
|
-
SUBMIT: {
|
|
90
|
-
target: 'debouncing',
|
|
91
|
-
},
|
|
92
|
-
BACK: {
|
|
93
|
-
target: 'loaded',
|
|
94
|
-
},
|
|
95
|
-
CLEAR_ALL: {
|
|
96
|
-
actions: 'reset',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
debouncing: {
|
|
101
|
-
on: {
|
|
102
|
-
SELECT_AMOUNT: [
|
|
103
|
-
{
|
|
104
|
-
target: 'debouncing',
|
|
105
|
-
actions: 'addAmount',
|
|
106
|
-
cond: (context, event) => context.grandTotalEnable === 1,
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
target: 'debouncing',
|
|
110
|
-
actions: 'setAmount',
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
KEY_IN: {
|
|
114
|
-
target: 'debouncing',
|
|
115
|
-
actions: 'setAmount',
|
|
116
|
-
},
|
|
117
|
-
BACK: {
|
|
118
|
-
target: 'loaded',
|
|
119
|
-
},
|
|
120
|
-
CLEAR_ALL: {
|
|
121
|
-
actions: 'reset',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
after: {
|
|
125
|
-
1000: {
|
|
126
|
-
target: 'calculating',
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
calculating: {
|
|
131
|
-
invoke: {
|
|
132
|
-
src: 'fetchCalculation',
|
|
133
|
-
onDone: {
|
|
134
|
-
target: 'submitting',
|
|
135
|
-
actions: 'setCalculation',
|
|
136
|
-
},
|
|
137
|
-
onError: {
|
|
138
|
-
target: 'selecting',
|
|
139
|
-
actions: 'reset',
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
submitting: {
|
|
144
|
-
invoke: {
|
|
145
|
-
src: 'submitDeposit',
|
|
146
|
-
onDone: {
|
|
147
|
-
target: '#crypro_button.submitted',
|
|
148
|
-
actions: 'setResult',
|
|
149
|
-
},
|
|
150
|
-
onError: {
|
|
151
|
-
target: 'selecting',
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
defaultMode: {
|
|
44
|
+
loaded: {
|
|
158
45
|
on: {
|
|
159
46
|
SET_CHANNEL: {
|
|
160
47
|
actions: 'setChannel',
|
|
@@ -194,7 +81,7 @@ export default function (request) {
|
|
|
194
81
|
actions: 'setAmount',
|
|
195
82
|
},
|
|
196
83
|
BACK: {
|
|
197
|
-
target: '
|
|
84
|
+
target: 'loaded',
|
|
198
85
|
},
|
|
199
86
|
},
|
|
200
87
|
},
|
|
@@ -289,9 +176,8 @@ export default function (request) {
|
|
|
289
176
|
calculation: null,
|
|
290
177
|
}
|
|
291
178
|
}),
|
|
292
|
-
|
|
293
|
-
const {
|
|
294
|
-
const cryptos = paymentDetail?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
179
|
+
setCryptos: assign((context, event) => {
|
|
180
|
+
const cryptos = event.data?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
295
181
|
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
296
182
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
297
183
|
const defaultNetworks =
|
|
@@ -315,12 +201,6 @@ export default function (request) {
|
|
|
315
201
|
options,
|
|
316
202
|
}
|
|
317
203
|
}),
|
|
318
|
-
preset: assign((context, event) => {
|
|
319
|
-
const { siteConfig } = event.data
|
|
320
|
-
return {
|
|
321
|
-
siteConfig,
|
|
322
|
-
}
|
|
323
|
-
}),
|
|
324
204
|
setChannel: assign((context, event) => {
|
|
325
205
|
const { cryptos } = context
|
|
326
206
|
const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
@@ -400,9 +280,6 @@ export default function (request) {
|
|
|
400
280
|
}),
|
|
401
281
|
},
|
|
402
282
|
guards: {
|
|
403
|
-
isPromotionApplyMode: (context, event) => {
|
|
404
|
-
return context.siteConfig?.promotionApplyMode === '1'
|
|
405
|
-
},
|
|
406
283
|
isConfirmable: (context, event) => {
|
|
407
284
|
const { selectedCrypto, selectedNetwork } = context
|
|
408
285
|
return selectedCrypto && selectedNetwork
|
|
@@ -413,13 +290,8 @@ export default function (request) {
|
|
|
413
290
|
},
|
|
414
291
|
},
|
|
415
292
|
services: {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
request.send(common.getConfig({ appSecret })),
|
|
419
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
420
|
-
])
|
|
421
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
422
|
-
return { siteConfig, paymentDetail }
|
|
293
|
+
fetchPayments: async (context, event) => {
|
|
294
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
423
295
|
},
|
|
424
296
|
fetchCalculation: async (context, event) => {
|
|
425
297
|
const { selectedCrypto, selectedAmount } = context
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
-
import common from '../../api/common.js'
|
|
4
3
|
|
|
5
4
|
export default function (request) {
|
|
6
|
-
const { appSecret } = request.config
|
|
7
5
|
return createMachine(
|
|
8
6
|
{
|
|
9
7
|
id: 'loadcard',
|
|
10
8
|
initial: 'loading',
|
|
11
9
|
context: {
|
|
12
|
-
siteConfig: null,
|
|
13
10
|
cards: [],
|
|
14
11
|
options: [],
|
|
15
12
|
|
|
@@ -20,7 +17,7 @@ export default function (request) {
|
|
|
20
17
|
|
|
21
18
|
calculation: null,
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
paymentDetails: [],
|
|
24
21
|
currentCategory: 'loadcard',
|
|
25
22
|
currentMethod: null,
|
|
26
23
|
currentPayment: null,
|
|
@@ -30,127 +27,15 @@ export default function (request) {
|
|
|
30
27
|
invoke: {
|
|
31
28
|
src: 'fetchInitData',
|
|
32
29
|
onDone: {
|
|
33
|
-
target: '
|
|
34
|
-
actions:
|
|
30
|
+
target: 'loaded',
|
|
31
|
+
actions: 'setInitData',
|
|
35
32
|
},
|
|
36
33
|
onError: {
|
|
37
34
|
target: 'fail',
|
|
38
35
|
},
|
|
39
36
|
},
|
|
40
37
|
},
|
|
41
|
-
|
|
42
|
-
always: [{ target: 'promotionApplyMode', cond: 'isPromotionApplyMode' }, { target: 'defaultMode' }],
|
|
43
|
-
},
|
|
44
|
-
promotionApplyMode: {
|
|
45
|
-
initial: 'loaded',
|
|
46
|
-
states: {
|
|
47
|
-
loaded: {
|
|
48
|
-
entry: 'reset',
|
|
49
|
-
on: {
|
|
50
|
-
SELECT_CARD: {
|
|
51
|
-
actions: 'setCard',
|
|
52
|
-
},
|
|
53
|
-
SELECT_AMOUNT: {
|
|
54
|
-
target: 'submittable',
|
|
55
|
-
actions: 'setAmount',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
submittable: {
|
|
60
|
-
on: {
|
|
61
|
-
SELECT_AMOUNT: {
|
|
62
|
-
actions: 'setAmount',
|
|
63
|
-
},
|
|
64
|
-
CONFIRM: {
|
|
65
|
-
target: 'debouncing',
|
|
66
|
-
},
|
|
67
|
-
BACK: {
|
|
68
|
-
target: 'loaded',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
debouncing: {
|
|
73
|
-
on: {
|
|
74
|
-
SELECT_AMOUNT: {
|
|
75
|
-
target: 'debouncing',
|
|
76
|
-
actions: 'setAmount',
|
|
77
|
-
},
|
|
78
|
-
BACK: {
|
|
79
|
-
target: 'loaded',
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
after: {
|
|
83
|
-
1000: {
|
|
84
|
-
target: 'calculating',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
calculable: {
|
|
89
|
-
entry: 'clearCalculation',
|
|
90
|
-
on: {
|
|
91
|
-
SELECT_AMOUNT: {
|
|
92
|
-
target: 'debouncing',
|
|
93
|
-
actions: 'setAmount',
|
|
94
|
-
},
|
|
95
|
-
CALCULATE: {
|
|
96
|
-
target: 'debouncing',
|
|
97
|
-
},
|
|
98
|
-
BACK: {
|
|
99
|
-
target: 'loaded',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
calculating: {
|
|
104
|
-
invoke: {
|
|
105
|
-
src: 'fetchCalculation',
|
|
106
|
-
onDone: {
|
|
107
|
-
target: 'cardInfo',
|
|
108
|
-
actions: 'setCalculation',
|
|
109
|
-
},
|
|
110
|
-
onError: {
|
|
111
|
-
target: 'calculable',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
cardInfo: {
|
|
116
|
-
on: {
|
|
117
|
-
INPUT_CARD_NUMBER: {
|
|
118
|
-
actions: 'setCardNumber',
|
|
119
|
-
},
|
|
120
|
-
INPUT_SERIAL_NUMBER: {
|
|
121
|
-
actions: 'setSerialNumber',
|
|
122
|
-
},
|
|
123
|
-
SUBMIT: {
|
|
124
|
-
target: 'submitting',
|
|
125
|
-
cond: 'isSubmittable',
|
|
126
|
-
},
|
|
127
|
-
SELECT_CARD: {
|
|
128
|
-
target: 'loaded',
|
|
129
|
-
actions: 'setCard',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
submitting: {
|
|
134
|
-
invoke: {
|
|
135
|
-
src: 'submitDeposit',
|
|
136
|
-
onDone: {
|
|
137
|
-
target: 'submitted',
|
|
138
|
-
},
|
|
139
|
-
onError: {
|
|
140
|
-
target: 'cardInfo',
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
submitted: {
|
|
145
|
-
on: {
|
|
146
|
-
BACK: {
|
|
147
|
-
target: 'loaded',
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
defaultMode: {
|
|
38
|
+
loaded: {
|
|
154
39
|
entry: 'reset',
|
|
155
40
|
on: {
|
|
156
41
|
SELECT_CARD: {
|
|
@@ -169,7 +54,7 @@ export default function (request) {
|
|
|
169
54
|
actions: 'setAmount',
|
|
170
55
|
},
|
|
171
56
|
BACK: {
|
|
172
|
-
target: '
|
|
57
|
+
target: 'loaded',
|
|
173
58
|
},
|
|
174
59
|
},
|
|
175
60
|
after: {
|
|
@@ -190,7 +75,7 @@ export default function (request) {
|
|
|
190
75
|
target: 'debouncing',
|
|
191
76
|
},
|
|
192
77
|
BACK: {
|
|
193
|
-
target: '
|
|
78
|
+
target: 'loaded',
|
|
194
79
|
},
|
|
195
80
|
},
|
|
196
81
|
},
|
|
@@ -216,7 +101,7 @@ export default function (request) {
|
|
|
216
101
|
target: 'cardInfo',
|
|
217
102
|
},
|
|
218
103
|
BACK: {
|
|
219
|
-
target: '
|
|
104
|
+
target: 'loaded',
|
|
220
105
|
},
|
|
221
106
|
CLEAR_CALCULATION: {
|
|
222
107
|
target: 'debouncing',
|
|
@@ -237,7 +122,7 @@ export default function (request) {
|
|
|
237
122
|
cond: 'isSubmittable',
|
|
238
123
|
},
|
|
239
124
|
SELECT_CARD: {
|
|
240
|
-
target: '
|
|
125
|
+
target: 'loaded',
|
|
241
126
|
actions: 'setCard',
|
|
242
127
|
},
|
|
243
128
|
},
|
|
@@ -256,7 +141,7 @@ export default function (request) {
|
|
|
256
141
|
submitted: {
|
|
257
142
|
on: {
|
|
258
143
|
BACK: {
|
|
259
|
-
target: '
|
|
144
|
+
target: 'loaded',
|
|
260
145
|
},
|
|
261
146
|
},
|
|
262
147
|
},
|
|
@@ -273,22 +158,16 @@ export default function (request) {
|
|
|
273
158
|
}
|
|
274
159
|
}),
|
|
275
160
|
setInitData: assign((context, event) => {
|
|
276
|
-
const
|
|
277
|
-
const cards =
|
|
161
|
+
const paymentDetails = event.data
|
|
162
|
+
const cards = paymentDetails.filter((element) => element.category === context.currentCategory)
|
|
278
163
|
return {
|
|
279
|
-
|
|
164
|
+
paymentDetails,
|
|
280
165
|
cards,
|
|
281
166
|
selectedCard: cards[0],
|
|
282
167
|
currentMethod: cards[0].method,
|
|
283
168
|
options: cards[0].optional,
|
|
284
169
|
}
|
|
285
170
|
}),
|
|
286
|
-
preset: assign((context, event) => {
|
|
287
|
-
const { siteConfig } = event.data
|
|
288
|
-
return {
|
|
289
|
-
siteConfig,
|
|
290
|
-
}
|
|
291
|
-
}),
|
|
292
171
|
setCard: assign((context, event) => {
|
|
293
172
|
return {
|
|
294
173
|
selectedCard: event.data,
|
|
@@ -321,9 +200,6 @@ export default function (request) {
|
|
|
321
200
|
}),
|
|
322
201
|
},
|
|
323
202
|
guards: {
|
|
324
|
-
isPromotionApplyMode: (context, event) => {
|
|
325
|
-
return context.siteConfig?.promotionApplyMode === '1'
|
|
326
|
-
},
|
|
327
203
|
isSubmittable: (context, event) => {
|
|
328
204
|
const { cardNumber, serialNumber } = context
|
|
329
205
|
return cardNumber && serialNumber
|
|
@@ -331,12 +207,7 @@ export default function (request) {
|
|
|
331
207
|
},
|
|
332
208
|
services: {
|
|
333
209
|
fetchInitData: async (context, event) => {
|
|
334
|
-
|
|
335
|
-
request.send(common.getConfig({ appSecret })),
|
|
336
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
337
|
-
])
|
|
338
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
339
|
-
return { siteConfig, paymentDetail }
|
|
210
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
340
211
|
},
|
|
341
212
|
fetchCalculation: async (context, event) => {
|
|
342
213
|
const { currentMethod, selectedAmount } = context
|