@jetthai/cuora 1.1.63 → 1.1.65-doubleWallet
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 +6 -0
- package/dist/bundle.mjs +678 -502
- package/package.json +1 -1
- package/src/api/payment.js +2 -0
- package/src/machine/activity/activity.js +1 -1
- package/src/machine/deposit/crypto.js +36 -19
- package/src/machine/deposit/crypto_button.js +114 -129
- package/src/machine/deposit/direct.js +69 -7
- package/src/machine/deposit/float.js +95 -27
- package/src/machine/deposit/loadcard_vn.js +99 -136
- package/src/machine/deposit/manual_vn.js +39 -7
- package/src/machine/deposit/qrcode_v2.js +136 -150
- package/src/machine/deposit/vpay.js +89 -24
package/package.json
CHANGED
package/src/api/payment.js
CHANGED
|
@@ -38,6 +38,7 @@ export default {
|
|
|
38
38
|
checkTransaction: (paymentMethod) => ({ url: `payment/${paymentMethod}/checkTransaction`, method: 'post' }),
|
|
39
39
|
setBonusSetting: ({ bonus }) => ({ url: 'payment/v2/setting', method: 'post', params: { bonus } }),
|
|
40
40
|
getCurrentWithdrawRule: () => ({ url: 'payment/v2/getCurrentWithdrawRule', method: 'get' }),
|
|
41
|
+
getDoubleWalletWithdrawRule: ({ walletType }) => ({ url: 'payment/v2/withdrawRule', method: 'post', params: { walletType } }),
|
|
41
42
|
convertFreeCredit: ({ exchangeType, cryptoNetwork, targetAddress }) => ({
|
|
42
43
|
url: 'payment/v2/convertFreeCredit',
|
|
43
44
|
method: 'post',
|
|
@@ -136,4 +137,5 @@ export default {
|
|
|
136
137
|
}),
|
|
137
138
|
giveUp: () => ({ url: 'payment/v2/bankWallet/promotion/giveUp', method: 'post' }),
|
|
138
139
|
restore: ({ amount }) => ({ url: 'payment/v2/bankWallet/restore', method: 'post', params: { amount } }),
|
|
140
|
+
restore: () => ({ url: 'payment/v2/bankWallet/restore', method: 'post', params: { amount } }),
|
|
139
141
|
}
|
|
@@ -85,7 +85,7 @@ export default function (request) {
|
|
|
85
85
|
setActivityList: assign((context, event) => {
|
|
86
86
|
const noRedActivity = [2, 4, 13, 20, 90, 91, 92]
|
|
87
87
|
const { uidSite } = context
|
|
88
|
-
let list = event.data
|
|
88
|
+
let list = JSON.parse(JSON.stringify(event.data))
|
|
89
89
|
list.forEach((activity) => {
|
|
90
90
|
const storageUnread = localStorage.getItem(`unread_${activity.activityNo}_${uidSite}`)
|
|
91
91
|
if (noRedActivity.includes(activity.activityType)) {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import padStart from 'lodash/padStart.js'
|
|
3
3
|
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
4
|
-
|
|
5
|
-
// const padStart = require('lodash/padStart')
|
|
4
|
+
import common from '../../api/common.js'
|
|
6
5
|
|
|
7
6
|
export default function (request) {
|
|
7
|
+
const { appSecret } = request.config
|
|
8
8
|
return createMachine(
|
|
9
9
|
{
|
|
10
10
|
id: 'crypto',
|
|
11
11
|
initial: 'loading',
|
|
12
12
|
context: {
|
|
13
|
+
siteConfig: null,
|
|
13
14
|
paymentDetails: [],
|
|
14
15
|
|
|
15
16
|
channels: [],
|
|
@@ -26,14 +27,17 @@ export default function (request) {
|
|
|
26
27
|
|
|
27
28
|
calculation: null,
|
|
28
29
|
result: null,
|
|
30
|
+
|
|
31
|
+
// use for wallet mode 4
|
|
32
|
+
promotion: null,
|
|
29
33
|
},
|
|
30
34
|
states: {
|
|
31
35
|
loading: {
|
|
32
36
|
invoke: {
|
|
33
|
-
src: '
|
|
37
|
+
src: 'fetchInitData',
|
|
34
38
|
onDone: {
|
|
35
39
|
target: 'idle',
|
|
36
|
-
actions: '
|
|
40
|
+
actions: 'setInitData',
|
|
37
41
|
},
|
|
38
42
|
onError: {
|
|
39
43
|
target: '#crypto.fail',
|
|
@@ -50,13 +54,6 @@ export default function (request) {
|
|
|
50
54
|
},
|
|
51
55
|
},
|
|
52
56
|
},
|
|
53
|
-
// calculable: {
|
|
54
|
-
// on: {
|
|
55
|
-
// CALCULATE: {
|
|
56
|
-
// target: 'calculating',
|
|
57
|
-
// },
|
|
58
|
-
// },
|
|
59
|
-
// },
|
|
60
57
|
calculating: {
|
|
61
58
|
invoke: {
|
|
62
59
|
src: 'fetchCalculation',
|
|
@@ -70,6 +67,20 @@ export default function (request) {
|
|
|
70
67
|
},
|
|
71
68
|
},
|
|
72
69
|
calculated: {
|
|
70
|
+
on: {
|
|
71
|
+
SUBMIT: [
|
|
72
|
+
{
|
|
73
|
+
target: 'pending',
|
|
74
|
+
cond: 'isDoubleWalletMode',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
target: 'submitting',
|
|
78
|
+
cond: 'isSubmittable',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
pending: {
|
|
73
84
|
on: {
|
|
74
85
|
SUBMIT: {
|
|
75
86
|
target: 'submitting',
|
|
@@ -112,10 +123,6 @@ export default function (request) {
|
|
|
112
123
|
target: '.idle',
|
|
113
124
|
actions: ['setAmount', 'clearCalculation'],
|
|
114
125
|
},
|
|
115
|
-
// CLEAR_CALCULATION: {
|
|
116
|
-
// target: '.idle',
|
|
117
|
-
// actions: 'clearCalculation',
|
|
118
|
-
// },
|
|
119
126
|
CALCULATE: {
|
|
120
127
|
target: '.debouncing',
|
|
121
128
|
actions: 'clearCalculation',
|
|
@@ -124,8 +131,9 @@ export default function (request) {
|
|
|
124
131
|
},
|
|
125
132
|
{
|
|
126
133
|
actions: {
|
|
127
|
-
|
|
128
|
-
const
|
|
134
|
+
setInitData: assign((context, event) => {
|
|
135
|
+
const { siteConfig, paymentDetail } = event.data
|
|
136
|
+
const cryptos = paymentDetail.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
129
137
|
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
130
138
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
131
139
|
const defaultNetworks =
|
|
@@ -137,6 +145,7 @@ export default function (request) {
|
|
|
137
145
|
}
|
|
138
146
|
}) || []
|
|
139
147
|
return {
|
|
148
|
+
siteConfig,
|
|
140
149
|
channels,
|
|
141
150
|
cryptos,
|
|
142
151
|
networks: defaultNetworks,
|
|
@@ -221,6 +230,9 @@ export default function (request) {
|
|
|
221
230
|
}),
|
|
222
231
|
},
|
|
223
232
|
guards: {
|
|
233
|
+
isDoubleWalletMode: (context, event) => {
|
|
234
|
+
return context.siteConfig?.walletMode === '4'
|
|
235
|
+
},
|
|
224
236
|
isCalculable: (context, event) => {
|
|
225
237
|
const {
|
|
226
238
|
selectedCrypto,
|
|
@@ -236,8 +248,13 @@ export default function (request) {
|
|
|
236
248
|
},
|
|
237
249
|
},
|
|
238
250
|
services: {
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
fetchInitData: async (context, event) => {
|
|
252
|
+
const [{ config }, paymentDetail = []] = await Promise.all([
|
|
253
|
+
request.send(common.getConfig({ appSecret })),
|
|
254
|
+
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
255
|
+
])
|
|
256
|
+
const siteConfig = JSON.parse(window.atob(config))
|
|
257
|
+
return { siteConfig, paymentDetail }
|
|
241
258
|
},
|
|
242
259
|
fetchCalculation: async (context, event) => {
|
|
243
260
|
const { selectedCrypto, amount } = context
|
|
@@ -30,28 +30,58 @@ export default function (request) {
|
|
|
30
30
|
result: null,
|
|
31
31
|
|
|
32
32
|
grandTotalEnable: 1,
|
|
33
|
+
|
|
34
|
+
// use for wallet mode 4
|
|
35
|
+
promotion: null,
|
|
36
|
+
bonusPreviewData: [],
|
|
33
37
|
},
|
|
34
38
|
states: {
|
|
35
39
|
loading: {
|
|
36
40
|
invoke: {
|
|
37
41
|
src: 'fetchInitData',
|
|
38
42
|
onDone: {
|
|
39
|
-
target: '
|
|
40
|
-
actions:
|
|
43
|
+
target: 'loaded',
|
|
44
|
+
actions: 'setInitData',
|
|
41
45
|
},
|
|
42
46
|
onError: {
|
|
43
47
|
target: 'fail',
|
|
44
48
|
},
|
|
45
49
|
},
|
|
46
50
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
newWalletMode: {
|
|
51
|
-
initial: 'loaded',
|
|
51
|
+
loaded: {
|
|
52
|
+
type: 'parallel',
|
|
52
53
|
states: {
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
bonusPreview: {
|
|
55
|
+
initial: 'checking',
|
|
56
|
+
states: {
|
|
57
|
+
checking: {
|
|
58
|
+
always: [
|
|
59
|
+
{
|
|
60
|
+
target: 'fetching',
|
|
61
|
+
cond: (context, event) => {
|
|
62
|
+
const { siteConfig = {}, promotion = {} } = context
|
|
63
|
+
return siteConfig.bonusPreviewEnable === '1' && promotion.activityNo != 'none'
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{ target: 'end' },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
fetching: {
|
|
70
|
+
invoke: {
|
|
71
|
+
src: 'fetchBonusPreview',
|
|
72
|
+
onDone: {
|
|
73
|
+
target: 'end',
|
|
74
|
+
actions: 'setBonusPreview',
|
|
75
|
+
},
|
|
76
|
+
onError: {
|
|
77
|
+
target: 'end',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
end: {},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
idle: {
|
|
55
85
|
on: {
|
|
56
86
|
SET_CHANNEL: {
|
|
57
87
|
actions: 'setChannel',
|
|
@@ -66,112 +96,11 @@ export default function (request) {
|
|
|
66
96
|
actions: 'setAddress',
|
|
67
97
|
},
|
|
68
98
|
CONFIRM: {
|
|
69
|
-
target: 'selecting',
|
|
99
|
+
target: '#crypro_button.selecting',
|
|
70
100
|
cond: 'isConfirmable',
|
|
71
101
|
},
|
|
72
102
|
},
|
|
73
103
|
},
|
|
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: {
|
|
158
|
-
on: {
|
|
159
|
-
SET_CHANNEL: {
|
|
160
|
-
actions: 'setChannel',
|
|
161
|
-
},
|
|
162
|
-
SET_CRYPTO: {
|
|
163
|
-
actions: 'setCrypto',
|
|
164
|
-
},
|
|
165
|
-
SET_NETWORK: {
|
|
166
|
-
actions: 'setNetwork',
|
|
167
|
-
},
|
|
168
|
-
SET_ADDRESS: {
|
|
169
|
-
actions: 'setAddress',
|
|
170
|
-
},
|
|
171
|
-
CONFIRM: {
|
|
172
|
-
target: 'selecting',
|
|
173
|
-
cond: 'isConfirmable',
|
|
174
|
-
},
|
|
175
104
|
},
|
|
176
105
|
},
|
|
177
106
|
fail: {},
|
|
@@ -181,20 +110,45 @@ export default function (request) {
|
|
|
181
110
|
SELECT_AMOUNT: [
|
|
182
111
|
{
|
|
183
112
|
target: 'debouncing',
|
|
113
|
+
actions: 'setAmount',
|
|
114
|
+
cond: 'isDoubleWalletMode',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
184
117
|
actions: 'addAmount',
|
|
185
|
-
cond: (context, event) => context.grandTotalEnable === 1,
|
|
118
|
+
cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
actions: 'setAmount',
|
|
122
|
+
cond: (context, event) => context.siteConfig?.walletMode === '2',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
target: 'debouncing',
|
|
126
|
+
actions: 'addAmount',
|
|
127
|
+
cond: 'isGrandTotalEnable',
|
|
186
128
|
},
|
|
187
129
|
{
|
|
188
130
|
target: 'debouncing',
|
|
189
131
|
actions: 'setAmount',
|
|
190
132
|
},
|
|
191
133
|
],
|
|
192
|
-
KEY_IN:
|
|
134
|
+
KEY_IN: [
|
|
135
|
+
{
|
|
136
|
+
actions: 'setAmount',
|
|
137
|
+
cond: 'isFreeWalletMode',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
target: 'debouncing',
|
|
141
|
+
actions: 'setAmount',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
SUBMIT: {
|
|
193
145
|
target: 'debouncing',
|
|
194
|
-
actions: 'setAmount',
|
|
195
146
|
},
|
|
196
147
|
BACK: {
|
|
197
|
-
target: '
|
|
148
|
+
target: 'loaded',
|
|
149
|
+
},
|
|
150
|
+
CLEAR_ALL: {
|
|
151
|
+
actions: 'reset',
|
|
198
152
|
},
|
|
199
153
|
},
|
|
200
154
|
},
|
|
@@ -204,7 +158,7 @@ export default function (request) {
|
|
|
204
158
|
{
|
|
205
159
|
target: 'debouncing',
|
|
206
160
|
actions: 'addAmount',
|
|
207
|
-
cond:
|
|
161
|
+
cond: 'isGrandTotalEnable',
|
|
208
162
|
},
|
|
209
163
|
{
|
|
210
164
|
target: 'debouncing',
|
|
@@ -225,10 +179,17 @@ export default function (request) {
|
|
|
225
179
|
calculating: {
|
|
226
180
|
invoke: {
|
|
227
181
|
src: 'fetchCalculation',
|
|
228
|
-
onDone:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
182
|
+
onDone: [
|
|
183
|
+
{
|
|
184
|
+
target: 'submitting',
|
|
185
|
+
actions: 'setCalculation',
|
|
186
|
+
cond: 'isFreeWalletMode',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
target: 'calculated',
|
|
190
|
+
actions: 'setCalculation',
|
|
191
|
+
},
|
|
192
|
+
],
|
|
232
193
|
onError: {
|
|
233
194
|
target: 'selecting',
|
|
234
195
|
actions: 'reset',
|
|
@@ -241,7 +202,7 @@ export default function (request) {
|
|
|
241
202
|
{
|
|
242
203
|
target: 'debouncing',
|
|
243
204
|
actions: 'addAmount',
|
|
244
|
-
cond:
|
|
205
|
+
cond: 'isGrandTotalEnable',
|
|
245
206
|
},
|
|
246
207
|
{
|
|
247
208
|
target: 'debouncing',
|
|
@@ -280,6 +241,11 @@ export default function (request) {
|
|
|
280
241
|
},
|
|
281
242
|
submitted: {},
|
|
282
243
|
},
|
|
244
|
+
on: {
|
|
245
|
+
SET_PROMOTION: {
|
|
246
|
+
actions: 'setPromotion',
|
|
247
|
+
},
|
|
248
|
+
},
|
|
283
249
|
},
|
|
284
250
|
{
|
|
285
251
|
actions: {
|
|
@@ -290,7 +256,7 @@ export default function (request) {
|
|
|
290
256
|
}
|
|
291
257
|
}),
|
|
292
258
|
setInitData: assign((context, event) => {
|
|
293
|
-
const { paymentDetail } = event.data
|
|
259
|
+
const { siteConfig, paymentDetail } = event.data
|
|
294
260
|
const cryptos = paymentDetail?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
|
|
295
261
|
const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
|
|
296
262
|
const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
|
|
@@ -304,6 +270,7 @@ export default function (request) {
|
|
|
304
270
|
}) || []
|
|
305
271
|
const options = cryptos[0].optional
|
|
306
272
|
return {
|
|
273
|
+
siteConfig,
|
|
307
274
|
channels,
|
|
308
275
|
cryptos,
|
|
309
276
|
networks: defaultNetworks,
|
|
@@ -315,12 +282,6 @@ export default function (request) {
|
|
|
315
282
|
options,
|
|
316
283
|
}
|
|
317
284
|
}),
|
|
318
|
-
preset: assign((context, event) => {
|
|
319
|
-
const { siteConfig } = event.data
|
|
320
|
-
return {
|
|
321
|
-
siteConfig,
|
|
322
|
-
}
|
|
323
|
-
}),
|
|
324
285
|
setChannel: assign((context, event) => {
|
|
325
286
|
const { cryptos } = context
|
|
326
287
|
const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
@@ -372,6 +333,11 @@ export default function (request) {
|
|
|
372
333
|
setNetwork: assign((context, event) => {
|
|
373
334
|
return { selectedNetwork: event.data }
|
|
374
335
|
}),
|
|
336
|
+
setBonusPreview: assign((context, event) => {
|
|
337
|
+
return {
|
|
338
|
+
bonusPreviewData: event.data.bonus,
|
|
339
|
+
}
|
|
340
|
+
}),
|
|
375
341
|
addAmount: assign((context, event) => {
|
|
376
342
|
return { selectedAmount: (context.selectedAmount || 0) + event.data }
|
|
377
343
|
}),
|
|
@@ -398,11 +364,23 @@ export default function (request) {
|
|
|
398
364
|
result: event.data,
|
|
399
365
|
}
|
|
400
366
|
}),
|
|
367
|
+
setPromotion: assign((context, event) => {
|
|
368
|
+
const promotion = event.data
|
|
369
|
+
return {
|
|
370
|
+
promotion,
|
|
371
|
+
}
|
|
372
|
+
}),
|
|
401
373
|
},
|
|
402
374
|
guards: {
|
|
403
|
-
|
|
375
|
+
isFreeWalletMode: (context, event) => {
|
|
404
376
|
return context.siteConfig?.walletMode === '2'
|
|
405
377
|
},
|
|
378
|
+
isDoubleWalletMode: (context, event) => {
|
|
379
|
+
return context.siteConfig?.walletMode === '4'
|
|
380
|
+
},
|
|
381
|
+
isGrandTotalEnable: (context, event) => {
|
|
382
|
+
return context.grandTotalEnable === 1
|
|
383
|
+
},
|
|
406
384
|
isConfirmable: (context, event) => {
|
|
407
385
|
const { selectedCrypto, selectedNetwork } = context
|
|
408
386
|
return selectedCrypto && selectedNetwork
|
|
@@ -421,6 +399,13 @@ export default function (request) {
|
|
|
421
399
|
const siteConfig = JSON.parse(window.atob(config))
|
|
422
400
|
return { siteConfig, paymentDetail }
|
|
423
401
|
},
|
|
402
|
+
fetchBonusPreview: async (context, event) => {
|
|
403
|
+
const { selectedCrypto, promotion } = context
|
|
404
|
+
return await request.send({
|
|
405
|
+
paymentMethod: selectedCrypto.method,
|
|
406
|
+
promotionsNo: promotion?.activityNo,
|
|
407
|
+
})
|
|
408
|
+
},
|
|
424
409
|
fetchCalculation: async (context, event) => {
|
|
425
410
|
const { selectedCrypto, selectedAmount } = context
|
|
426
411
|
return await request.send(
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import payment from '../../api/payment.js'
|
|
3
|
+
import common from '../../api/common.js'
|
|
3
4
|
|
|
4
5
|
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
5
7
|
return createMachine(
|
|
6
8
|
{
|
|
7
9
|
id: 'direct',
|
|
8
10
|
initial: 'loading',
|
|
9
11
|
context: {
|
|
10
|
-
|
|
12
|
+
siteConfig: null,
|
|
13
|
+
paymentDetail: [],
|
|
11
14
|
directs: [],
|
|
12
15
|
currentDirect: null,
|
|
13
16
|
banks: [],
|
|
@@ -53,6 +56,10 @@ export default function (request) {
|
|
|
53
56
|
},
|
|
54
57
|
promotion: {
|
|
55
58
|
always: [
|
|
59
|
+
{
|
|
60
|
+
target: 'loaded',
|
|
61
|
+
cond: 'isDoubleWalletMode',
|
|
62
|
+
},
|
|
56
63
|
{
|
|
57
64
|
target: 'calculating',
|
|
58
65
|
actions: 'setPromotionDefaultAmount',
|
|
@@ -79,15 +86,61 @@ export default function (request) {
|
|
|
79
86
|
actions: 'clearCalculation',
|
|
80
87
|
},
|
|
81
88
|
CALCULATE: {
|
|
82
|
-
target: '
|
|
83
|
-
cond: 'isCalculable',
|
|
89
|
+
target: 'debouncing',
|
|
84
90
|
},
|
|
91
|
+
SUBMIT: [
|
|
92
|
+
{
|
|
93
|
+
target: 'pending',
|
|
94
|
+
cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
target: 'submitting',
|
|
98
|
+
cond: 'isSubmittable',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
pending: {
|
|
104
|
+
on: {
|
|
85
105
|
SUBMIT: {
|
|
86
106
|
target: 'submitting',
|
|
87
107
|
cond: 'isSubmittable',
|
|
88
108
|
},
|
|
89
109
|
},
|
|
90
110
|
},
|
|
111
|
+
debouncing: {
|
|
112
|
+
on: {
|
|
113
|
+
SELECT_DIRECT: {
|
|
114
|
+
actions: ['setDirect', 'reset'],
|
|
115
|
+
target: 'loading.fetching',
|
|
116
|
+
},
|
|
117
|
+
SELECT_BANK: {
|
|
118
|
+
actions: 'setSelectedBank',
|
|
119
|
+
},
|
|
120
|
+
SET_AMOUNT: {
|
|
121
|
+
actions: ['setAmount', 'clearCalculation'],
|
|
122
|
+
},
|
|
123
|
+
CLEAR_CALCULATION: {
|
|
124
|
+
actions: 'clearCalculation',
|
|
125
|
+
},
|
|
126
|
+
CALCULATE: {
|
|
127
|
+
target: 'debouncing',
|
|
128
|
+
},
|
|
129
|
+
SUBMIT: [
|
|
130
|
+
{
|
|
131
|
+
target: 'pending',
|
|
132
|
+
cond: (context, event) => context.siteConfig?.walletMode === '4' && !!context.calculation,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
target: 'submitting',
|
|
136
|
+
cond: 'isSubmittable',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
after: {
|
|
141
|
+
1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
91
144
|
calculating: {
|
|
92
145
|
invoke: {
|
|
93
146
|
src: 'fetchCalculation',
|
|
@@ -132,11 +185,12 @@ export default function (request) {
|
|
|
132
185
|
}
|
|
133
186
|
}),
|
|
134
187
|
setInitData: assign((context, event) => {
|
|
135
|
-
const
|
|
136
|
-
const directs =
|
|
188
|
+
const { siteConfig, paymentDetail } = event.data
|
|
189
|
+
const directs = paymentDetail.filter((element) => element.category === context.currentCategory)
|
|
137
190
|
|
|
138
191
|
return {
|
|
139
|
-
|
|
192
|
+
siteConfig,
|
|
193
|
+
paymentDetail,
|
|
140
194
|
directs,
|
|
141
195
|
currentDirect: directs[0],
|
|
142
196
|
currentMethod: directs[0]?.method,
|
|
@@ -193,6 +247,9 @@ export default function (request) {
|
|
|
193
247
|
}),
|
|
194
248
|
},
|
|
195
249
|
guards: {
|
|
250
|
+
isDoubleWalletMode: (context, event) => {
|
|
251
|
+
return context.siteConfig?.walletMode === '4'
|
|
252
|
+
},
|
|
196
253
|
isCalculable: (context, event) => {
|
|
197
254
|
const {
|
|
198
255
|
amount,
|
|
@@ -211,7 +268,12 @@ export default function (request) {
|
|
|
211
268
|
},
|
|
212
269
|
services: {
|
|
213
270
|
fetchInitData: async (context, event) => {
|
|
214
|
-
|
|
271
|
+
const [{ config }, paymentDetail = []] = await Promise.all([
|
|
272
|
+
request.send(common.getConfig({ appSecret })),
|
|
273
|
+
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
274
|
+
])
|
|
275
|
+
const siteConfig = JSON.parse(window.atob(config))
|
|
276
|
+
return { siteConfig, paymentDetail }
|
|
215
277
|
},
|
|
216
278
|
fetchBanksList: async (context, event) => {
|
|
217
279
|
const { currentDirect } = context
|