@jetthai/cuora 1.0.204 → 1.0.302-dev-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/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/CHANGELOG.md +848 -0
- package/README.md +6 -0
- package/package.json +6 -9
- package/src/api/activity.js +43 -2
- package/src/api/auth.js +22 -7
- package/src/api/common.js +3 -1
- package/src/api/game.js +20 -7
- package/src/api/mailbox.js +9 -5
- package/src/api/payment.js +167 -19
- package/src/api/user.js +7 -0
- package/src/lib/fingerprint.js +9779 -0
- package/src/machine/activity/activity.js +111 -26
- package/src/machine/activity/activity_cash.js +159 -0
- package/src/machine/activity/cash_rain_activity.js +153 -0
- package/src/machine/activity/continue_deposit_activity.js +11 -2
- package/src/machine/activity/deposit_activity.js +13 -4
- package/src/machine/activity/diamond_shop_activity_cash.js +179 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +54 -89
- package/src/machine/activity/fafafa_activity.js +34 -19
- package/src/machine/activity/{affiliate_invite_friends_activity.js → friend_invite_friends_activity.js} +72 -45
- package/src/machine/activity/index.js +22 -4
- package/src/machine/activity/instant_rebate_activity.js +217 -0
- package/src/machine/activity/invite_friends_activity.js +14 -14
- package/src/machine/activity/jackpot.js +74 -0
- package/src/machine/activity/otp_verified_activity.js +74 -0
- package/src/machine/activity/ranking_activity.js +11 -2
- package/src/machine/activity/roulette_activity_v2.js +90 -0
- package/src/machine/activity/sign_in_activity.js +21 -14
- package/src/machine/activity/sign_in_monthly_activity.js +65 -0
- package/src/machine/activity/specify_bets_activity.js +25 -3
- package/src/machine/activity/specify_turnover_activity.js +25 -3
- package/src/machine/activity/time_bomb_activity.js +11 -2
- package/src/machine/activity/vip_card_activity.js +140 -0
- package/src/machine/auth.js +141 -27
- package/src/machine/auth_otp_v2.js +10 -4
- package/src/machine/auth_otp_v3.js +11 -3
- package/src/machine/bank_binding.js +112 -12
- package/src/machine/bank_binding_amb.js +145 -0
- package/src/machine/common.js +113 -25
- package/src/machine/deposit/amb.js +92 -0
- package/src/machine/deposit/crypto.js +50 -29
- package/src/machine/deposit/crypto_bank.js +317 -0
- package/src/machine/deposit/crypto_bank_cash.js +287 -0
- package/src/machine/deposit/crypto_button.js +174 -39
- package/src/machine/deposit/crypto_cash.js +255 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +131 -0
- package/src/machine/deposit/crypto_way.js +239 -0
- package/src/machine/deposit/crypto_way_cash.js +256 -0
- package/src/machine/deposit/deposit_fc.js +8 -5
- package/src/machine/deposit/direct.js +111 -16
- package/src/machine/deposit/direct_cash.js +217 -0
- package/src/machine/deposit/float.js +366 -0
- package/src/machine/deposit/index.js +43 -2
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_cash.js +207 -0
- package/src/machine/deposit/loadcard_vn.js +191 -43
- package/src/machine/deposit/manual_cash.js +356 -0
- package/src/machine/deposit/manual_vn.js +182 -60
- package/src/machine/deposit/qrcode_cash.js +217 -0
- package/src/machine/deposit/qrcode_v2.js +285 -52
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/usdt_cash.js +138 -0
- package/src/machine/deposit/vpay.js +359 -0
- package/src/machine/game_favorite_v2.js +70 -28
- package/src/machine/game_info.js +57 -0
- package/src/machine/game_search_cash.js +390 -0
- package/src/machine/game_search_v2.js +64 -24
- package/src/machine/game_v2_1.js +662 -0
- package/src/machine/honor_board_cash.js +63 -0
- package/src/machine/inbox.js +259 -34
- package/src/machine/index.js +24 -17
- package/src/machine/leaderboard.js +31 -8
- package/src/machine/navbar.js +57 -0
- package/src/machine/promotions.js +171 -0
- package/src/machine/reward.js +74 -7
- package/src/machine/reward_cash.js +219 -0
- package/src/machine/roulette_v2.js +276 -0
- package/src/machine/setting.js +5 -2
- package/src/machine/side_cash.js +110 -0
- package/src/machine/side_v2.js +33 -28
- package/src/machine/user_photo.js +65 -0
- package/src/machine/user_sign_up.js +117 -17
- package/src/machine/withdraw/index.js +23 -0
- package/src/machine/{withdraw_vn.js → withdraw/withdraw_amb.js} +146 -78
- package/src/machine/{withdraw_crypto.js → withdraw/withdraw_crypto.js} +220 -69
- package/src/machine/withdraw/withdraw_crypto2.js +540 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +319 -0
- package/src/machine/{withdraw_fc.js → withdraw/withdraw_fc.js} +2 -2
- package/src/machine/withdraw/withdraw_krway.js +207 -0
- package/src/machine/withdraw/withdraw_manual.js +595 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +303 -0
- package/src/machine/withdraw/withdraw_vn.js +533 -0
- package/src/machine/withdraw/withdraw_vn2.js +548 -0
- package/src/request/request.js +10 -5
- package/src/util/constant.js +19 -1
- package/src/util/deviceToken.js +18 -8
- package/src/util/index.js +2 -1
- package/src/util/math.js +4 -0
- package/src/util/storage.js +22 -22
- package/dist/bundle.mjs +0 -18462
- package/rollup.config.js +0 -16
- package/src/machine/auth_otp.js +0 -201
- package/src/machine/deposit/qrcode_vn.js +0 -206
- package/src/machine/game.js +0 -285
- package/src/machine/game_favorite.js +0 -123
- package/src/machine/game_search.js +0 -244
- package/src/machine/game_v2.js +0 -356
package/src/machine/auth.js
CHANGED
|
@@ -4,24 +4,27 @@ import auth from '../api/auth.js'
|
|
|
4
4
|
import user from '../api/user.js'
|
|
5
5
|
import storage from '../util/storage.js'
|
|
6
6
|
import { getDeviceToken } from '../util/deviceToken.js'
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import common from '../api/common.js'
|
|
8
|
+
import pickBy from 'lodash/pickBy.js'
|
|
9
9
|
|
|
10
10
|
export default function (request) {
|
|
11
|
-
const { clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
11
|
+
const { appSecret, clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
12
12
|
const tokenKey = `cuora_${clientId}`
|
|
13
13
|
const userKey = `cuora_tempuser`
|
|
14
14
|
const phoneCountryCode = 'phone_countrycode'
|
|
15
15
|
const accountPhoneKey = 'account_phone'
|
|
16
16
|
const accountEmailKey = 'account_email'
|
|
17
|
+
const accountUsernameKey = 'account_username'
|
|
17
18
|
|
|
18
19
|
return createMachine(
|
|
19
20
|
{
|
|
20
21
|
id: 'auth',
|
|
21
|
-
initial: '
|
|
22
|
+
initial: 'fetchingConfig',
|
|
22
23
|
context: {
|
|
24
|
+
base: '',
|
|
23
25
|
token: null,
|
|
24
26
|
tick: 2000,
|
|
27
|
+
siteConfig: {},
|
|
25
28
|
isPlaying: false,
|
|
26
29
|
loginData: {
|
|
27
30
|
provider: '',
|
|
@@ -35,12 +38,24 @@ export default function (request) {
|
|
|
35
38
|
userInfo: {},
|
|
36
39
|
redirectURL: null,
|
|
37
40
|
reCaptchaToken: null,
|
|
38
|
-
|
|
41
|
+
fc: null,
|
|
39
42
|
},
|
|
40
43
|
states: {
|
|
44
|
+
fetchingConfig: {
|
|
45
|
+
invoke: {
|
|
46
|
+
src: 'fetchSiteConfig',
|
|
47
|
+
onDone: {
|
|
48
|
+
target: 'idle',
|
|
49
|
+
actions: 'setSiteConfig',
|
|
50
|
+
},
|
|
51
|
+
onError: {
|
|
52
|
+
target: 'idle',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
41
56
|
idle: {
|
|
42
57
|
entry: 'fetchToken',
|
|
43
|
-
always: [{ target: '
|
|
58
|
+
always: [{ target: 'tokenAuthenticated', cond: 'hasToken' }],
|
|
44
59
|
},
|
|
45
60
|
authentication: {
|
|
46
61
|
invoke: {
|
|
@@ -82,6 +97,25 @@ export default function (request) {
|
|
|
82
97
|
},
|
|
83
98
|
},
|
|
84
99
|
authenticated: {
|
|
100
|
+
invoke: {
|
|
101
|
+
src: 'fetchUserInfo',
|
|
102
|
+
onDone: {
|
|
103
|
+
target: 'loginSuccess',
|
|
104
|
+
actions: ['setUserInfo', 'extendToken'],
|
|
105
|
+
},
|
|
106
|
+
onError: {
|
|
107
|
+
target: 'leaving',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
loginSuccess: {
|
|
112
|
+
after: {
|
|
113
|
+
0: {
|
|
114
|
+
target: 'inline',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
tokenAuthenticated: {
|
|
85
119
|
invoke: {
|
|
86
120
|
src: 'fetchUserInfo',
|
|
87
121
|
onDone: {
|
|
@@ -97,7 +131,7 @@ export default function (request) {
|
|
|
97
131
|
initial: 'pending',
|
|
98
132
|
states: {
|
|
99
133
|
pending: {
|
|
100
|
-
always: [{ target: '#auth.
|
|
134
|
+
always: [{ target: '#auth.inlineFinish', cond: 'isNotInline' }],
|
|
101
135
|
after: {
|
|
102
136
|
TIMEOUT: {
|
|
103
137
|
target: 'fetching',
|
|
@@ -118,9 +152,27 @@ export default function (request) {
|
|
|
118
152
|
},
|
|
119
153
|
},
|
|
120
154
|
},
|
|
155
|
+
inlineFinish: {
|
|
156
|
+
after: {
|
|
157
|
+
0: {
|
|
158
|
+
target: 'login',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
121
162
|
login: {
|
|
122
|
-
initial: '
|
|
163
|
+
initial: 'deviceTokenChecking',
|
|
123
164
|
states: {
|
|
165
|
+
deviceTokenChecking: {
|
|
166
|
+
invoke: {
|
|
167
|
+
src: 'checkDeviceToken',
|
|
168
|
+
onDone: {
|
|
169
|
+
target: 'fetching',
|
|
170
|
+
},
|
|
171
|
+
onError: {
|
|
172
|
+
target: 'fetching',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
124
176
|
fetching: {
|
|
125
177
|
invoke: {
|
|
126
178
|
src: 'fetchUserInfo',
|
|
@@ -169,7 +221,7 @@ export default function (request) {
|
|
|
169
221
|
},
|
|
170
222
|
on: {
|
|
171
223
|
LOGIN_TOKEN: {
|
|
172
|
-
target: '
|
|
224
|
+
target: '.fetchingConfig',
|
|
173
225
|
actions: 'setToken',
|
|
174
226
|
},
|
|
175
227
|
CLEAR: {
|
|
@@ -178,6 +230,10 @@ export default function (request) {
|
|
|
178
230
|
LOGIN_GUEST: {
|
|
179
231
|
target: '.authenticationGuest',
|
|
180
232
|
},
|
|
233
|
+
LOGIN_ID: {
|
|
234
|
+
target: '.authentication',
|
|
235
|
+
actions: ['setReCaptchaToken', 'setLoginId'],
|
|
236
|
+
},
|
|
181
237
|
LOGIN_PHONE: {
|
|
182
238
|
target: '.authentication',
|
|
183
239
|
actions: ['setReCaptchaToken', 'setLoginPhone'],
|
|
@@ -194,7 +250,7 @@ export default function (request) {
|
|
|
194
250
|
actions: 'redirectTo3Party',
|
|
195
251
|
},
|
|
196
252
|
LOGIN_APP: {
|
|
197
|
-
target: '.authenticationApp'
|
|
253
|
+
target: '.authenticationApp',
|
|
198
254
|
},
|
|
199
255
|
SET_PLAY: {
|
|
200
256
|
actions: 'setPlay',
|
|
@@ -220,12 +276,28 @@ export default function (request) {
|
|
|
220
276
|
},
|
|
221
277
|
},
|
|
222
278
|
actions: {
|
|
279
|
+
setSiteConfig: assign((context, event) => {
|
|
280
|
+
const { loginMethods = {}, registerMethods = {} } = event.data
|
|
281
|
+
return {
|
|
282
|
+
siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
223
285
|
setReCaptchaToken: assign((context, event) => {
|
|
224
286
|
const { reCaptchaToken } = event.data
|
|
225
287
|
return {
|
|
226
288
|
reCaptchaToken,
|
|
227
289
|
}
|
|
228
290
|
}),
|
|
291
|
+
setLoginId: assign((context, event) => {
|
|
292
|
+
const { username, password } = event.data
|
|
293
|
+
return {
|
|
294
|
+
loginData: {
|
|
295
|
+
provider: 'local',
|
|
296
|
+
username,
|
|
297
|
+
password,
|
|
298
|
+
},
|
|
299
|
+
}
|
|
300
|
+
}),
|
|
229
301
|
setLoginPhone: assign((context, event) => {
|
|
230
302
|
const { countryCode, countryAbbr, phone, password } = event.data
|
|
231
303
|
return {
|
|
@@ -278,22 +350,31 @@ export default function (request) {
|
|
|
278
350
|
}
|
|
279
351
|
}),
|
|
280
352
|
setAccount: assign((context, event) => {
|
|
281
|
-
if (context.loginData.
|
|
353
|
+
if (context.loginData.username) {
|
|
354
|
+
storage.remove(accountEmailKey)
|
|
355
|
+
storage.remove(accountPhoneKey)
|
|
356
|
+
storage.set(accountUsernameKey, `${context.loginData.username}`, {
|
|
357
|
+
path: '/',
|
|
358
|
+
maxAge: 60 * 60 * 24 * 31,
|
|
359
|
+
})
|
|
360
|
+
} else if (context.loginData.phone) {
|
|
282
361
|
storage.remove(accountEmailKey)
|
|
362
|
+
storage.remove(accountUsernameKey)
|
|
283
363
|
storage.set(accountPhoneKey, `${context.loginData.phone}`, {
|
|
284
364
|
path: '/',
|
|
285
|
-
maxAge: 60 * 60 * 24 *
|
|
365
|
+
maxAge: 60 * 60 * 24 * 31,
|
|
286
366
|
})
|
|
287
367
|
storage.set(phoneCountryCode, `${context.countryAbbr}_${context.loginData.countryCode}`, {
|
|
288
368
|
path: '/',
|
|
289
|
-
maxAge: 60 * 60 * 24 *
|
|
369
|
+
maxAge: 60 * 60 * 24 * 31,
|
|
290
370
|
})
|
|
291
371
|
} else if (context.loginData.email) {
|
|
292
372
|
storage.remove(accountPhoneKey)
|
|
293
373
|
storage.remove(phoneCountryCode)
|
|
374
|
+
storage.remove(accountUsernameKey)
|
|
294
375
|
storage.set(accountEmailKey, context.loginData.email, {
|
|
295
376
|
path: '/',
|
|
296
|
-
maxAge: 60 * 60 * 24 *
|
|
377
|
+
maxAge: 60 * 60 * 24 * 31,
|
|
297
378
|
})
|
|
298
379
|
}
|
|
299
380
|
}),
|
|
@@ -313,33 +394,52 @@ export default function (request) {
|
|
|
313
394
|
return { token }
|
|
314
395
|
}),
|
|
315
396
|
redirectTo3Party: async (context, event) => {
|
|
316
|
-
const { provider, channel, subchannel,
|
|
397
|
+
const { provider, channel, subchannel, fc } = event.data
|
|
398
|
+
const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
|
|
317
399
|
|
|
318
|
-
|
|
319
|
-
|
|
400
|
+
await getDeviceToken({
|
|
401
|
+
fpToken,
|
|
402
|
+
sentry,
|
|
403
|
+
hosts: request.hosts,
|
|
404
|
+
enable: deviceTokenEnable,
|
|
405
|
+
})
|
|
320
406
|
|
|
407
|
+
const affiliateCode = storage.get('ac')
|
|
408
|
+
const nickname = storage.get('nk')
|
|
321
409
|
const messages = {
|
|
322
410
|
url: window.location.href,
|
|
323
|
-
|
|
411
|
+
channelOrders: [
|
|
324
412
|
{ channel: storage.get('channel'), subchannel: storage.get('subchannel') },
|
|
325
413
|
{ channel: defaultChannel, subchannel: defaultSubchannel },
|
|
326
414
|
{ channel: channel, subchannel: subchannel },
|
|
327
415
|
],
|
|
416
|
+
affiliateCode,
|
|
417
|
+
nickname,
|
|
328
418
|
}
|
|
329
419
|
sentry.captureMessage(JSON.stringify(messages))
|
|
330
420
|
|
|
421
|
+
const referralObj = {}
|
|
422
|
+
if (![undefined, 'undefined', null, 'null'].includes(affiliateCode)) {
|
|
423
|
+
referralObj.ac = affiliateCode
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (![undefined, 'undefined', null, 'null'].includes(nickname)) {
|
|
427
|
+
referralObj.nick_name = nickname
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
referralObj.channel = storage.get('channel') || defaultChannel || channel
|
|
431
|
+
referralObj.subchannel = storage.get('subchannel') || defaultSubchannel || subchannel
|
|
432
|
+
|
|
331
433
|
const redirectURL = urljoin(
|
|
332
434
|
request.config.fullURL,
|
|
333
435
|
'login?' +
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
affiliate
|
|
342
|
-
}).toString()
|
|
436
|
+
new URLSearchParams({
|
|
437
|
+
provider,
|
|
438
|
+
redirectURI: `${window.location.protocol}//${window.location.host}${context.base}`,
|
|
439
|
+
...referralObj,
|
|
440
|
+
platform: 'pwa',
|
|
441
|
+
fc,
|
|
442
|
+
}).toString()
|
|
343
443
|
)
|
|
344
444
|
|
|
345
445
|
window.location.href = redirectURL
|
|
@@ -376,6 +476,20 @@ export default function (request) {
|
|
|
376
476
|
fetchUserInfo: async (context, event) => {
|
|
377
477
|
return await request.send(user.getUserInfo())
|
|
378
478
|
},
|
|
479
|
+
checkDeviceToken: async (context, event) => {
|
|
480
|
+
const deviceTokenEnable = context.siteConfig?.dtVerify === '1'
|
|
481
|
+
if (deviceTokenEnable) {
|
|
482
|
+
const { exist } = await request.send(user.checkDt())
|
|
483
|
+
if (!exist) {
|
|
484
|
+
const dt = await getDeviceToken({ fpToken, sentry, hosts: request.hosts, enable: deviceTokenEnable })
|
|
485
|
+
await request.send(user.updateDt({ dt }))
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
fetchSiteConfig: async (context, event) => {
|
|
490
|
+
const { config } = await request.send(common.getConfig({ appSecret }))
|
|
491
|
+
return JSON.parse(window.atob(config))
|
|
492
|
+
},
|
|
379
493
|
},
|
|
380
494
|
}
|
|
381
495
|
)
|
|
@@ -34,10 +34,16 @@ export default function (request) {
|
|
|
34
34
|
otpFetching: {
|
|
35
35
|
invoke: {
|
|
36
36
|
src: 'sendOtp',
|
|
37
|
-
onDone:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
onDone: [
|
|
38
|
+
{
|
|
39
|
+
target: 'acknowledged',
|
|
40
|
+
cond: (context, event) => event.data.status === 'success-verified',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
target: 'otp',
|
|
44
|
+
actions: 'setOtpResult',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
41
47
|
onError: {
|
|
42
48
|
target: 'idle',
|
|
43
49
|
},
|
|
@@ -16,6 +16,7 @@ export default function (request) {
|
|
|
16
16
|
email: null,
|
|
17
17
|
target: null,
|
|
18
18
|
requestId: null,
|
|
19
|
+
status: null,
|
|
19
20
|
ttl: 0,
|
|
20
21
|
},
|
|
21
22
|
states: {
|
|
@@ -115,11 +116,14 @@ export default function (request) {
|
|
|
115
116
|
},
|
|
116
117
|
},
|
|
117
118
|
verification: {
|
|
118
|
-
initial: '
|
|
119
|
+
initial: 'checking',
|
|
119
120
|
states: {
|
|
121
|
+
checking: {
|
|
122
|
+
always: [{ target: '#auth_otp.verified', cond: 'isAutoVerified' }, { target: 'idle' }],
|
|
123
|
+
},
|
|
120
124
|
idle: {
|
|
121
125
|
on: {
|
|
122
|
-
|
|
126
|
+
ACKNOWLEDGE: {
|
|
123
127
|
target: 'acknowledging',
|
|
124
128
|
},
|
|
125
129
|
RESET_OTP: {
|
|
@@ -174,11 +178,12 @@ export default function (request) {
|
|
|
174
178
|
}
|
|
175
179
|
}),
|
|
176
180
|
setVerificationData: assign((context, event) => {
|
|
177
|
-
const { requestId, ttl, target } = event.data
|
|
181
|
+
const { requestId, ttl, target, status } = event.data
|
|
178
182
|
return {
|
|
179
183
|
requestId,
|
|
180
184
|
ttl: ttl * 1000,
|
|
181
185
|
target,
|
|
186
|
+
status,
|
|
182
187
|
}
|
|
183
188
|
}),
|
|
184
189
|
decreaseTtl: assign((context, evnet) => {
|
|
@@ -225,6 +230,9 @@ export default function (request) {
|
|
|
225
230
|
const { error } = context
|
|
226
231
|
return error.code === 'ERR_F106'
|
|
227
232
|
},
|
|
233
|
+
isAutoVerified: (context, event) => {
|
|
234
|
+
return context.status === 'success-verified'
|
|
235
|
+
},
|
|
228
236
|
},
|
|
229
237
|
services: {
|
|
230
238
|
fetchUserInfo: async (context, event) => {
|
|
@@ -2,17 +2,32 @@ 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',
|
|
8
10
|
initial: 'fetching',
|
|
9
11
|
context: {
|
|
10
12
|
hasAnyAccount: false,
|
|
11
|
-
|
|
13
|
+
paymentList: {
|
|
14
|
+
bankList: [],
|
|
15
|
+
cryptoList: [],
|
|
16
|
+
ewalletList: [],
|
|
17
|
+
},
|
|
18
|
+
currency: null,
|
|
19
|
+
bindingType: 'BANK',
|
|
12
20
|
bank: null,
|
|
21
|
+
ifscCode: null,
|
|
22
|
+
crypto: null,
|
|
23
|
+
network: null,
|
|
24
|
+
cryptoAddress: null,
|
|
25
|
+
walletCode: null,
|
|
13
26
|
branch: null,
|
|
27
|
+
branchCode: null,
|
|
14
28
|
accountNumber: null,
|
|
15
29
|
holderName: null,
|
|
30
|
+
pixType: null,
|
|
16
31
|
},
|
|
17
32
|
states: {
|
|
18
33
|
fetching: {
|
|
@@ -29,6 +44,13 @@ export default function (request) {
|
|
|
29
44
|
},
|
|
30
45
|
idle: {
|
|
31
46
|
on: {
|
|
47
|
+
SET_BIND_TYPE: {
|
|
48
|
+
actions: assign((context, event) => {
|
|
49
|
+
return {
|
|
50
|
+
bindingType: event.data,
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
32
54
|
SET_BANK_CODE: {
|
|
33
55
|
actions: assign((context, event) => {
|
|
34
56
|
return {
|
|
@@ -36,6 +58,34 @@ export default function (request) {
|
|
|
36
58
|
}
|
|
37
59
|
}),
|
|
38
60
|
},
|
|
61
|
+
SET_CRYPTO_CODE: {
|
|
62
|
+
actions: assign((context, event) => {
|
|
63
|
+
return {
|
|
64
|
+
crypto: event.data,
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
68
|
+
SET_NETWORK_CODE: {
|
|
69
|
+
actions: assign((context, event) => {
|
|
70
|
+
return {
|
|
71
|
+
network: event.data,
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
SET_CRYPTO_ADDRESS: {
|
|
76
|
+
actions: assign((context, event) => {
|
|
77
|
+
return {
|
|
78
|
+
cryptoAddress: event.data,
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
},
|
|
82
|
+
SET_WALLET_CODE: {
|
|
83
|
+
actions: assign((context, event) => {
|
|
84
|
+
return {
|
|
85
|
+
walletCode: event.data,
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
39
89
|
SET_BRANCH: {
|
|
40
90
|
actions: assign((context, event) => {
|
|
41
91
|
return {
|
|
@@ -43,6 +93,13 @@ export default function (request) {
|
|
|
43
93
|
}
|
|
44
94
|
}),
|
|
45
95
|
},
|
|
96
|
+
SET_BRANCH_CODE: {
|
|
97
|
+
actions: assign((context, event) => {
|
|
98
|
+
return {
|
|
99
|
+
branchCode: event.data,
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
},
|
|
46
103
|
SET_ACCOUNT_NUMBER: {
|
|
47
104
|
actions: assign((context, event) => {
|
|
48
105
|
return {
|
|
@@ -57,6 +114,20 @@ export default function (request) {
|
|
|
57
114
|
}
|
|
58
115
|
}),
|
|
59
116
|
},
|
|
117
|
+
SET_PIX_TYPE: {
|
|
118
|
+
actions: assign((context, event) => {
|
|
119
|
+
return {
|
|
120
|
+
pixType: event.data,
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
SET_IFSC_CODE: {
|
|
125
|
+
actions: assign((context, event) => {
|
|
126
|
+
return {
|
|
127
|
+
ifscCode: event.data,
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
60
131
|
BIND_BANK: {
|
|
61
132
|
target: 'binding',
|
|
62
133
|
cond: 'isBindable',
|
|
@@ -80,37 +151,66 @@ export default function (request) {
|
|
|
80
151
|
{
|
|
81
152
|
actions: {
|
|
82
153
|
setBanks: assign((context, event) => {
|
|
83
|
-
const {
|
|
154
|
+
const { paymentList = {}, paymentInfo = {} } = event.data
|
|
84
155
|
const { bankInfo = [] } = paymentInfo
|
|
85
156
|
return {
|
|
86
157
|
hasAnyAccount: bankInfo.length > 0,
|
|
87
158
|
holderName: bankInfo[0]?.holderName,
|
|
88
|
-
|
|
89
|
-
bank:
|
|
159
|
+
paymentList,
|
|
160
|
+
bank: null, // 不預選銀行,玩家可能不知道這裡可以選 by Gordan
|
|
90
161
|
}
|
|
91
162
|
}),
|
|
92
163
|
},
|
|
93
164
|
guards: {
|
|
94
165
|
isBindable: (context, event) => {
|
|
95
|
-
const {
|
|
96
|
-
|
|
166
|
+
const { bindingType, currency } = context
|
|
167
|
+
|
|
168
|
+
if (bindingType === 'CRYPTO') {
|
|
169
|
+
// 虛擬貨幣
|
|
170
|
+
const { crypto, network, cryptoAddress, holderName } = context
|
|
171
|
+
return crypto && network && cryptoAddress && holderName
|
|
172
|
+
} else if (bindingType === 'EWALLET') {
|
|
173
|
+
// 電子錢包
|
|
174
|
+
const { walletCode, accountNumber, holderName } = context
|
|
175
|
+
return walletCode?.bankCode && accountNumber && holderName
|
|
176
|
+
} else {
|
|
177
|
+
// 一般銀行
|
|
178
|
+
if (currency === 'INR') {
|
|
179
|
+
// 如果是印度幣別
|
|
180
|
+
const { bank, ifscCode, accountNumber, branch, holderName } = context
|
|
181
|
+
return bank.bankCode && ifscCode && accountNumber && branch && holderName
|
|
182
|
+
} else {
|
|
183
|
+
const { bank, accountNumber, branch, holderName } = context
|
|
184
|
+
return bank.bankCode && accountNumber && branch && holderName
|
|
185
|
+
}
|
|
186
|
+
}
|
|
97
187
|
},
|
|
98
188
|
},
|
|
99
189
|
services: {
|
|
100
190
|
fetchInitData: async (context, event) => {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
191
|
+
const [paymentList, paymentInfo] = await Promise.all([
|
|
192
|
+
request.send(payment.getBindingPaymentList({ appSecret })),
|
|
193
|
+
request.send(payment.getPaymentInfo()),
|
|
194
|
+
])
|
|
195
|
+
return { paymentList, paymentInfo }
|
|
105
196
|
},
|
|
106
197
|
updatePaymentInfo: async (context, event) => {
|
|
107
|
-
const { bank, branch, accountNumber, holderName } =
|
|
198
|
+
const { bindingType, bank, ifscCode, crypto, network, cryptoAddress, walletCode, branch, branchCode, accountNumber, holderName, pixType } =
|
|
199
|
+
context
|
|
108
200
|
return await request.send(
|
|
109
201
|
payment.updatePaymentInfo({
|
|
110
|
-
|
|
202
|
+
bindingType,
|
|
203
|
+
ifscCode,
|
|
204
|
+
bankCode: bank?.bankCode || '',
|
|
205
|
+
cryptoCurrency: crypto?.symbol || '',
|
|
206
|
+
cryptoNetwork: network?.label || '',
|
|
207
|
+
cryptoAddress: cryptoAddress,
|
|
208
|
+
walletCode: walletCode?.bankCode || '',
|
|
111
209
|
branch: branch === 'BLANK' ? '' : branch, // 'BLANK'會置換成空值
|
|
210
|
+
branchCode,
|
|
112
211
|
bankAccount: accountNumber,
|
|
113
212
|
holderName,
|
|
213
|
+
pixType,
|
|
114
214
|
})
|
|
115
215
|
)
|
|
116
216
|
},
|