@jetthai/cuora 1.1.181 → 1.1.182-krw-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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/api/payment.js +1 -1
- package/src/machine/auth.js +17 -3
- package/src/machine/bank_binding.js +6 -1
- package/src/machine/bank_binding_amb.js +6 -1
- package/src/machine/deposit/crypto_bank_cash.js +265 -0
- package/src/machine/deposit/index.js +8 -4
- package/src/machine/deposit/krway.js +124 -0
- package/src/machine/user_sign_up.js +40 -7
- package/src/machine/withdraw/index.js +2 -0
- package/src/machine/withdraw/withdraw_krway.js +515 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.182-krw-1](https://github.com/jetthai/cuora-module/compare/v1.1.182-krw...v1.1.182-krw-1) (2023-09-27)
|
|
6
|
+
|
|
7
|
+
### [1.1.182-krw](https://github.com/jetthai/cuora-module/compare/v1.1.182...v1.1.182-krw) (2023-09-26)
|
|
8
|
+
|
|
9
|
+
### [1.1.182](https://github.com/jetthai/cuora-module/compare/v1.1.181...v1.1.182) (2023-09-21)
|
|
10
|
+
|
|
5
11
|
### [1.1.181](https://github.com/jetthai/cuora-module/compare/v1.1.180...v1.1.181) (2023-09-20)
|
|
6
12
|
|
|
7
13
|
### [1.1.180](https://github.com/jetthai/cuora-module/compare/v1.1.179...v1.1.180) (2023-09-19)
|
package/package.json
CHANGED
package/src/api/payment.js
CHANGED
|
@@ -40,7 +40,7 @@ export default {
|
|
|
40
40
|
},
|
|
41
41
|
}),
|
|
42
42
|
getBankList: (paymentMethod) => ({ url: `payment/v2/${paymentMethod}/getBankList`, method: 'get' }),
|
|
43
|
-
getBindingBankList: () => ({ url: 'payment/v2/getBindingBankList', method: 'get' }),
|
|
43
|
+
getBindingBankList: ({ appSecret }) => ({ url: 'payment/v2/getBindingBankList', method: 'get', params: { appSecret }, isPublic: true }),
|
|
44
44
|
getWithdrawBankList: () => ({ url: 'payment/v2/getWithdrawBankList', method: 'get' }),
|
|
45
45
|
makeTransaction: ({ type, payload, paymentMethod }) => ({
|
|
46
46
|
url: `payment/v2/${paymentMethod}/transaction`,
|
package/src/machine/auth.js
CHANGED
|
@@ -210,6 +210,10 @@ export default function (request) {
|
|
|
210
210
|
LOGIN_GUEST: {
|
|
211
211
|
target: '.authenticationGuest',
|
|
212
212
|
},
|
|
213
|
+
LOGIN_ID: {
|
|
214
|
+
target: '.authentication',
|
|
215
|
+
actions: ['setReCaptchaToken', 'setLoginId'],
|
|
216
|
+
},
|
|
213
217
|
LOGIN_PHONE: {
|
|
214
218
|
target: '.authentication',
|
|
215
219
|
actions: ['setReCaptchaToken', 'setLoginPhone'],
|
|
@@ -264,6 +268,16 @@ export default function (request) {
|
|
|
264
268
|
reCaptchaToken,
|
|
265
269
|
}
|
|
266
270
|
}),
|
|
271
|
+
setLoginId: assign((context, event) => {
|
|
272
|
+
const { username, password } = event.data
|
|
273
|
+
return {
|
|
274
|
+
loginData: {
|
|
275
|
+
provider: 'local',
|
|
276
|
+
username,
|
|
277
|
+
password,
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
}),
|
|
267
281
|
setLoginPhone: assign((context, event) => {
|
|
268
282
|
const { countryCode, countryAbbr, phone, password } = event.data
|
|
269
283
|
return {
|
|
@@ -320,18 +334,18 @@ export default function (request) {
|
|
|
320
334
|
storage.remove(accountEmailKey)
|
|
321
335
|
storage.set(accountPhoneKey, `${context.loginData.phone}`, {
|
|
322
336
|
path: '/',
|
|
323
|
-
maxAge: 60 * 60 * 24 *
|
|
337
|
+
maxAge: 60 * 60 * 24 * 31,
|
|
324
338
|
})
|
|
325
339
|
storage.set(phoneCountryCode, `${context.countryAbbr}_${context.loginData.countryCode}`, {
|
|
326
340
|
path: '/',
|
|
327
|
-
maxAge: 60 * 60 * 24 *
|
|
341
|
+
maxAge: 60 * 60 * 24 * 31,
|
|
328
342
|
})
|
|
329
343
|
} else if (context.loginData.email) {
|
|
330
344
|
storage.remove(accountPhoneKey)
|
|
331
345
|
storage.remove(phoneCountryCode)
|
|
332
346
|
storage.set(accountEmailKey, context.loginData.email, {
|
|
333
347
|
path: '/',
|
|
334
|
-
maxAge: 60 * 60 * 24 *
|
|
348
|
+
maxAge: 60 * 60 * 24 * 31,
|
|
335
349
|
})
|
|
336
350
|
}
|
|
337
351
|
}),
|
|
@@ -2,6 +2,8 @@ import { assign, createMachine } from 'xstate'
|
|
|
2
2
|
import payment from '../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
|
|
5
7
|
return createMachine(
|
|
6
8
|
{
|
|
7
9
|
id: 'bank_binding',
|
|
@@ -106,7 +108,10 @@ export default function (request) {
|
|
|
106
108
|
},
|
|
107
109
|
services: {
|
|
108
110
|
fetchInitData: async (context, event) => {
|
|
109
|
-
const [bankList, paymentInfo] = await Promise.all([
|
|
111
|
+
const [bankList, paymentInfo] = await Promise.all([
|
|
112
|
+
request.send(payment.getBindingBankList({ appSecret })),
|
|
113
|
+
request.send(payment.getPaymentInfo()),
|
|
114
|
+
])
|
|
110
115
|
return { bankList, paymentInfo }
|
|
111
116
|
},
|
|
112
117
|
updatePaymentInfo: async (context, event) => {
|
|
@@ -2,6 +2,8 @@ import { assign, createMachine } from 'xstate'
|
|
|
2
2
|
import payment from '../api/payment.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
|
|
5
7
|
return createMachine(
|
|
6
8
|
{
|
|
7
9
|
id: 'bank_binding_amb',
|
|
@@ -116,7 +118,10 @@ export default function (request) {
|
|
|
116
118
|
},
|
|
117
119
|
services: {
|
|
118
120
|
fetchInitData: async (context, event) => {
|
|
119
|
-
const [bankList, paymentInfo] = await Promise.all([
|
|
121
|
+
const [bankList, paymentInfo] = await Promise.all([
|
|
122
|
+
request.send(payment.getBindingBankList({ appSecret })),
|
|
123
|
+
request.send(payment.getPaymentInfo()),
|
|
124
|
+
])
|
|
120
125
|
return { bankList, paymentInfo }
|
|
121
126
|
},
|
|
122
127
|
updatePaymentInfo: async (context, event) => {
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
3
|
+
import { max } from '../../util/index.js'
|
|
4
|
+
|
|
5
|
+
export default function (request, context) {
|
|
6
|
+
const { paymentDetail = [], promotion, selectedAmount } = context || {}
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'crypto_cash',
|
|
10
|
+
initial: 'loading',
|
|
11
|
+
context: {
|
|
12
|
+
paymentDetail,
|
|
13
|
+
promotion,
|
|
14
|
+
selectedAmount,
|
|
15
|
+
|
|
16
|
+
cryptos: [],
|
|
17
|
+
networks: [],
|
|
18
|
+
sourceAddress: '',
|
|
19
|
+
options: [],
|
|
20
|
+
|
|
21
|
+
selectedCrypto: null,
|
|
22
|
+
selectedNetwork: null,
|
|
23
|
+
|
|
24
|
+
currentCategory: 'cryptoBank',
|
|
25
|
+
|
|
26
|
+
calculation: null,
|
|
27
|
+
result: null,
|
|
28
|
+
receipt: null,
|
|
29
|
+
},
|
|
30
|
+
states: {
|
|
31
|
+
loading: {
|
|
32
|
+
always: [
|
|
33
|
+
{
|
|
34
|
+
target: 'debouncing',
|
|
35
|
+
actions: 'setInitData',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
loaded: {},
|
|
40
|
+
debouncing: {
|
|
41
|
+
entry: 'clearCalculation',
|
|
42
|
+
after: {
|
|
43
|
+
1000: [
|
|
44
|
+
{
|
|
45
|
+
target: 'calculating',
|
|
46
|
+
cond: 'isCalculable',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
target: 'loaded',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
calculating: {
|
|
55
|
+
invoke: {
|
|
56
|
+
src: 'fetchCalculation',
|
|
57
|
+
onDone: {
|
|
58
|
+
target: 'calculated',
|
|
59
|
+
actions: 'setCalculation',
|
|
60
|
+
},
|
|
61
|
+
onError: {
|
|
62
|
+
target: 'calculated',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
calculated: {
|
|
67
|
+
on: {
|
|
68
|
+
SUBMIT: [
|
|
69
|
+
{
|
|
70
|
+
target: 'submitting',
|
|
71
|
+
cond: 'isSubmittable',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
submitting: {
|
|
77
|
+
invoke: {
|
|
78
|
+
src: 'submitDeposit',
|
|
79
|
+
onDone: {
|
|
80
|
+
target: 'submitted',
|
|
81
|
+
actions: 'setResult',
|
|
82
|
+
},
|
|
83
|
+
onError: {
|
|
84
|
+
target: 'loaded',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
submitted: {},
|
|
89
|
+
},
|
|
90
|
+
on: {
|
|
91
|
+
SET_PROMOTION: {
|
|
92
|
+
target: '.debouncing',
|
|
93
|
+
actions: 'setPromotion',
|
|
94
|
+
internal: false,
|
|
95
|
+
},
|
|
96
|
+
SET_CRYPTO: {
|
|
97
|
+
target: '.debouncing',
|
|
98
|
+
actions: 'setCrypto',
|
|
99
|
+
internal: false,
|
|
100
|
+
},
|
|
101
|
+
SET_NETWORK: {
|
|
102
|
+
target: '.debouncing',
|
|
103
|
+
actions: 'setNetwork',
|
|
104
|
+
internal: false,
|
|
105
|
+
},
|
|
106
|
+
SET_ADDRESS: {
|
|
107
|
+
actions: 'setAddress',
|
|
108
|
+
internal: false,
|
|
109
|
+
},
|
|
110
|
+
SET_AMOUNT: {
|
|
111
|
+
target: '.debouncing',
|
|
112
|
+
actions: 'setAmount',
|
|
113
|
+
internal: false,
|
|
114
|
+
},
|
|
115
|
+
INPUT_AMOUNT: {
|
|
116
|
+
target: '.debouncing',
|
|
117
|
+
actions: 'inputAmount',
|
|
118
|
+
internal: false,
|
|
119
|
+
},
|
|
120
|
+
SET_RECEIPT: {
|
|
121
|
+
actions: 'setReceipt',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
actions: {
|
|
127
|
+
setInitData: assign((context, event) => {
|
|
128
|
+
const { paymentDetail } = context
|
|
129
|
+
const cryptos = paymentDetail
|
|
130
|
+
.filter((element) => element.transferType === 'deposit' && element.category === context.currentCategory)
|
|
131
|
+
.map((crypto) => ({
|
|
132
|
+
...crypto,
|
|
133
|
+
label: crypto.channel,
|
|
134
|
+
value: crypto.method,
|
|
135
|
+
icon: crypto.channel,
|
|
136
|
+
}))
|
|
137
|
+
const defaultNetworks = cryptos[0].networkName.map((value, i) => {
|
|
138
|
+
return {
|
|
139
|
+
label: cryptos[0].networkOptional?.[i],
|
|
140
|
+
value,
|
|
141
|
+
icon: value,
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
return {
|
|
145
|
+
cryptos,
|
|
146
|
+
networks: defaultNetworks,
|
|
147
|
+
selectedCrypto: cryptos[0],
|
|
148
|
+
selectedNetwork: defaultNetworks[0],
|
|
149
|
+
options: cryptos[0].optional,
|
|
150
|
+
}
|
|
151
|
+
}),
|
|
152
|
+
setCrypto: assign((context, event) => {
|
|
153
|
+
const { cryptos } = context
|
|
154
|
+
const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
|
|
155
|
+
const networks = selectedCrypto?.networkName.map((value, i) => {
|
|
156
|
+
return {
|
|
157
|
+
label: selectedCrypto?.networkOptional?.[i],
|
|
158
|
+
value,
|
|
159
|
+
icon: value,
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
return {
|
|
163
|
+
networks,
|
|
164
|
+
selectedCrypto: selectedCrypto,
|
|
165
|
+
selectedNetwork: networks[0],
|
|
166
|
+
selectedAmount: null,
|
|
167
|
+
calculation: null,
|
|
168
|
+
options: selectedCrypto.optional,
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
setNetwork: assign((context, event) => {
|
|
172
|
+
return { selectedNetwork: event.data }
|
|
173
|
+
}),
|
|
174
|
+
setAmount: assign((context, event) => {
|
|
175
|
+
// 現金網可自由填額度,grandTotalEnable 欄位感覺不再需要?
|
|
176
|
+
if (context.selectedCrypto?.grandTotalEnable === 1) {
|
|
177
|
+
return { selectedAmount: parseFloat(context.selectedAmount || 0) + parseFloat(event.data) }
|
|
178
|
+
} else {
|
|
179
|
+
return { selectedAmount: event.data }
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
inputAmount: assign((context, event) => {
|
|
183
|
+
return { selectedAmount: event.data }
|
|
184
|
+
}),
|
|
185
|
+
setAddress: assign((context, event) => {
|
|
186
|
+
return {
|
|
187
|
+
sourceAddress: event.data,
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
setCalculation: assign((context, event) => {
|
|
191
|
+
return {
|
|
192
|
+
calculation: event.data,
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
clearCalculation: assign((context, event) => {
|
|
196
|
+
return {
|
|
197
|
+
calculation: null,
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
setResult: assign((context, event) => {
|
|
201
|
+
return {
|
|
202
|
+
result: event.data,
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
setPromotion: assign((context, event) => {
|
|
206
|
+
const { selectedCrypto, selectedAmount } = context
|
|
207
|
+
const promotion = event.data
|
|
208
|
+
return {
|
|
209
|
+
promotion,
|
|
210
|
+
selectedAmount: max(promotion.minimumAmount, selectedCrypto.minimum, selectedAmount, 0),
|
|
211
|
+
calculation: null,
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
setReceipt: assign((context, event) => {
|
|
215
|
+
return {
|
|
216
|
+
receipt: event.data,
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
},
|
|
220
|
+
guards: {
|
|
221
|
+
isCalculable: (context, event) => {
|
|
222
|
+
const { selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
223
|
+
return (
|
|
224
|
+
selectedCrypto &&
|
|
225
|
+
selectedNetwork &&
|
|
226
|
+
selectedAmount &&
|
|
227
|
+
selectedCrypto.minimum <= +selectedAmount &&
|
|
228
|
+
+selectedAmount <= selectedCrypto.maximum
|
|
229
|
+
)
|
|
230
|
+
},
|
|
231
|
+
isSubmittable: (context, event) => {
|
|
232
|
+
const { selectedCrypto, selectedNetwork, selectedAmount } = context
|
|
233
|
+
return selectedCrypto && selectedNetwork && selectedAmount
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
services: {
|
|
237
|
+
fetchCalculation: async (context, event) => {
|
|
238
|
+
const { selectedCrypto, selectedAmount, promotion } = context
|
|
239
|
+
return await request.send(
|
|
240
|
+
payment.getCryptoDepositExpectedResult({
|
|
241
|
+
method: selectedCrypto.method,
|
|
242
|
+
amount: selectedAmount,
|
|
243
|
+
cryptoCurrency: selectedCrypto.channel,
|
|
244
|
+
promotionsNo: promotion?.promotionsNo,
|
|
245
|
+
})
|
|
246
|
+
)
|
|
247
|
+
},
|
|
248
|
+
submitDeposit: async (context, event) => {
|
|
249
|
+
const { selectedCrypto, selectedNetwork, calculation, sourceAddress, promotion, receipt } = context
|
|
250
|
+
return await request.send(
|
|
251
|
+
payment.submitDepositTransactionCrypto({
|
|
252
|
+
method: selectedCrypto.method,
|
|
253
|
+
amount: calculation.actualAmount,
|
|
254
|
+
cryptoCurrency: selectedCrypto.channel,
|
|
255
|
+
cryptoNetwork: selectedNetwork.value,
|
|
256
|
+
sourceAddress: sourceAddress,
|
|
257
|
+
promotionsNo: promotion?.promotionsNo,
|
|
258
|
+
receipt,
|
|
259
|
+
})
|
|
260
|
+
)
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
}
|
|
@@ -4,12 +4,11 @@ import qrcode_v2 from './qrcode_v2.js'
|
|
|
4
4
|
import deposit_fc from './deposit_fc.js'
|
|
5
5
|
import crypto from './crypto.js'
|
|
6
6
|
import crypto_button from './crypto_button.js'
|
|
7
|
-
import crypto_qrcode_cash from './crypto_qrcode_cash.js'
|
|
8
|
-
import crypto_way_cash from './crypto_way_cash.js'
|
|
9
7
|
import direct from './direct.js'
|
|
10
8
|
import amb from './amb.js'
|
|
11
9
|
import float from './float.js'
|
|
12
10
|
import vpay from './vpay.js'
|
|
11
|
+
import krway from './krway.js'
|
|
13
12
|
import usdt from './usdt.js'
|
|
14
13
|
import manual_cash from './manual_cash.js'
|
|
15
14
|
import qrcode_cash from './qrcode_cash.js'
|
|
@@ -20,6 +19,9 @@ import loadcard_cash from './loadcard_cash.js'
|
|
|
20
19
|
import crypto_bank from './crypto_bank.js'
|
|
21
20
|
import crypto_qrcode from './crypto_qrcode.js'
|
|
22
21
|
import crypto_way from './crypto_way.js'
|
|
22
|
+
import crypto_bank_cash from './crypto_bank_cash.js'
|
|
23
|
+
import crypto_qrcode_cash from './crypto_qrcode_cash.js'
|
|
24
|
+
import crypto_way_cash from './crypto_way_cash.js'
|
|
23
25
|
|
|
24
26
|
export default {
|
|
25
27
|
manual_vn,
|
|
@@ -28,13 +30,12 @@ export default {
|
|
|
28
30
|
deposit_fc,
|
|
29
31
|
crypto,
|
|
30
32
|
crypto_button,
|
|
31
|
-
crypto_qrcode_cash,
|
|
32
|
-
crypto_way_cash,
|
|
33
33
|
direct,
|
|
34
34
|
amb,
|
|
35
35
|
float,
|
|
36
36
|
vpay,
|
|
37
37
|
usdt,
|
|
38
|
+
krway,
|
|
38
39
|
manual_cash,
|
|
39
40
|
qrcode_cash,
|
|
40
41
|
usdt_cash,
|
|
@@ -44,4 +45,7 @@ export default {
|
|
|
44
45
|
crypto_bank,
|
|
45
46
|
crypto_qrcode,
|
|
46
47
|
crypto_way,
|
|
48
|
+
crypto_bank_cash,
|
|
49
|
+
crypto_qrcode_cash,
|
|
50
|
+
crypto_way_cash,
|
|
47
51
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '@jetthai/cuora/src/api/payment.js'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'krway',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
currentCategory: 'krway',
|
|
11
|
+
paymentDetail: [],
|
|
12
|
+
currentPayment: null,
|
|
13
|
+
options: null,
|
|
14
|
+
amount: null,
|
|
15
|
+
},
|
|
16
|
+
states: {
|
|
17
|
+
loading: {
|
|
18
|
+
invoke: {
|
|
19
|
+
src: 'fetchPaymentDetail',
|
|
20
|
+
onDone: {
|
|
21
|
+
target: 'idle',
|
|
22
|
+
actions: 'setInitData',
|
|
23
|
+
},
|
|
24
|
+
onError: {
|
|
25
|
+
target: 'fail',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
idle: {},
|
|
30
|
+
searching: {
|
|
31
|
+
invoke: {
|
|
32
|
+
src: 'searchAccount',
|
|
33
|
+
onDone: {
|
|
34
|
+
target: 'searched',
|
|
35
|
+
},
|
|
36
|
+
onError: {
|
|
37
|
+
target: 'fail',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
searched: {
|
|
42
|
+
after: {
|
|
43
|
+
0: {
|
|
44
|
+
target: 'idle',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
submitting: {
|
|
49
|
+
invoke: {
|
|
50
|
+
src: 'submitDeposit',
|
|
51
|
+
onDone: {
|
|
52
|
+
target: 'idle',
|
|
53
|
+
},
|
|
54
|
+
onError: {
|
|
55
|
+
target: 'fail',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
submitted: {},
|
|
60
|
+
fail: {},
|
|
61
|
+
},
|
|
62
|
+
on: {
|
|
63
|
+
SEARCHING_ACCOUNT: {
|
|
64
|
+
target: 'searching',
|
|
65
|
+
},
|
|
66
|
+
ADD_AMOUNT: {
|
|
67
|
+
actions: 'addAmount',
|
|
68
|
+
},
|
|
69
|
+
SET_AMOUNT: {
|
|
70
|
+
actions: 'setAmount',
|
|
71
|
+
},
|
|
72
|
+
CLEAR_AMOUNT: {
|
|
73
|
+
actions: 'clearAmount',
|
|
74
|
+
},
|
|
75
|
+
SUBMIT: {
|
|
76
|
+
target: 'submitting',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
actions: {
|
|
82
|
+
setInitData: assign((context, event) => {
|
|
83
|
+
const paymentDetail = event.data
|
|
84
|
+
const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
|
|
85
|
+
const currentPayment = payments[0]
|
|
86
|
+
const options = currentPayment.optional
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
currentPayment,
|
|
90
|
+
options,
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
addAmount: assign((context, event) => {
|
|
94
|
+
return {
|
|
95
|
+
amount: parseFloat(`${context.amount || 0}`) + parseFloat(`${event.data}`),
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
setAmount: assign((context, event) => {
|
|
99
|
+
return { amount: parseFloat(`${event.data}`) }
|
|
100
|
+
}),
|
|
101
|
+
clearAmount: assign((context, event) => {
|
|
102
|
+
return { amount: null }
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
services: {
|
|
106
|
+
fetchPaymentDetail: async (context, event) => {
|
|
107
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
108
|
+
},
|
|
109
|
+
searchAccount: async (context, event) => {
|
|
110
|
+
return await request.send(payment.searchAccount())
|
|
111
|
+
},
|
|
112
|
+
submitDeposit: async (context, event) => {
|
|
113
|
+
const { currentPayment, amount } = context
|
|
114
|
+
return await request.send(
|
|
115
|
+
payment.submitDepositTransaction({
|
|
116
|
+
method: currentPayment.method,
|
|
117
|
+
amount,
|
|
118
|
+
})
|
|
119
|
+
)
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
}
|
|
@@ -28,13 +28,17 @@ export default function (request) {
|
|
|
28
28
|
states: {
|
|
29
29
|
idle: {
|
|
30
30
|
on: {
|
|
31
|
+
SIGN_UP_ID: {
|
|
32
|
+
target: 'authentication',
|
|
33
|
+
actions: ['setReCaptchaToken', 'setFriendCode', 'setSignUpId'],
|
|
34
|
+
},
|
|
31
35
|
SIGN_UP_PHONE: {
|
|
32
36
|
target: 'authentication',
|
|
33
|
-
actions: ['setReCaptchaToken', '
|
|
37
|
+
actions: ['setReCaptchaToken', 'setFriendCode', 'setSignUpPhone'],
|
|
34
38
|
},
|
|
35
39
|
SIGN_UP_EMAIL: {
|
|
36
40
|
target: 'authentication',
|
|
37
|
-
actions: ['setReCaptchaToken', '
|
|
41
|
+
actions: ['setReCaptchaToken', 'setFriendCode', 'setSignUpEmail'],
|
|
38
42
|
},
|
|
39
43
|
},
|
|
40
44
|
},
|
|
@@ -66,32 +70,61 @@ export default function (request) {
|
|
|
66
70
|
reCaptchaToken,
|
|
67
71
|
}
|
|
68
72
|
}),
|
|
69
|
-
|
|
73
|
+
setFriendCode: assign((context, event) => {
|
|
70
74
|
const { fc } = event.data
|
|
75
|
+
return { fc }
|
|
76
|
+
}),
|
|
77
|
+
setSignUpId: assign((context, event) => {
|
|
78
|
+
const { username, password, channel, subchannel, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
|
|
71
79
|
return {
|
|
72
|
-
|
|
80
|
+
signUpData: {
|
|
81
|
+
provider: 'local',
|
|
82
|
+
username,
|
|
83
|
+
password,
|
|
84
|
+
bankCode,
|
|
85
|
+
bankAccount,
|
|
86
|
+
holderName,
|
|
87
|
+
branch,
|
|
88
|
+
branchCode,
|
|
89
|
+
affiliateCode,
|
|
90
|
+
},
|
|
91
|
+
channel,
|
|
92
|
+
subchannel,
|
|
73
93
|
}
|
|
74
94
|
}),
|
|
75
95
|
setSignUpPhone: assign((context, event) => {
|
|
76
|
-
const { countryCode, phone, password, channel, subchannel } =
|
|
96
|
+
const { countryCode, phone, password, channel, subchannel, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } =
|
|
97
|
+
event.data
|
|
77
98
|
return {
|
|
78
99
|
signUpData: {
|
|
79
100
|
provider: 'phone',
|
|
80
101
|
countryCode,
|
|
81
102
|
phone,
|
|
82
103
|
password,
|
|
104
|
+
bankCode,
|
|
105
|
+
bankAccount,
|
|
106
|
+
holderName,
|
|
107
|
+
branch,
|
|
108
|
+
branchCode,
|
|
109
|
+
affiliateCode,
|
|
83
110
|
},
|
|
84
111
|
channel,
|
|
85
112
|
subchannel,
|
|
86
113
|
}
|
|
87
114
|
}),
|
|
88
115
|
setSignUpEmail: assign((context, event) => {
|
|
89
|
-
const { email, password, channel, subchannel } = event.data
|
|
116
|
+
const { email, password, channel, subchannel, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
|
|
90
117
|
return {
|
|
91
118
|
signUpData: {
|
|
92
119
|
provider: 'email',
|
|
93
120
|
email,
|
|
94
121
|
password,
|
|
122
|
+
bankCode,
|
|
123
|
+
bankAccount,
|
|
124
|
+
holderName,
|
|
125
|
+
branch,
|
|
126
|
+
branchCode,
|
|
127
|
+
affiliateCode,
|
|
95
128
|
},
|
|
96
129
|
channel,
|
|
97
130
|
subchannel,
|
|
@@ -122,7 +155,7 @@ export default function (request) {
|
|
|
122
155
|
const { channel, subchannel, signUpData, deviceTokenEnable } = context
|
|
123
156
|
const dt = await getDeviceToken({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
124
157
|
|
|
125
|
-
const affiliateCode = storage.get('ac')
|
|
158
|
+
const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
|
|
126
159
|
const messages = {
|
|
127
160
|
url: window.location.href,
|
|
128
161
|
channelOrders: [
|
|
@@ -4,6 +4,7 @@ import withdraw_vn2 from './withdraw_vn2.js'
|
|
|
4
4
|
import withdraw_crypto from './withdraw_crypto.js'
|
|
5
5
|
import withdraw_crypto2 from './withdraw_crypto2.js'
|
|
6
6
|
import withdraw_amb from './withdraw_amb.js'
|
|
7
|
+
import withdraw_krway from './withdraw_krway.js'
|
|
7
8
|
import withdraw_crypto_cash from './withdraw_crypto_cash.js'
|
|
8
9
|
import withdraw_manual_cash from './withdraw_manual_cash.js'
|
|
9
10
|
|
|
@@ -14,6 +15,7 @@ export default {
|
|
|
14
15
|
withdraw_crypto,
|
|
15
16
|
withdraw_crypto2,
|
|
16
17
|
withdraw_amb,
|
|
18
|
+
withdraw_krway,
|
|
17
19
|
withdraw_crypto_cash,
|
|
18
20
|
withdraw_manual_cash,
|
|
19
21
|
}
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import findLastIndex from 'lodash/findLastIndex.js'
|
|
3
|
+
import payment from '../../api/payment.js'
|
|
4
|
+
import user from '../../api/user.js'
|
|
5
|
+
|
|
6
|
+
export default function (request) {
|
|
7
|
+
const { appSecret } = request.config
|
|
8
|
+
return createMachine(
|
|
9
|
+
{
|
|
10
|
+
id: 'withdraw_vn2',
|
|
11
|
+
initial: 'loading',
|
|
12
|
+
context: {
|
|
13
|
+
mode: null,
|
|
14
|
+
siteConfig: null,
|
|
15
|
+
balance: null,
|
|
16
|
+
charge: null,
|
|
17
|
+
realAmount: null,
|
|
18
|
+
applyId: null,
|
|
19
|
+
methods: [],
|
|
20
|
+
paymentDetail: [],
|
|
21
|
+
bankInfo: [],
|
|
22
|
+
bankList: [],
|
|
23
|
+
currentWithdrawLimit: null,
|
|
24
|
+
targetWithdrawLimit: null,
|
|
25
|
+
attachmentType: null, // null | 'withdraw' | 'pool'
|
|
26
|
+
enableWithdrawAmount: 0,
|
|
27
|
+
enableWithdraw: false,
|
|
28
|
+
withdrawRules: [],
|
|
29
|
+
withdrawRule: {},
|
|
30
|
+
|
|
31
|
+
amount: null,
|
|
32
|
+
bank: null,
|
|
33
|
+
branch: null,
|
|
34
|
+
holderName: null,
|
|
35
|
+
|
|
36
|
+
// otp
|
|
37
|
+
requestId: null,
|
|
38
|
+
status: null,
|
|
39
|
+
target: null,
|
|
40
|
+
ttl: null,
|
|
41
|
+
},
|
|
42
|
+
states: {
|
|
43
|
+
loading: {
|
|
44
|
+
invoke: {
|
|
45
|
+
src: 'fetchInitData',
|
|
46
|
+
onDone: {
|
|
47
|
+
target: 'pending',
|
|
48
|
+
actions: ['setInitData', 'preset'],
|
|
49
|
+
},
|
|
50
|
+
onError: {
|
|
51
|
+
target: 'fail',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
pending: {
|
|
56
|
+
on: {
|
|
57
|
+
SET_MODE: {
|
|
58
|
+
target: 'fetching',
|
|
59
|
+
actions: 'setMode',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
fetching: {
|
|
64
|
+
invoke: {
|
|
65
|
+
src: 'fetchWithdrawRules',
|
|
66
|
+
onDone: {
|
|
67
|
+
target: 'mode',
|
|
68
|
+
actions: 'updateWithdrawCondition',
|
|
69
|
+
},
|
|
70
|
+
onError: {
|
|
71
|
+
target: '#withdraw_vn2.fail',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
mode: {
|
|
76
|
+
always: [{ target: 'activity', cond: 'isActivity' }, { target: 'cash' }],
|
|
77
|
+
},
|
|
78
|
+
activity: {
|
|
79
|
+
initial: 'checking',
|
|
80
|
+
states: {
|
|
81
|
+
checking: {
|
|
82
|
+
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
83
|
+
},
|
|
84
|
+
notConvertible: {
|
|
85
|
+
on: {
|
|
86
|
+
GIVE_UP: {
|
|
87
|
+
target: 'fetchWithdrawRule',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
fetchWithdrawRule: {
|
|
92
|
+
invoke: {
|
|
93
|
+
src: 'fetchWithdrawRulePreview',
|
|
94
|
+
onDone: {
|
|
95
|
+
target: 'giveUp',
|
|
96
|
+
actions: 'setWithdrawRulePreview',
|
|
97
|
+
},
|
|
98
|
+
onError: {
|
|
99
|
+
target: 'notConvertible',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
giveUp: {
|
|
104
|
+
on: {
|
|
105
|
+
CONFIRM: {
|
|
106
|
+
target: 'givingUp',
|
|
107
|
+
},
|
|
108
|
+
BACK: {
|
|
109
|
+
target: 'notConvertible',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
givingUp: {
|
|
114
|
+
invoke: {
|
|
115
|
+
src: 'giveUp',
|
|
116
|
+
onDone: {
|
|
117
|
+
target: 'gaveUp',
|
|
118
|
+
},
|
|
119
|
+
onError: {
|
|
120
|
+
target: 'convertible',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
gaveUp: {},
|
|
125
|
+
convertible: {
|
|
126
|
+
on: {
|
|
127
|
+
SUBMIT: {
|
|
128
|
+
target: 'converting',
|
|
129
|
+
actions: 'setAttachmentType',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
converting: {
|
|
134
|
+
invoke: {
|
|
135
|
+
src: 'convertFreeCredit',
|
|
136
|
+
onDone: [
|
|
137
|
+
{
|
|
138
|
+
target: '#withdraw_vn2.otp',
|
|
139
|
+
actions: 'setOtp',
|
|
140
|
+
cond: 'isOtpRequired',
|
|
141
|
+
},
|
|
142
|
+
{ target: 'converted' },
|
|
143
|
+
],
|
|
144
|
+
onError: {
|
|
145
|
+
target: 'convertible',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
converted: {
|
|
150
|
+
always: [
|
|
151
|
+
{ target: '#withdraw_vn2.cash.unbound', cond: 'isBankNotBound' },
|
|
152
|
+
{ target: '#withdraw_vn2.cash.withdrawable', cond: 'hasAttachmentType' },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
cash: {
|
|
158
|
+
initial: 'checking',
|
|
159
|
+
states: {
|
|
160
|
+
checking: {
|
|
161
|
+
always: [
|
|
162
|
+
{ target: 'inProcessing', cond: 'haveProcessing' },
|
|
163
|
+
{ target: 'notWithdrawable', cond: 'isNotWithdrawable' },
|
|
164
|
+
{ target: 'unbound', cond: 'isBankNotBound' },
|
|
165
|
+
{ target: 'withdrawable' },
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
notWithdrawable: {},
|
|
169
|
+
unbound: {
|
|
170
|
+
// to bank_binding.js
|
|
171
|
+
},
|
|
172
|
+
inProcessing: {},
|
|
173
|
+
withdrawable: {
|
|
174
|
+
on: {
|
|
175
|
+
SET_CURRENT_BANK: {
|
|
176
|
+
actions: assign((context, event) => {
|
|
177
|
+
return {
|
|
178
|
+
bank: event.data,
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
},
|
|
182
|
+
SET_AMOUNT: {
|
|
183
|
+
actions: assign((context, event) => {
|
|
184
|
+
return {
|
|
185
|
+
amount: event.data,
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
SET_ATTACHMENT_TYPE: {
|
|
190
|
+
actions: 'setAttachmentType',
|
|
191
|
+
},
|
|
192
|
+
SUBMIT: [
|
|
193
|
+
{
|
|
194
|
+
target: 'pooling',
|
|
195
|
+
cond: (context, event) => {
|
|
196
|
+
const { amount, attachmentType } = context
|
|
197
|
+
return attachmentType === 'pool' && amount > 0
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
target: 'submitting',
|
|
202
|
+
cond: 'isSubmittable',
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
submitting: {
|
|
208
|
+
invoke: {
|
|
209
|
+
src: 'submitWithdraw',
|
|
210
|
+
onDone: [
|
|
211
|
+
{
|
|
212
|
+
target: '#withdraw_vn2.otp',
|
|
213
|
+
actions: 'setOtp',
|
|
214
|
+
cond: 'isOtpRequired',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
target: 'submitted',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
onError: {
|
|
221
|
+
target: 'withdrawable',
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
submitted: {
|
|
226
|
+
entry: assign((context, event) => {
|
|
227
|
+
const { applyId, balance, realAmount, charge } = event.data
|
|
228
|
+
return { applyId, balance, realAmount, charge }
|
|
229
|
+
}),
|
|
230
|
+
invoke: {
|
|
231
|
+
src: 'fetchPaymentData',
|
|
232
|
+
onDone: {
|
|
233
|
+
target: 'inProcessing',
|
|
234
|
+
actions: 'setPaymentData',
|
|
235
|
+
},
|
|
236
|
+
onError: {
|
|
237
|
+
target: '#withdraw_vn2.fail',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
pooling: {
|
|
242
|
+
invoke: {
|
|
243
|
+
src: 'pool',
|
|
244
|
+
onDone: { target: 'pooled' },
|
|
245
|
+
onError: {
|
|
246
|
+
target: 'withdrawable',
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
pooled: {},
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
otp: {
|
|
254
|
+
type: 'parallel',
|
|
255
|
+
states: {
|
|
256
|
+
countdown: {
|
|
257
|
+
after: {
|
|
258
|
+
1000: {
|
|
259
|
+
target: 'countdown',
|
|
260
|
+
actions: 'decreaseTtl',
|
|
261
|
+
cond: (context) => context.ttl > 0,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
verification: {
|
|
266
|
+
initial: 'idle',
|
|
267
|
+
states: {
|
|
268
|
+
idle: {
|
|
269
|
+
on: {
|
|
270
|
+
ACKNOWLEDGE: {
|
|
271
|
+
target: 'acknowledging',
|
|
272
|
+
},
|
|
273
|
+
RESET_OTP: {
|
|
274
|
+
target: 'reset',
|
|
275
|
+
},
|
|
276
|
+
BACK: [
|
|
277
|
+
{
|
|
278
|
+
target: '#withdraw_vn2.activity.convertible',
|
|
279
|
+
cond: 'isActivity',
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
target: '#withdraw_vn2.cash.withdrawable',
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
acknowledging: {
|
|
288
|
+
invoke: {
|
|
289
|
+
src: 'acknowledge',
|
|
290
|
+
onDone: [
|
|
291
|
+
{
|
|
292
|
+
target: '#withdraw_vn2.activity.converted',
|
|
293
|
+
cond: 'isActivity',
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
target: '#withdraw_vn2.cash.submitted',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
onError: {
|
|
300
|
+
target: 'idle',
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
reset: {
|
|
305
|
+
invoke: {
|
|
306
|
+
src: 'resetOtp',
|
|
307
|
+
onDone: {
|
|
308
|
+
target: 'idle',
|
|
309
|
+
actions: 'setVerificationData',
|
|
310
|
+
},
|
|
311
|
+
onError: { target: 'idle' },
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
fail: {},
|
|
319
|
+
},
|
|
320
|
+
on: {
|
|
321
|
+
REFRESH: {
|
|
322
|
+
target: 'loading',
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
actions: {
|
|
328
|
+
setInitData: assign((context, event) => {
|
|
329
|
+
const { paymentDetail, bankInfo, bonus, bankList } = event.data
|
|
330
|
+
return {
|
|
331
|
+
paymentDetail,
|
|
332
|
+
bankInfo,
|
|
333
|
+
bank: bankInfo[0],
|
|
334
|
+
bonus,
|
|
335
|
+
bankList,
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
338
|
+
preset: assign((context, event) => {
|
|
339
|
+
const { siteConfig } = context
|
|
340
|
+
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
341
|
+
return {
|
|
342
|
+
methods,
|
|
343
|
+
attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
|
|
344
|
+
}
|
|
345
|
+
}),
|
|
346
|
+
setMode: assign((context, event) => {
|
|
347
|
+
return {
|
|
348
|
+
mode: event.data,
|
|
349
|
+
}
|
|
350
|
+
}),
|
|
351
|
+
updateWithdrawCondition: assign((context, event) => {
|
|
352
|
+
const { enableWithdraw, enableWithdrawAmount, currentWithdrawLimit, targetWithdrawLimit, balance } = event.data
|
|
353
|
+
const withdrawRules = event.data?.rules || []
|
|
354
|
+
const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
355
|
+
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
356
|
+
|
|
357
|
+
let maxWithdrawAmount = 0
|
|
358
|
+
|
|
359
|
+
if (lastMatchedIndex > -1) {
|
|
360
|
+
rules[lastMatchedIndex].match = true
|
|
361
|
+
maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
|
|
362
|
+
} else if (rules.length > 0) {
|
|
363
|
+
maxWithdrawAmount = rules[0].maxWithdrawAmount
|
|
364
|
+
} else {
|
|
365
|
+
maxWithdrawAmount = balance
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return {
|
|
369
|
+
balance,
|
|
370
|
+
currentWithdrawLimit,
|
|
371
|
+
targetWithdrawLimit,
|
|
372
|
+
maxWithdrawAmount,
|
|
373
|
+
enableWithdrawAmount: +enableWithdrawAmount,
|
|
374
|
+
enableWithdraw,
|
|
375
|
+
withdrawRules,
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
setWithdrawRulePreview: assign((context, event) => {
|
|
379
|
+
return {
|
|
380
|
+
withdrawRule: event.data,
|
|
381
|
+
}
|
|
382
|
+
}),
|
|
383
|
+
setPaymentData: assign((context, event) => {
|
|
384
|
+
const { bankInfo, bonus, paymentDetail } = event.data
|
|
385
|
+
return {
|
|
386
|
+
bankInfo,
|
|
387
|
+
bonus,
|
|
388
|
+
paymentDetail,
|
|
389
|
+
}
|
|
390
|
+
}),
|
|
391
|
+
setOtp: assign((context, event) => {
|
|
392
|
+
const { requestId, status, target, ttl } = event.data
|
|
393
|
+
return {
|
|
394
|
+
requestId,
|
|
395
|
+
status,
|
|
396
|
+
target,
|
|
397
|
+
ttl,
|
|
398
|
+
}
|
|
399
|
+
}),
|
|
400
|
+
decreaseTtl: assign((context, evnet) => {
|
|
401
|
+
const second = context.ttl
|
|
402
|
+
return {
|
|
403
|
+
ttl: Math.max(second - 1, 0),
|
|
404
|
+
}
|
|
405
|
+
}),
|
|
406
|
+
setVerificationData: assign((context, event) => {
|
|
407
|
+
const { requestId, ttl, target } = event.data
|
|
408
|
+
return {
|
|
409
|
+
requestId,
|
|
410
|
+
ttl,
|
|
411
|
+
target,
|
|
412
|
+
}
|
|
413
|
+
}),
|
|
414
|
+
setAttachmentType: assign((context, event) => {
|
|
415
|
+
return {
|
|
416
|
+
attachmentType: event.data,
|
|
417
|
+
}
|
|
418
|
+
}),
|
|
419
|
+
},
|
|
420
|
+
guards: {
|
|
421
|
+
isActivity: (context, event) => {
|
|
422
|
+
return context.mode === 'ACTIVITY'
|
|
423
|
+
},
|
|
424
|
+
hasAttachmentType: (context, event) => {
|
|
425
|
+
return ['withdraw', 'pool'].includes(context.attachmentType)
|
|
426
|
+
},
|
|
427
|
+
haveProcessing: (context, event) => {
|
|
428
|
+
return (context.paymentDetail?.[0]?.processing || []).length > 0
|
|
429
|
+
},
|
|
430
|
+
isBankNotBound: (context, event) => {
|
|
431
|
+
return !context.bankInfo?.length
|
|
432
|
+
},
|
|
433
|
+
isSubmittable: (context, event) => {
|
|
434
|
+
const { bank, amount } = context
|
|
435
|
+
return bank && amount > 0
|
|
436
|
+
},
|
|
437
|
+
isConvertible: (context, event) => {
|
|
438
|
+
const { balance, enableWithdraw } = context
|
|
439
|
+
return balance > 0 && enableWithdraw
|
|
440
|
+
},
|
|
441
|
+
isNotWithdrawable: (context, event) => {
|
|
442
|
+
const { balance, enableWithdraw, paymentDetail } = context
|
|
443
|
+
const minWithdrawAmount = paymentDetail[0]?.minimum || 0
|
|
444
|
+
return !enableWithdraw || balance < minWithdrawAmount
|
|
445
|
+
},
|
|
446
|
+
isOtpRequired: (context, event) => {
|
|
447
|
+
return event.data?.status === 'otp-verifying'
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
services: {
|
|
451
|
+
fetchInitData: async (context, event) => {
|
|
452
|
+
const [paymentDetail = [], { bonus, bankInfo }] = await Promise.all([
|
|
453
|
+
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
454
|
+
request.send(payment.getPaymentInfo()),
|
|
455
|
+
])
|
|
456
|
+
const bankList = await request.send(payment.getWithdrawBankList())
|
|
457
|
+
const newBankInfo = bankInfo
|
|
458
|
+
.map((item) => {
|
|
459
|
+
const matchedBank = bankList.find((bank) => bank.bankCode === item.bankCode)
|
|
460
|
+
return matchedBank ? { ...item, ...matchedBank } : null
|
|
461
|
+
})
|
|
462
|
+
.filter(Boolean)
|
|
463
|
+
return { paymentDetail, bonus, bankInfo: newBankInfo, bankList }
|
|
464
|
+
},
|
|
465
|
+
fetchPaymentData: async (context, event) => {
|
|
466
|
+
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
467
|
+
const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
|
|
468
|
+
return { bonus, bankInfo, paymentDetail }
|
|
469
|
+
},
|
|
470
|
+
fetchWithdrawRules: async (context, event) => {
|
|
471
|
+
const { mode } = context
|
|
472
|
+
return await request.send(payment.getDoubleWalletWithdrawRule({ walletType: mode }))
|
|
473
|
+
},
|
|
474
|
+
fetchWithdrawRulePreview: async (context, event) => {
|
|
475
|
+
const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'giveup' }))
|
|
476
|
+
return data
|
|
477
|
+
},
|
|
478
|
+
submitWithdraw: async (context, event) => {
|
|
479
|
+
const { bank, amount } = context
|
|
480
|
+
const { method } = context.paymentDetail[0]
|
|
481
|
+
const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(bank.bankCode) ? '' : bank.branch
|
|
482
|
+
return await request.send(
|
|
483
|
+
payment.submitWithdrawTransactionVN({
|
|
484
|
+
method,
|
|
485
|
+
amount,
|
|
486
|
+
applyerBankCode: bank.bankCode,
|
|
487
|
+
applyerAccountNumber: bank.accountNumber,
|
|
488
|
+
branch: branchTemp,
|
|
489
|
+
holderName: bank.holderName,
|
|
490
|
+
})
|
|
491
|
+
)
|
|
492
|
+
},
|
|
493
|
+
convertFreeCredit: async (context, event) => {
|
|
494
|
+
return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
|
|
495
|
+
},
|
|
496
|
+
resetOtp: async (context, event) => {
|
|
497
|
+
const { requestId, target } = context
|
|
498
|
+
return await request.send(user.otpReset({ requestId, target }))
|
|
499
|
+
},
|
|
500
|
+
acknowledge: async (context, event) => {
|
|
501
|
+
const { requestId, target } = context
|
|
502
|
+
const code = event.data
|
|
503
|
+
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
504
|
+
},
|
|
505
|
+
pool: async (context, event) => {
|
|
506
|
+
const { amount } = context
|
|
507
|
+
return await request.send(payment.restore({ amount }))
|
|
508
|
+
},
|
|
509
|
+
giveUp: async (context, event) => {
|
|
510
|
+
return await request.send(payment.giveUp())
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
}
|