@jetthai/cuora 1.1.9-bc88-1 → 1.1.10
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 +1 -3
- package/package.json +1 -1
- package/src/api/payment.js +5 -25
- package/src/machine/auth.js +11 -4
- package/src/machine/deposit/crypto.js +1 -1
- package/src/machine/deposit/crypto_button.js +1 -1
- package/src/machine/deposit/deposit_fc.js +5 -8
- package/src/machine/deposit/index.js +1 -16
- package/src/machine/deposit/qrcode_v2.js +1 -1
- package/src/machine/deposit/qrcode_vn.js +1 -1
- package/src/machine/index.js +0 -4
- package/src/machine/withdraw_crypto.js +25 -37
- package/src/machine/withdraw_fc.js +1 -1
- package/src/machine/bank_binding_amb.js +0 -141
- package/src/machine/deposit/amb.js +0 -90
- package/src/machine/deposit/float.js +0 -158
- package/src/machine/deposit/vpay.js +0 -141
- package/src/machine/withdraw_amb.js +0 -424
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
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.
|
|
6
|
-
|
|
7
|
-
### [1.1.9-bc88](https://github.com/jetthai/cuora-module/compare/v1.1.9...v1.1.9-bc88) (2022-12-13)
|
|
5
|
+
### [1.1.10](https://github.com/jetthai/cuora-module/compare/v1.1.9...v1.1.10) (2022-12-21)
|
|
8
6
|
|
|
9
7
|
### [1.1.9](https://github.com/jetthai/cuora-module/compare/v1.1.5-1...v1.1.9) (2022-12-07)
|
|
10
8
|
|
package/package.json
CHANGED
package/src/api/payment.js
CHANGED
|
@@ -2,29 +2,14 @@ export default {
|
|
|
2
2
|
// getPaymentHistory: () => ({ url: 'payment/history', method: 'post' }),
|
|
3
3
|
getPaymentHistory: (returnDays) => ({ url: 'payment/v2/history', method: 'post', params: { returnDays } }),
|
|
4
4
|
getSpotMarket: () => ({ url: 'payment/spotmarket', method: 'get' }),
|
|
5
|
-
getTransactionHistory: (payload) => ({
|
|
6
|
-
url: 'payment/v2/transactionHistory',
|
|
7
|
-
method: 'post',
|
|
8
|
-
params: { ...payload },
|
|
9
|
-
}),
|
|
5
|
+
getTransactionHistory: (payload) => ({ url: 'payment/v2/transactionHistory', method: 'post', params: { ...payload } }),
|
|
10
6
|
getTransactionHistoryOptions: () => ({ url: 'payment/v2/category/options', method: 'get' }),
|
|
11
7
|
// getPaymentInfo: () => ({ url: `payment/paymentInfo`, method: 'get' }),
|
|
12
8
|
getPaymentInfo: () => ({ url: `payment/v2/paymentInfo`, method: 'get' }),
|
|
13
9
|
updatePaymentInfo: ({ bankCode, branch, holderName, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn, bonus, paymentProvider }) => ({
|
|
14
10
|
url: 'payment/v2/updatePaymentInfo',
|
|
15
11
|
method: 'post',
|
|
16
|
-
params: {
|
|
17
|
-
bankCode,
|
|
18
|
-
branch,
|
|
19
|
-
holderName,
|
|
20
|
-
bankAccount,
|
|
21
|
-
firstNameTh,
|
|
22
|
-
lastNameTh,
|
|
23
|
-
firstNameEn,
|
|
24
|
-
lastNameEn,
|
|
25
|
-
bonus,
|
|
26
|
-
paymentProvider,
|
|
27
|
-
},
|
|
12
|
+
params: { bankCode, branch, holderName, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn, bonus, paymentProvider },
|
|
28
13
|
}),
|
|
29
14
|
getBankList: (paymentMethod) => ({ url: `payment/v2/${paymentMethod}/getBankList`, method: 'get' }),
|
|
30
15
|
makeTransaction: ({ type, payload, paymentMethod }) => ({
|
|
@@ -59,7 +44,7 @@ export default {
|
|
|
59
44
|
method: 'post',
|
|
60
45
|
params: { transferType: 'WITHDRAW', amount, cryptoNetwork },
|
|
61
46
|
}),
|
|
62
|
-
|
|
47
|
+
submitDepositTransaction: ({ method, amount, cryptoCurrency, cryptoNetwork, sourceAddress }) => ({
|
|
63
48
|
url: `payment/v2/${method}/transaction`,
|
|
64
49
|
method: 'post',
|
|
65
50
|
params: { transferType: 'DEPOSIT', amount, cryptoCurrency, cryptoNetwork, sourceAddress },
|
|
@@ -94,12 +79,12 @@ export default {
|
|
|
94
79
|
receipt,
|
|
95
80
|
},
|
|
96
81
|
}),
|
|
97
|
-
|
|
82
|
+
submitDepositTransactionQrcode: ({ method, amount }) => ({
|
|
98
83
|
url: `payment/v2/${method}/transaction`,
|
|
99
84
|
method: 'post',
|
|
100
85
|
params: { transferType: 'DEPOSIT', amount },
|
|
101
86
|
}),
|
|
102
|
-
|
|
87
|
+
submitWithdrawTransaction: ({ method, amount, cryptoCurrency, cryptoNetwork, targetAddress }) => ({
|
|
103
88
|
url: `payment/v2/${method}/transaction`,
|
|
104
89
|
method: 'post',
|
|
105
90
|
params: { transferType: 'WITHDRAW', amount, cryptoCurrency, cryptoNetwork, targetAddress },
|
|
@@ -109,9 +94,4 @@ export default {
|
|
|
109
94
|
method: 'post',
|
|
110
95
|
params: { transferType: 'WITHDRAW', amount, applyerBankCode, applyerAccountNumber, branch, holderName },
|
|
111
96
|
}),
|
|
112
|
-
submitWithdrawTransactionAmb: ({ method, amount }) => ({
|
|
113
|
-
url: `payment/v2/${method}/transaction`,
|
|
114
|
-
method: 'post',
|
|
115
|
-
params: { transferType: 'WITHDRAW', amount },
|
|
116
|
-
}),
|
|
117
97
|
}
|
package/src/machine/auth.js
CHANGED
|
@@ -98,7 +98,7 @@ export default function (request) {
|
|
|
98
98
|
initial: 'pending',
|
|
99
99
|
states: {
|
|
100
100
|
pending: {
|
|
101
|
-
always: [{ target: '#auth.
|
|
101
|
+
always: [{ target: '#auth.inlineFinish', cond: 'isNotInline' }],
|
|
102
102
|
after: {
|
|
103
103
|
TIMEOUT: {
|
|
104
104
|
target: 'fetching',
|
|
@@ -119,6 +119,13 @@ export default function (request) {
|
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
|
+
inlineFinish: {
|
|
123
|
+
after: {
|
|
124
|
+
0: {
|
|
125
|
+
target: 'login',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
122
129
|
login: {
|
|
123
130
|
initial: 'fetching',
|
|
124
131
|
states: {
|
|
@@ -327,7 +334,7 @@ export default function (request) {
|
|
|
327
334
|
{ channel: defaultChannel, subchannel: defaultSubchannel },
|
|
328
335
|
{ channel: channel, subchannel: subchannel },
|
|
329
336
|
],
|
|
330
|
-
referralCode
|
|
337
|
+
referralCode,
|
|
331
338
|
}
|
|
332
339
|
sentry.captureMessage(JSON.stringify(messages))
|
|
333
340
|
|
|
@@ -335,8 +342,8 @@ export default function (request) {
|
|
|
335
342
|
if (referralCode) {
|
|
336
343
|
referralObj.referralCode = referralCode
|
|
337
344
|
} else {
|
|
338
|
-
referralObj.channel = storage.get('channel') || defaultChannel || channel,
|
|
339
|
-
|
|
345
|
+
;(referralObj.channel = storage.get('channel') || defaultChannel || channel),
|
|
346
|
+
(referralObj.subchannel = storage.get('subchannel') || defaultSubchannel || subchannel)
|
|
340
347
|
}
|
|
341
348
|
|
|
342
349
|
const redirectURL = urljoin(
|
|
@@ -252,7 +252,7 @@ export default function (request) {
|
|
|
252
252
|
submitDeposit: async (context, event) => {
|
|
253
253
|
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
254
254
|
return await request.send(
|
|
255
|
-
payment.
|
|
255
|
+
payment.submitDepositTransaction({
|
|
256
256
|
method: selectedCrypto.method,
|
|
257
257
|
amount: calculation.actualAmount,
|
|
258
258
|
cryptoCurrency: selectedCrypto.channel,
|
|
@@ -304,7 +304,7 @@ export default function (request) {
|
|
|
304
304
|
submitDeposit: async (context, event) => {
|
|
305
305
|
const { selectedCrypto, selectedNetwork, calculation, sourceAddress } = context
|
|
306
306
|
return await request.send(
|
|
307
|
-
payment.
|
|
307
|
+
payment.submitDepositTransaction({
|
|
308
308
|
method: selectedCrypto.method,
|
|
309
309
|
amount: calculation.actualAmount,
|
|
310
310
|
cryptoCurrency: selectedCrypto.channel,
|
|
@@ -59,7 +59,9 @@ export default function (request) {
|
|
|
59
59
|
},
|
|
60
60
|
checking: {
|
|
61
61
|
entry: 'clearCalculatedResult',
|
|
62
|
-
always: [
|
|
62
|
+
always: [
|
|
63
|
+
{ target: 'debouncing', cond: 'isCalculable' },
|
|
64
|
+
{ target: 'loaded'}]
|
|
63
65
|
},
|
|
64
66
|
debouncing: {
|
|
65
67
|
after: {
|
|
@@ -130,12 +132,7 @@ export default function (request) {
|
|
|
130
132
|
actions: {
|
|
131
133
|
setCryptos: assign((context, event) => {
|
|
132
134
|
return {
|
|
133
|
-
cryptos: event.data.map((crypto) => ({
|
|
134
|
-
...crypto,
|
|
135
|
-
label: crypto.channel,
|
|
136
|
-
value: crypto.method,
|
|
137
|
-
icon: crypto.channel,
|
|
138
|
-
})),
|
|
135
|
+
cryptos: event.data.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })),
|
|
139
136
|
}
|
|
140
137
|
}),
|
|
141
138
|
setCrypto: assign((context, event) => {
|
|
@@ -241,7 +238,7 @@ export default function (request) {
|
|
|
241
238
|
submitDeposit: async (context, event) => {
|
|
242
239
|
const { currentCrypto, currentNetwork, calculatedResult } = context
|
|
243
240
|
return await request.send(
|
|
244
|
-
payment.
|
|
241
|
+
payment.submitDepositTransaction({
|
|
245
242
|
method: currentCrypto.method,
|
|
246
243
|
amount: calculatedResult.actualAmount,
|
|
247
244
|
cryptoCurrency: currentCrypto.channel,
|
|
@@ -6,20 +6,5 @@ import deposit_fc from './deposit_fc.js'
|
|
|
6
6
|
import crypto from './crypto.js'
|
|
7
7
|
import crypto_button from './crypto_button.js'
|
|
8
8
|
import direct from './direct.js'
|
|
9
|
-
import amb from './amb.js'
|
|
10
|
-
import float from './float.js'
|
|
11
|
-
import vpay from './vpay.js'
|
|
12
9
|
|
|
13
|
-
export default {
|
|
14
|
-
manual_vn,
|
|
15
|
-
loadcard_vn,
|
|
16
|
-
qrcode_vn,
|
|
17
|
-
qrcode_v2,
|
|
18
|
-
deposit_fc,
|
|
19
|
-
crypto,
|
|
20
|
-
crypto_button,
|
|
21
|
-
direct,
|
|
22
|
-
amb,
|
|
23
|
-
float,
|
|
24
|
-
vpay,
|
|
25
|
-
}
|
|
10
|
+
export default { manual_vn, loadcard_vn, qrcode_vn, qrcode_v2, deposit_fc, crypto, crypto_button, direct }
|
|
@@ -239,7 +239,7 @@ export default function (request) {
|
|
|
239
239
|
submitDeposit: async (context, event) => {
|
|
240
240
|
const { currentMethod, selectedAmount } = context
|
|
241
241
|
return await request.send(
|
|
242
|
-
payment.
|
|
242
|
+
payment.submitDepositTransactionQrcode({
|
|
243
243
|
method: currentMethod,
|
|
244
244
|
amount: selectedAmount,
|
|
245
245
|
})
|
|
@@ -194,7 +194,7 @@ export default function (request) {
|
|
|
194
194
|
submitDeposit: async (context, event) => {
|
|
195
195
|
const { currentMethod, selectedAmount } = context
|
|
196
196
|
return await request.send(
|
|
197
|
-
payment.
|
|
197
|
+
payment.submitDepositTransactionQrcode({
|
|
198
198
|
method: currentMethod,
|
|
199
199
|
amount: selectedAmount,
|
|
200
200
|
})
|
package/src/machine/index.js
CHANGED
|
@@ -22,11 +22,9 @@ import user_info from './user_info.js'
|
|
|
22
22
|
import user_sign_up from './user_sign_up.js'
|
|
23
23
|
import user_reset_password from './user_reset_password.js'
|
|
24
24
|
import bank_binding from './bank_binding.js'
|
|
25
|
-
import bank_binding_amb from './bank_binding_amb.js'
|
|
26
25
|
import withdraw_fc from './withdraw_fc.js'
|
|
27
26
|
import withdraw_vn from './withdraw_vn.js'
|
|
28
27
|
import withdraw_crypto from './withdraw_crypto.js'
|
|
29
|
-
import withdraw_amb from './withdraw_amb.js'
|
|
30
28
|
import deposit from './deposit/index.js'
|
|
31
29
|
import bonus from './bonus.js'
|
|
32
30
|
import leaderboard from './leaderboard.js'
|
|
@@ -60,11 +58,9 @@ export default {
|
|
|
60
58
|
user_sign_up,
|
|
61
59
|
user_reset_password,
|
|
62
60
|
bank_binding,
|
|
63
|
-
bank_binding_amb,
|
|
64
61
|
withdraw_fc,
|
|
65
62
|
withdraw_vn,
|
|
66
63
|
withdraw_crypto,
|
|
67
|
-
withdraw_amb,
|
|
68
64
|
...deposit,
|
|
69
65
|
bonus,
|
|
70
66
|
leaderboard,
|
|
@@ -84,16 +84,13 @@ export default function (request) {
|
|
|
84
84
|
converting: {
|
|
85
85
|
invoke: {
|
|
86
86
|
src: 'submitWithdrawFree',
|
|
87
|
-
onDone: [
|
|
88
|
-
{
|
|
87
|
+
onDone: [{
|
|
89
88
|
target: '#withdraw_crypto.otp',
|
|
90
89
|
actions: 'setOtp',
|
|
91
|
-
cond: 'isOtpRequired'
|
|
92
|
-
},
|
|
93
|
-
{
|
|
90
|
+
cond: 'isOtpRequired'
|
|
91
|
+
}, {
|
|
94
92
|
target: 'converted',
|
|
95
|
-
},
|
|
96
|
-
],
|
|
93
|
+
}],
|
|
97
94
|
onError: {
|
|
98
95
|
target: 'convertible',
|
|
99
96
|
},
|
|
@@ -161,16 +158,13 @@ export default function (request) {
|
|
|
161
158
|
submitting: {
|
|
162
159
|
invoke: {
|
|
163
160
|
src: 'submitWithdraw',
|
|
164
|
-
onDone: [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
target: 'submitted',
|
|
172
|
-
},
|
|
173
|
-
],
|
|
161
|
+
onDone: [{
|
|
162
|
+
target: '#withdraw_crypto.otp',
|
|
163
|
+
actions: 'setOtp',
|
|
164
|
+
cond: 'isOtpRequired'
|
|
165
|
+
}, {
|
|
166
|
+
target: 'submitted',
|
|
167
|
+
}],
|
|
174
168
|
onError: {
|
|
175
169
|
target: 'withdrawable',
|
|
176
170
|
},
|
|
@@ -202,29 +196,23 @@ export default function (request) {
|
|
|
202
196
|
RESET_OTP: {
|
|
203
197
|
target: 'reset',
|
|
204
198
|
},
|
|
205
|
-
BACK: [
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
target: '#withdraw_crypto.cash.submittable',
|
|
212
|
-
},
|
|
213
|
-
],
|
|
199
|
+
BACK: [{
|
|
200
|
+
target: '#withdraw_crypto.free.convertible',
|
|
201
|
+
cond: 'isFree'
|
|
202
|
+
}, {
|
|
203
|
+
target: '#withdraw_crypto.cash.submittable',
|
|
204
|
+
}],
|
|
214
205
|
},
|
|
215
206
|
},
|
|
216
207
|
acknowledging: {
|
|
217
208
|
invoke: {
|
|
218
209
|
src: 'acknowledge',
|
|
219
|
-
onDone: [
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
target: '#withdraw_crypto.cash.submitted',
|
|
226
|
-
},
|
|
227
|
-
],
|
|
210
|
+
onDone: [{
|
|
211
|
+
target: '#withdraw_crypto.free.converted',
|
|
212
|
+
cond: 'isFree'
|
|
213
|
+
}, {
|
|
214
|
+
target: '#withdraw_crypto.cash.submitted',
|
|
215
|
+
}],
|
|
228
216
|
onError: {
|
|
229
217
|
target: 'idle',
|
|
230
218
|
},
|
|
@@ -401,7 +389,7 @@ export default function (request) {
|
|
|
401
389
|
},
|
|
402
390
|
isOtpRequired: (context, event) => {
|
|
403
391
|
return event.data?.status === 'otp-verifying'
|
|
404
|
-
}
|
|
392
|
+
}
|
|
405
393
|
},
|
|
406
394
|
services: {
|
|
407
395
|
fetchInitData: async (context, event) => {
|
|
@@ -423,7 +411,7 @@ export default function (request) {
|
|
|
423
411
|
submitWithdraw: async (context, event) => {
|
|
424
412
|
const { crypto, selectedNetwork, address, amount } = context
|
|
425
413
|
return await request.send(
|
|
426
|
-
api.
|
|
414
|
+
api.submitWithdrawTransaction({
|
|
427
415
|
method: crypto.method,
|
|
428
416
|
amount,
|
|
429
417
|
cryptoCurrency: crypto.channel,
|
|
@@ -215,7 +215,7 @@ export default function (request) {
|
|
|
215
215
|
const { crypto, currentNetwork, currentAddress, withdrawAmount } = context
|
|
216
216
|
const method = crypto.method
|
|
217
217
|
return await request.send(
|
|
218
|
-
api.
|
|
218
|
+
api.submitWithdrawTransaction({
|
|
219
219
|
method,
|
|
220
220
|
amount: withdrawAmount,
|
|
221
221
|
cryptoCurrency: crypto.channel,
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '../api/payment.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'bank_binding_amb',
|
|
8
|
-
initial: 'fetching',
|
|
9
|
-
context: {
|
|
10
|
-
hasAnyAccount: false,
|
|
11
|
-
bankList: [],
|
|
12
|
-
bank: null,
|
|
13
|
-
// bonus: 0,
|
|
14
|
-
bankAccount: null,
|
|
15
|
-
firstNameTh: null,
|
|
16
|
-
lastNameTh: null,
|
|
17
|
-
firstNameEn: null,
|
|
18
|
-
lastNameEn: null,
|
|
19
|
-
},
|
|
20
|
-
states: {
|
|
21
|
-
fetching: {
|
|
22
|
-
invoke: {
|
|
23
|
-
src: 'fetchInitData',
|
|
24
|
-
onDone: {
|
|
25
|
-
target: 'idle',
|
|
26
|
-
actions: 'setBanks',
|
|
27
|
-
},
|
|
28
|
-
onError: {
|
|
29
|
-
target: 'idle',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
idle: {
|
|
34
|
-
on: {
|
|
35
|
-
SET_BANK_CODE: {
|
|
36
|
-
actions: assign((context, event) => {
|
|
37
|
-
console.log(event.data)
|
|
38
|
-
return {
|
|
39
|
-
bank: event.data,
|
|
40
|
-
}
|
|
41
|
-
}),
|
|
42
|
-
},
|
|
43
|
-
SET_BANK_ACCOUNT: {
|
|
44
|
-
actions: assign((context, event) => {
|
|
45
|
-
return {
|
|
46
|
-
bankAccount: event.data,
|
|
47
|
-
}
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
SET_FIRST_NAME_TH: {
|
|
51
|
-
actions: assign((context, event) => {
|
|
52
|
-
return {
|
|
53
|
-
firstNameTh: event.data,
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
56
|
-
},
|
|
57
|
-
SET_LAST_NAME_TH: {
|
|
58
|
-
actions: assign((context, event) => {
|
|
59
|
-
return {
|
|
60
|
-
lastNameTh: event.data,
|
|
61
|
-
}
|
|
62
|
-
}),
|
|
63
|
-
},
|
|
64
|
-
SET_FIRST_NAME_EN: {
|
|
65
|
-
actions: assign((context, event) => {
|
|
66
|
-
return {
|
|
67
|
-
firstNameEn: event.data,
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
SET_LAST_NAME_EN: {
|
|
72
|
-
actions: assign((context, event) => {
|
|
73
|
-
return {
|
|
74
|
-
lastNameEn: event.data,
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
77
|
-
},
|
|
78
|
-
BIND_BANK: {
|
|
79
|
-
target: 'binding',
|
|
80
|
-
cond: 'isBindable',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
binding: {
|
|
85
|
-
invoke: {
|
|
86
|
-
src: 'updatePaymentInfo',
|
|
87
|
-
onDone: {
|
|
88
|
-
target: 'bound',
|
|
89
|
-
},
|
|
90
|
-
onError: {
|
|
91
|
-
target: 'idle',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
bound: {},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
actions: {
|
|
100
|
-
setBanks: assign((context, event) => {
|
|
101
|
-
const { bankList = [], paymentInfo = {} } = event.data
|
|
102
|
-
const { bankInfo = [] } = paymentInfo
|
|
103
|
-
return {
|
|
104
|
-
hasAnyAccount: bankInfo.length > 0,
|
|
105
|
-
holderName: bankInfo[0]?.holderName,
|
|
106
|
-
bankList,
|
|
107
|
-
bank: bankList[0],
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
},
|
|
111
|
-
guards: {
|
|
112
|
-
isBindable: (context, event) => {
|
|
113
|
-
const { bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
114
|
-
|
|
115
|
-
return bank.bankCode && bankAccount && firstNameTh && lastNameTh && firstNameEn && lastNameEn
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
services: {
|
|
119
|
-
fetchInitData: async (context, event) => {
|
|
120
|
-
const [bankList, paymentInfo] = await Promise.all([request.send(payment.getBankList('amb')), request.send(payment.getPaymentInfo())])
|
|
121
|
-
return { bankList, paymentInfo }
|
|
122
|
-
},
|
|
123
|
-
updatePaymentInfo: async (context, event) => {
|
|
124
|
-
const { bonus, bank, bankAccount, firstNameTh, lastNameTh, firstNameEn, lastNameEn } = context
|
|
125
|
-
return await request.send(
|
|
126
|
-
payment.updatePaymentInfo({
|
|
127
|
-
paymentProvider: 'amb',
|
|
128
|
-
// bonus,
|
|
129
|
-
bankCode: bank.bankCode,
|
|
130
|
-
bankAccount,
|
|
131
|
-
firstNameTh,
|
|
132
|
-
lastNameTh,
|
|
133
|
-
firstNameEn,
|
|
134
|
-
lastNameEn,
|
|
135
|
-
})
|
|
136
|
-
)
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
}
|
|
140
|
-
)
|
|
141
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '../../api/payment.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'amb',
|
|
8
|
-
initial: 'loading',
|
|
9
|
-
context: {
|
|
10
|
-
bankList: [],
|
|
11
|
-
userAccount: {},
|
|
12
|
-
houseAccountName: null,
|
|
13
|
-
houseAccountNumber: null,
|
|
14
|
-
houseBankName: null,
|
|
15
|
-
method: 'amb',
|
|
16
|
-
},
|
|
17
|
-
states: {
|
|
18
|
-
loading: {
|
|
19
|
-
initial: 'checkingUserAccount',
|
|
20
|
-
states: {
|
|
21
|
-
checkingUserAccount: {
|
|
22
|
-
invoke: {
|
|
23
|
-
src: 'fetchPaymentInfo',
|
|
24
|
-
onDone: [
|
|
25
|
-
{
|
|
26
|
-
target: 'initializing',
|
|
27
|
-
actions: 'setUserAccount',
|
|
28
|
-
cond: 'hasUserAccount',
|
|
29
|
-
},
|
|
30
|
-
{ target: '#amb.accountUnbound' },
|
|
31
|
-
],
|
|
32
|
-
onError: {
|
|
33
|
-
target: '#amb.unavailable',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
initializing: {
|
|
38
|
-
invoke: {
|
|
39
|
-
src: 'initialize',
|
|
40
|
-
onDone: { target: '#amb.finish', actions: 'setInitialization' },
|
|
41
|
-
onError: {
|
|
42
|
-
target: '#amb.unavailable',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
finish: {},
|
|
49
|
-
accountUnbound: {},
|
|
50
|
-
unavailable: {},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
actions: {
|
|
55
|
-
setUserAccount: assign((context, event) => {
|
|
56
|
-
return {
|
|
57
|
-
userAccount: event.data.bankInfo?.[0],
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
setInitialization: assign((context, event) => {
|
|
61
|
-
const { houseAccount, bankList } = event.data
|
|
62
|
-
return {
|
|
63
|
-
houseAccountName: houseAccount.accountName,
|
|
64
|
-
houseAccountNumber: houseAccount.accountNumber,
|
|
65
|
-
houseBankName: houseAccount.bankName,
|
|
66
|
-
bankList,
|
|
67
|
-
}
|
|
68
|
-
}),
|
|
69
|
-
},
|
|
70
|
-
guards: {
|
|
71
|
-
hasUserAccount: (context, event) => {
|
|
72
|
-
return event.data.bankInfo?.[0]
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
services: {
|
|
76
|
-
fetchPaymentInfo: async (context, event) => {
|
|
77
|
-
return await request.send(payment.getPaymentInfo())
|
|
78
|
-
},
|
|
79
|
-
initialize: async (context, event) => {
|
|
80
|
-
const { method } = context
|
|
81
|
-
const [houseAccount, bankList] = await Promise.all([
|
|
82
|
-
request.send(payment.submitDepositTransaction({ method })),
|
|
83
|
-
request.send(payment.getBankList(method)),
|
|
84
|
-
])
|
|
85
|
-
return { houseAccount, bankList }
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '../../api/payment.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'float',
|
|
8
|
-
initial: 'loading',
|
|
9
|
-
context: {
|
|
10
|
-
method: 'amb_float',
|
|
11
|
-
userAccount: {},
|
|
12
|
-
amount: 0,
|
|
13
|
-
|
|
14
|
-
bankList: [],
|
|
15
|
-
options: [],
|
|
16
|
-
minimum: 0,
|
|
17
|
-
maximum: 0,
|
|
18
|
-
|
|
19
|
-
houseAccountName: null,
|
|
20
|
-
houseAccountNumber: null,
|
|
21
|
-
houseBankName: null,
|
|
22
|
-
calculatedAmount: 0,
|
|
23
|
-
|
|
24
|
-
ttl: 120,
|
|
25
|
-
},
|
|
26
|
-
states: {
|
|
27
|
-
loading: {
|
|
28
|
-
initial: 'checkingUserAccount',
|
|
29
|
-
states: {
|
|
30
|
-
checkingUserAccount: {
|
|
31
|
-
invoke: {
|
|
32
|
-
src: 'fetchPaymentInfo',
|
|
33
|
-
onDone: [
|
|
34
|
-
{
|
|
35
|
-
target: 'initializing',
|
|
36
|
-
actions: 'setUserAccount',
|
|
37
|
-
cond: 'hasUserAccount',
|
|
38
|
-
},
|
|
39
|
-
{ target: '#float.accountUnbound' },
|
|
40
|
-
],
|
|
41
|
-
onError: {
|
|
42
|
-
target: '#float.unavailable',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
initializing: {
|
|
47
|
-
invoke: {
|
|
48
|
-
src: 'initialize',
|
|
49
|
-
onDone: { target: '#float.submittable', actions: 'setInitialization' },
|
|
50
|
-
onError: {
|
|
51
|
-
target: '#float.unavailable',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
submittable: {
|
|
58
|
-
on: {
|
|
59
|
-
ADD: {
|
|
60
|
-
actions: 'add',
|
|
61
|
-
},
|
|
62
|
-
CLEAR: {
|
|
63
|
-
actions: 'clear',
|
|
64
|
-
},
|
|
65
|
-
SUBMIT: {
|
|
66
|
-
target: 'submitting',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
submitting: {
|
|
71
|
-
invoke: {
|
|
72
|
-
src: 'submitDeposit',
|
|
73
|
-
onDone: { target: 'countdown', actions: 'setHouseBank' },
|
|
74
|
-
onError: {
|
|
75
|
-
target: 'submittable',
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
countdown: {
|
|
80
|
-
after: {
|
|
81
|
-
1000: {
|
|
82
|
-
target: 'countdown',
|
|
83
|
-
actions: 'decreaseTtl',
|
|
84
|
-
cond: (context) => context.ttl > 0,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
accountUnbound: {},
|
|
89
|
-
unavailable: {},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
actions: {
|
|
94
|
-
setUserAccount: assign((context, event) => {
|
|
95
|
-
return {
|
|
96
|
-
userAccount: event.data.bankInfo?.[0],
|
|
97
|
-
}
|
|
98
|
-
}),
|
|
99
|
-
setHouseBank: assign((context, event) => {
|
|
100
|
-
const { accountName, accountNumber, bankName, amount } = event.data
|
|
101
|
-
return {
|
|
102
|
-
houseAccountName: accountName,
|
|
103
|
-
houseAccountNumber: accountNumber,
|
|
104
|
-
houseBankName: bankName,
|
|
105
|
-
calculatedAmount: amount,
|
|
106
|
-
}
|
|
107
|
-
}),
|
|
108
|
-
setInitialization: assign((context, event) => {
|
|
109
|
-
const { housePayment, bankList } = event.data
|
|
110
|
-
const { optional, minimum, maximum } = housePayment
|
|
111
|
-
return {
|
|
112
|
-
options: optional,
|
|
113
|
-
minimum,
|
|
114
|
-
maximum,
|
|
115
|
-
bankList,
|
|
116
|
-
}
|
|
117
|
-
}),
|
|
118
|
-
add: assign((context, event) => {
|
|
119
|
-
const { amount, maximum } = context
|
|
120
|
-
return {
|
|
121
|
-
amount: Math.min(amount + event.data, maximum),
|
|
122
|
-
}
|
|
123
|
-
}),
|
|
124
|
-
clear: assign((context, event) => {
|
|
125
|
-
return {
|
|
126
|
-
amount: 0,
|
|
127
|
-
}
|
|
128
|
-
}),
|
|
129
|
-
decreaseTtl: assign((context, evnet) => {
|
|
130
|
-
const ms = context.ttl
|
|
131
|
-
return {
|
|
132
|
-
ttl: Math.max(ms - 1, 0),
|
|
133
|
-
}
|
|
134
|
-
}),
|
|
135
|
-
},
|
|
136
|
-
guards: {
|
|
137
|
-
hasUserAccount: (context, event) => {
|
|
138
|
-
return event.data.bankInfo?.[0]
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
services: {
|
|
142
|
-
fetchPaymentInfo: async (context, event) => {
|
|
143
|
-
return await request.send(payment.getPaymentInfo())
|
|
144
|
-
},
|
|
145
|
-
initialize: async (context, event) => {
|
|
146
|
-
const [payments, bankList] = await Promise.all([
|
|
147
|
-
request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
|
|
148
|
-
request.send(payment.getBankList('amb')),
|
|
149
|
-
])
|
|
150
|
-
return { housePayment: payments.find((payment) => payment.method === context.method), bankList }
|
|
151
|
-
},
|
|
152
|
-
submitDeposit: async (context, event) => {
|
|
153
|
-
return await request.send(payment.submitDepositTransaction({ method: 'amb', amount: context.amount }))
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import payment from '../../api/payment.js'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'vpay',
|
|
8
|
-
initial: 'loading',
|
|
9
|
-
context: {
|
|
10
|
-
method: 'vpay',
|
|
11
|
-
userAccount: {},
|
|
12
|
-
amount: 0,
|
|
13
|
-
|
|
14
|
-
options: [],
|
|
15
|
-
minimum: 0,
|
|
16
|
-
maximum: 0,
|
|
17
|
-
|
|
18
|
-
qrcode: null,
|
|
19
|
-
vpayId: null,
|
|
20
|
-
calculatedAmount: 0,
|
|
21
|
-
},
|
|
22
|
-
states: {
|
|
23
|
-
loading: {
|
|
24
|
-
initial: 'checkingUserAccount',
|
|
25
|
-
states: {
|
|
26
|
-
checkingUserAccount: {
|
|
27
|
-
invoke: {
|
|
28
|
-
src: 'fetchPaymentInfo',
|
|
29
|
-
onDone: [
|
|
30
|
-
{
|
|
31
|
-
target: 'initializing',
|
|
32
|
-
actions: 'setUserAccount',
|
|
33
|
-
cond: 'hasUserAccount',
|
|
34
|
-
},
|
|
35
|
-
{ target: '#vpay.accountUnbound' },
|
|
36
|
-
],
|
|
37
|
-
onError: {
|
|
38
|
-
target: '#vpay.unavailable',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
initializing: {
|
|
43
|
-
invoke: {
|
|
44
|
-
src: 'initialize',
|
|
45
|
-
onDone: { target: '#vpay.submittable', actions: 'setInitialization' },
|
|
46
|
-
onError: {
|
|
47
|
-
target: '#vpay.unavailable',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
submittable: {
|
|
54
|
-
on: {
|
|
55
|
-
ADD: {
|
|
56
|
-
actions: 'add',
|
|
57
|
-
},
|
|
58
|
-
CLEAR: {
|
|
59
|
-
actions: 'clear',
|
|
60
|
-
},
|
|
61
|
-
SUBMIT: {
|
|
62
|
-
target: 'submitting',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
submitting: {
|
|
67
|
-
invoke: {
|
|
68
|
-
src: 'submitDeposit',
|
|
69
|
-
onDone: { target: 'submitted', actions: 'setQrcode' },
|
|
70
|
-
onError: {
|
|
71
|
-
target: 'submittable',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
submitted: {},
|
|
76
|
-
accountUnbound: {},
|
|
77
|
-
unavailable: {},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
actions: {
|
|
82
|
-
setUserAccount: assign((context, event) => {
|
|
83
|
-
return {
|
|
84
|
-
userAccount: event.data.bankInfo?.[0],
|
|
85
|
-
}
|
|
86
|
-
}),
|
|
87
|
-
setQrcode: assign((context, event) => {
|
|
88
|
-
const { amount, qrcode, vpayId } = event.data
|
|
89
|
-
return {
|
|
90
|
-
qrcode,
|
|
91
|
-
vpayId,
|
|
92
|
-
calculatedAmount: amount,
|
|
93
|
-
}
|
|
94
|
-
}),
|
|
95
|
-
setInitialization: assign((context, event) => {
|
|
96
|
-
const { housePayment } = event.data
|
|
97
|
-
const { optional, minimum, maximum } = housePayment
|
|
98
|
-
return {
|
|
99
|
-
options: optional,
|
|
100
|
-
minimum,
|
|
101
|
-
maximum,
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
add: assign((context, event) => {
|
|
105
|
-
const { amount, maximum } = context
|
|
106
|
-
return {
|
|
107
|
-
amount: Math.min(amount + event.data, maximum),
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
clear: assign((context, event) => {
|
|
111
|
-
return {
|
|
112
|
-
amount: 0,
|
|
113
|
-
}
|
|
114
|
-
}),
|
|
115
|
-
},
|
|
116
|
-
guards: {
|
|
117
|
-
hasUserAccount: (context, event) => {
|
|
118
|
-
return event.data.bankInfo?.[0]
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
services: {
|
|
122
|
-
fetchPaymentInfo: async (context, event) => {
|
|
123
|
-
return await request.send(payment.getPaymentInfo())
|
|
124
|
-
},
|
|
125
|
-
initialize: async (context, event) => {
|
|
126
|
-
const payments = await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
127
|
-
return { housePayment: payments.find((payment) => payment.method === context.method) }
|
|
128
|
-
},
|
|
129
|
-
submitDeposit: async (context, event) => {
|
|
130
|
-
const { method, amount } = context
|
|
131
|
-
return await request.send(
|
|
132
|
-
payment.submitDepositTransaction({
|
|
133
|
-
method,
|
|
134
|
-
amount,
|
|
135
|
-
})
|
|
136
|
-
)
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
}
|
|
140
|
-
)
|
|
141
|
-
}
|
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import findLastIndex from 'lodash/findLastIndex.js'
|
|
3
|
-
import payment from '../api/payment.js'
|
|
4
|
-
import common from '../api/common.js'
|
|
5
|
-
import user from '../api/user.js'
|
|
6
|
-
|
|
7
|
-
export default function (request) {
|
|
8
|
-
const { appSecret } = request.config
|
|
9
|
-
return createMachine(
|
|
10
|
-
{
|
|
11
|
-
id: 'withdraw_amb',
|
|
12
|
-
initial: 'loading',
|
|
13
|
-
context: {
|
|
14
|
-
siteConfig: null,
|
|
15
|
-
userInfo: null,
|
|
16
|
-
balance: null,
|
|
17
|
-
charge: null,
|
|
18
|
-
realAmount: null,
|
|
19
|
-
applyId: null,
|
|
20
|
-
methods: [],
|
|
21
|
-
paymentDetail: [],
|
|
22
|
-
bankInfo: [],
|
|
23
|
-
bankList: [],
|
|
24
|
-
withdrawLimit: null,
|
|
25
|
-
targetWithdrawLimit: null,
|
|
26
|
-
|
|
27
|
-
amount: null,
|
|
28
|
-
bank: null,
|
|
29
|
-
branch: null,
|
|
30
|
-
accountNumber: null,
|
|
31
|
-
holderName: null,
|
|
32
|
-
|
|
33
|
-
withdrawDistance: null,
|
|
34
|
-
withdrawAmount: 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: 'mode',
|
|
48
|
-
actions: ['setInitData', 'preset'],
|
|
49
|
-
},
|
|
50
|
-
onError: {
|
|
51
|
-
target: 'fail',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
mode: {
|
|
56
|
-
always: [{ target: 'free', cond: 'isFree' }, { target: 'cash' }],
|
|
57
|
-
},
|
|
58
|
-
free: {
|
|
59
|
-
initial: 'loading',
|
|
60
|
-
states: {
|
|
61
|
-
loading: {
|
|
62
|
-
invoke: {
|
|
63
|
-
src: 'fetchWithdrawRules',
|
|
64
|
-
onDone: {
|
|
65
|
-
target: 'checking',
|
|
66
|
-
actions: 'updateWithdrawCondition',
|
|
67
|
-
},
|
|
68
|
-
onError: {
|
|
69
|
-
target: 'notConvertible',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
checking: {
|
|
74
|
-
always: [{ target: 'convertible', cond: 'isConvertible' }, { target: 'notConvertible' }],
|
|
75
|
-
},
|
|
76
|
-
notConvertible: {},
|
|
77
|
-
convertible: {
|
|
78
|
-
on: {
|
|
79
|
-
SUBMIT: {
|
|
80
|
-
target: 'converting',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
converting: {
|
|
85
|
-
invoke: {
|
|
86
|
-
src: 'submitWithdrawFree',
|
|
87
|
-
onDone: [
|
|
88
|
-
{
|
|
89
|
-
target: '#withdraw_amb.otp',
|
|
90
|
-
actions: 'setOtp',
|
|
91
|
-
cond: 'isOtpRequired',
|
|
92
|
-
},
|
|
93
|
-
{ target: 'converted' },
|
|
94
|
-
],
|
|
95
|
-
onError: {
|
|
96
|
-
target: 'convertible',
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
converted: {},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
cash: {
|
|
104
|
-
initial: 'checking',
|
|
105
|
-
states: {
|
|
106
|
-
checking: {
|
|
107
|
-
always: [
|
|
108
|
-
{ target: 'inProcessing', cond: 'haveProcessing' },
|
|
109
|
-
{ target: 'notWithdrawable', cond: 'isNotWithdrawable' },
|
|
110
|
-
{ target: 'unbound', cond: 'isBankNotBound' },
|
|
111
|
-
{ target: 'withdrawable' },
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
notWithdrawable: {},
|
|
115
|
-
unbound: {
|
|
116
|
-
// to bank_binding.js
|
|
117
|
-
},
|
|
118
|
-
inProcessing: {},
|
|
119
|
-
withdrawable: {
|
|
120
|
-
on: {
|
|
121
|
-
SET_CURRENT_BANK: {
|
|
122
|
-
actions: assign((context, event) => {
|
|
123
|
-
return {
|
|
124
|
-
bank: event.data,
|
|
125
|
-
}
|
|
126
|
-
}),
|
|
127
|
-
},
|
|
128
|
-
SET_AMOUNT: {
|
|
129
|
-
actions: assign((context, event) => {
|
|
130
|
-
return {
|
|
131
|
-
amount: event.data,
|
|
132
|
-
}
|
|
133
|
-
}),
|
|
134
|
-
},
|
|
135
|
-
SUBMIT: {
|
|
136
|
-
target: 'submitting',
|
|
137
|
-
cond: 'isSubmittable',
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
submitting: {
|
|
142
|
-
invoke: {
|
|
143
|
-
src: 'submitWithdraw',
|
|
144
|
-
onDone: [
|
|
145
|
-
{
|
|
146
|
-
target: '#withdraw_amb.otp',
|
|
147
|
-
actions: 'setOtp',
|
|
148
|
-
cond: 'isOtpRequired',
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
target: 'submitted',
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
|
-
onError: {
|
|
155
|
-
target: 'withdrawable',
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
submitted: {
|
|
160
|
-
entry: assign((context, event) => {
|
|
161
|
-
const { applyId, balance, realAmount, charge } = event.data
|
|
162
|
-
return { applyId, balance, realAmount, charge }
|
|
163
|
-
}),
|
|
164
|
-
invoke: {
|
|
165
|
-
src: 'fetchPaymentData',
|
|
166
|
-
onDone: {
|
|
167
|
-
target: 'inProcessing',
|
|
168
|
-
actions: 'setPaymentData',
|
|
169
|
-
},
|
|
170
|
-
onError: {
|
|
171
|
-
target: '#withdraw_amb.fail',
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
otp: {
|
|
178
|
-
type: 'parallel',
|
|
179
|
-
states: {
|
|
180
|
-
countdown: {
|
|
181
|
-
after: {
|
|
182
|
-
1000: {
|
|
183
|
-
target: 'countdown',
|
|
184
|
-
actions: 'decreaseTtl',
|
|
185
|
-
cond: (context) => context.ttl > 0,
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
verification: {
|
|
190
|
-
initial: 'idle',
|
|
191
|
-
states: {
|
|
192
|
-
idle: {
|
|
193
|
-
on: {
|
|
194
|
-
ACKNOWLEDGE: {
|
|
195
|
-
target: 'acknowledging',
|
|
196
|
-
},
|
|
197
|
-
RESET_OTP: {
|
|
198
|
-
target: 'reset',
|
|
199
|
-
},
|
|
200
|
-
BACK: [
|
|
201
|
-
{
|
|
202
|
-
target: '#withdraw_amb.free.convertible',
|
|
203
|
-
cond: 'isFree',
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
target: '#withdraw_amb.cash.withdrawable',
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
acknowledging: {
|
|
212
|
-
invoke: {
|
|
213
|
-
src: 'acknowledge',
|
|
214
|
-
onDone: [
|
|
215
|
-
{
|
|
216
|
-
target: '#withdraw_amb.free.converted',
|
|
217
|
-
cond: 'isFree',
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
target: '#withdraw_amb.cash.submitted',
|
|
221
|
-
},
|
|
222
|
-
],
|
|
223
|
-
onError: {
|
|
224
|
-
target: 'idle',
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
reset: {
|
|
229
|
-
invoke: {
|
|
230
|
-
src: 'resetOtp',
|
|
231
|
-
onDone: {
|
|
232
|
-
target: 'idle',
|
|
233
|
-
actions: 'setVerificationData',
|
|
234
|
-
},
|
|
235
|
-
onError: { target: 'idle' },
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
fail: {},
|
|
243
|
-
},
|
|
244
|
-
on: {
|
|
245
|
-
REFRESH: {
|
|
246
|
-
target: 'loading',
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
actions: {
|
|
252
|
-
setInitData: assign((context, event) => {
|
|
253
|
-
return {
|
|
254
|
-
paymentDetail: event.data.paymentDetail,
|
|
255
|
-
bankInfo: event.data.bankInfo,
|
|
256
|
-
bonus: event.data.bonus,
|
|
257
|
-
bankList: event.data.bankList,
|
|
258
|
-
}
|
|
259
|
-
}),
|
|
260
|
-
setPaymentData: assign((context, event) => {
|
|
261
|
-
return {
|
|
262
|
-
bankInfo: event.data.bankInfo,
|
|
263
|
-
bonus: event.data.bonus,
|
|
264
|
-
paymentDetail: event.data.paymentDetail,
|
|
265
|
-
}
|
|
266
|
-
}),
|
|
267
|
-
preset: assign((context, event) => {
|
|
268
|
-
const { userInfo, siteConfig } = event.data
|
|
269
|
-
const { withdraw_limit, target_withdraw_limit } = userInfo || {}
|
|
270
|
-
const balance = parseFloat(userInfo?.balance)
|
|
271
|
-
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
272
|
-
return {
|
|
273
|
-
withdrawLimit: Math.abs(withdraw_limit),
|
|
274
|
-
targetWithdrawLimit: Math.abs(target_withdraw_limit),
|
|
275
|
-
methods,
|
|
276
|
-
balance,
|
|
277
|
-
siteConfig,
|
|
278
|
-
userInfo,
|
|
279
|
-
}
|
|
280
|
-
}),
|
|
281
|
-
updateWithdrawCondition: assign((context, event) => {
|
|
282
|
-
const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
|
|
283
|
-
|
|
284
|
-
const { balance, withdrawLimit } = context
|
|
285
|
-
const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
|
|
286
|
-
|
|
287
|
-
let maxWithdrawAmount = 0,
|
|
288
|
-
availableWithdrawAmount = 0
|
|
289
|
-
|
|
290
|
-
if (lastMatchedIndex > -1) {
|
|
291
|
-
rules[lastMatchedIndex].match = true
|
|
292
|
-
maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
|
|
293
|
-
|
|
294
|
-
if (withdrawLimit === 0) {
|
|
295
|
-
availableWithdrawAmount = Math.min(balance, maxWithdrawAmount)
|
|
296
|
-
}
|
|
297
|
-
} else if (rules.length > 0) {
|
|
298
|
-
maxWithdrawAmount = rules[0].maxWithdrawAmount
|
|
299
|
-
} else {
|
|
300
|
-
maxWithdrawAmount = balance
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return {
|
|
304
|
-
maxWithdrawAmount,
|
|
305
|
-
availableWithdrawAmount,
|
|
306
|
-
}
|
|
307
|
-
}),
|
|
308
|
-
setOtp: assign((context, event) => {
|
|
309
|
-
const { requestId, status, target, ttl } = event.data
|
|
310
|
-
return {
|
|
311
|
-
requestId,
|
|
312
|
-
status,
|
|
313
|
-
target,
|
|
314
|
-
ttl,
|
|
315
|
-
}
|
|
316
|
-
}),
|
|
317
|
-
decreaseTtl: assign((context, evnet) => {
|
|
318
|
-
const second = context.ttl
|
|
319
|
-
return {
|
|
320
|
-
ttl: Math.max(second - 1, 0),
|
|
321
|
-
}
|
|
322
|
-
}),
|
|
323
|
-
setVerificationData: assign((context, event) => {
|
|
324
|
-
const { requestId, ttl, target } = event.data
|
|
325
|
-
return {
|
|
326
|
-
requestId,
|
|
327
|
-
ttl,
|
|
328
|
-
target,
|
|
329
|
-
}
|
|
330
|
-
}),
|
|
331
|
-
},
|
|
332
|
-
guards: {
|
|
333
|
-
isFree: (context, event) => {
|
|
334
|
-
return context.userInfo?.withdraw_rule !== 'DEFAULT'
|
|
335
|
-
},
|
|
336
|
-
haveProcessing: (context, event) => {
|
|
337
|
-
return (context.paymentDetail?.[0]?.processing || []).length > 0
|
|
338
|
-
},
|
|
339
|
-
isWithdrawDisable: (context, event) => {
|
|
340
|
-
const { siteConfig } = context
|
|
341
|
-
const methods = siteConfig?.paymentMethods?.withdraw || []
|
|
342
|
-
return methods.length === 0
|
|
343
|
-
},
|
|
344
|
-
isBankNotBound: (context, event) => {
|
|
345
|
-
return !context.bankInfo?.length
|
|
346
|
-
},
|
|
347
|
-
isSubmittable: (context, event) => {
|
|
348
|
-
const { applyerBankCode, applyerAccountNumber, branch, holderName, amount } = event.data
|
|
349
|
-
return applyerBankCode && applyerAccountNumber && branch && holderName && amount
|
|
350
|
-
},
|
|
351
|
-
isConvertible: (context, event) => {
|
|
352
|
-
const { balance, withdrawLimit } = context
|
|
353
|
-
return balance > 0 && withdrawLimit === 0
|
|
354
|
-
},
|
|
355
|
-
isNotWithdrawable: (context, event) => {
|
|
356
|
-
const { balance, withdrawLimit, paymentDetail } = context
|
|
357
|
-
const minWithdrawAmount = paymentDetail[0]?.minimum || 0
|
|
358
|
-
return withdrawLimit !== 0 || balance < minWithdrawAmount
|
|
359
|
-
},
|
|
360
|
-
isOtpRequired: (context, event) => {
|
|
361
|
-
return event.data?.status === 'otp-verifying'
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
services: {
|
|
365
|
-
fetchInitData: async (context, event) => {
|
|
366
|
-
const [{ config }, userInfo, paymentDetail = [], { bonus, bankInfo }] = await Promise.all([
|
|
367
|
-
request.send(common.getConfig({ appSecret })),
|
|
368
|
-
request.send(user.getUserInfo()),
|
|
369
|
-
request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' })),
|
|
370
|
-
request.send(payment.getPaymentInfo()),
|
|
371
|
-
])
|
|
372
|
-
const siteConfig = JSON.parse(window.atob(config))
|
|
373
|
-
const method = paymentDetail.find((payment) => payment.category === 'amb').method
|
|
374
|
-
const bankList = await request.send(payment.getBankList(method))
|
|
375
|
-
const newBankInfo = bankInfo.map((item) => {
|
|
376
|
-
return { ...item, ...bankList.find((bank) => bank.bankCode === item.bankCode) }
|
|
377
|
-
})
|
|
378
|
-
return { siteConfig, userInfo, paymentDetail, bonus, bankInfo: newBankInfo, bankList }
|
|
379
|
-
},
|
|
380
|
-
fetchPaymentData: async (context, event) => {
|
|
381
|
-
const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
|
|
382
|
-
const { bonus, bankInfo } = await request.send(payment.getPaymentInfo())
|
|
383
|
-
return { bonus, bankInfo, paymentDetail }
|
|
384
|
-
},
|
|
385
|
-
updatePaymentInfo: async (context, event) => {
|
|
386
|
-
const { bank, branch, accountNumber, holderName } = context
|
|
387
|
-
return await request.send(
|
|
388
|
-
payment.updatePaymentInfo({
|
|
389
|
-
bankCode: bank.bankCode,
|
|
390
|
-
branch,
|
|
391
|
-
bankAccount: accountNumber,
|
|
392
|
-
holderName,
|
|
393
|
-
})
|
|
394
|
-
)
|
|
395
|
-
},
|
|
396
|
-
fetchWithdrawRules: async (context, event) => {
|
|
397
|
-
return await request.send(payment.getCurrentWithdrawRule())
|
|
398
|
-
},
|
|
399
|
-
submitWithdraw: async (context, event) => {
|
|
400
|
-
const { amount } = event.data
|
|
401
|
-
const { method } = context.paymentDetail[0]
|
|
402
|
-
return await request.send(
|
|
403
|
-
payment.submitWithdrawTransactionAmb({
|
|
404
|
-
method,
|
|
405
|
-
amount,
|
|
406
|
-
})
|
|
407
|
-
)
|
|
408
|
-
},
|
|
409
|
-
submitWithdrawFree: async (context, event) => {
|
|
410
|
-
return await request.send(payment.convertFreeCredit({ exchangeType: 1 }))
|
|
411
|
-
},
|
|
412
|
-
resetOtp: async (context, event) => {
|
|
413
|
-
const { requestId, target } = context
|
|
414
|
-
return await request.send(user.otpReset({ requestId, target }))
|
|
415
|
-
},
|
|
416
|
-
acknowledge: async (context, event) => {
|
|
417
|
-
const { requestId, target } = context
|
|
418
|
-
const code = event.data
|
|
419
|
-
return await request.send(user.otpAcknowledge({ requestId, target, code }))
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
}
|
|
423
|
-
)
|
|
424
|
-
}
|