@jetthai/cuora 1.1.35 → 1.1.37
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 +4 -0
- package/dist/bundle.mjs +143 -205
- package/package.json +1 -1
- package/src/machine/deposit/index.js +2 -2
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/qrcode_vn.js +0 -206
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.37](https://github.com/jetthai/cuora-module/compare/v1.1.36...v1.1.37) (2023-01-13)
|
|
6
|
+
|
|
7
|
+
### [1.1.36](https://github.com/jetthai/cuora-module/compare/v1.1.35...v1.1.36) (2023-01-12)
|
|
8
|
+
|
|
5
9
|
### [1.1.35](https://github.com/jetthai/cuora-module/compare/v1.1.34...v1.1.35) (2023-01-12)
|
|
6
10
|
|
|
7
11
|
### [1.1.34](https://github.com/jetthai/cuora-module/compare/v1.1.32...v1.1.34) (2023-01-10)
|
package/dist/bundle.mjs
CHANGED
|
@@ -16901,210 +16901,6 @@ function loadcard_vn (request) {
|
|
|
16901
16901
|
)
|
|
16902
16902
|
}
|
|
16903
16903
|
|
|
16904
|
-
function qrcode_vn (request) {
|
|
16905
|
-
return createMachine(
|
|
16906
|
-
{
|
|
16907
|
-
id: 'qrcode',
|
|
16908
|
-
initial: 'loading',
|
|
16909
|
-
context: {
|
|
16910
|
-
qrcodes: [],
|
|
16911
|
-
options: [],
|
|
16912
|
-
|
|
16913
|
-
selectedQrcode: null,
|
|
16914
|
-
selectedAmount: null,
|
|
16915
|
-
|
|
16916
|
-
calculation: null,
|
|
16917
|
-
|
|
16918
|
-
paymentDetails: [],
|
|
16919
|
-
currentCategory: 'qrcode',
|
|
16920
|
-
currentMethod: null,
|
|
16921
|
-
|
|
16922
|
-
result: null,
|
|
16923
|
-
},
|
|
16924
|
-
states: {
|
|
16925
|
-
loading: {
|
|
16926
|
-
invoke: {
|
|
16927
|
-
src: 'fetchInitData',
|
|
16928
|
-
onDone: {
|
|
16929
|
-
target: 'loaded',
|
|
16930
|
-
actions: 'setInitData',
|
|
16931
|
-
},
|
|
16932
|
-
onError: {
|
|
16933
|
-
target: 'fail',
|
|
16934
|
-
},
|
|
16935
|
-
},
|
|
16936
|
-
},
|
|
16937
|
-
loaded: {
|
|
16938
|
-
entry: 'reset',
|
|
16939
|
-
on: {
|
|
16940
|
-
SELECT_QRCODE: {
|
|
16941
|
-
actions: 'setQrcode',
|
|
16942
|
-
},
|
|
16943
|
-
SELECT_AMOUNT: {
|
|
16944
|
-
target: 'calculable',
|
|
16945
|
-
actions: 'addAmount',
|
|
16946
|
-
},
|
|
16947
|
-
KEY_IN: {
|
|
16948
|
-
target: 'calculable',
|
|
16949
|
-
actions: 'setAmount',
|
|
16950
|
-
},
|
|
16951
|
-
},
|
|
16952
|
-
},
|
|
16953
|
-
fail: {},
|
|
16954
|
-
calculable: {
|
|
16955
|
-
entry: 'clearCalculation',
|
|
16956
|
-
on: {
|
|
16957
|
-
SELECT_AMOUNT: {
|
|
16958
|
-
actions: 'addAmount',
|
|
16959
|
-
},
|
|
16960
|
-
KEY_IN: {
|
|
16961
|
-
actions: 'setAmount',
|
|
16962
|
-
},
|
|
16963
|
-
CALCULATE: {
|
|
16964
|
-
target: 'calculating',
|
|
16965
|
-
},
|
|
16966
|
-
BACK: {
|
|
16967
|
-
target: 'loaded',
|
|
16968
|
-
},
|
|
16969
|
-
},
|
|
16970
|
-
},
|
|
16971
|
-
calculating: {
|
|
16972
|
-
invoke: {
|
|
16973
|
-
src: 'fetchCalculation',
|
|
16974
|
-
onDone: {
|
|
16975
|
-
target: 'calculated',
|
|
16976
|
-
actions: 'setCalculation',
|
|
16977
|
-
},
|
|
16978
|
-
onError: {
|
|
16979
|
-
target: 'calculable',
|
|
16980
|
-
},
|
|
16981
|
-
},
|
|
16982
|
-
},
|
|
16983
|
-
calculated: {
|
|
16984
|
-
on: {
|
|
16985
|
-
SELECT_AMOUNT: {
|
|
16986
|
-
target: 'calculable',
|
|
16987
|
-
actions: 'addAmount',
|
|
16988
|
-
},
|
|
16989
|
-
KEY_IN: {
|
|
16990
|
-
target: 'calculable',
|
|
16991
|
-
actions: 'setAmount',
|
|
16992
|
-
},
|
|
16993
|
-
CONFIRM: {
|
|
16994
|
-
target: 'submitting',
|
|
16995
|
-
},
|
|
16996
|
-
BACK: {
|
|
16997
|
-
target: 'loaded',
|
|
16998
|
-
},
|
|
16999
|
-
CLEAR_CALCULATION: {
|
|
17000
|
-
target: 'calculable',
|
|
17001
|
-
actions: 'clearCalculation',
|
|
17002
|
-
},
|
|
17003
|
-
},
|
|
17004
|
-
},
|
|
17005
|
-
submitting: {
|
|
17006
|
-
invoke: {
|
|
17007
|
-
src: 'submitDeposit',
|
|
17008
|
-
onDone: {
|
|
17009
|
-
target: 'submitted',
|
|
17010
|
-
actions: 'setResult',
|
|
17011
|
-
},
|
|
17012
|
-
onError: {
|
|
17013
|
-
target: 'calculated',
|
|
17014
|
-
},
|
|
17015
|
-
},
|
|
17016
|
-
},
|
|
17017
|
-
submitted: {
|
|
17018
|
-
on: {
|
|
17019
|
-
SELECT_QRCODE: {
|
|
17020
|
-
target: 'loaded',
|
|
17021
|
-
actions: 'setQrcode',
|
|
17022
|
-
},
|
|
17023
|
-
},
|
|
17024
|
-
},
|
|
17025
|
-
},
|
|
17026
|
-
},
|
|
17027
|
-
{
|
|
17028
|
-
actions: {
|
|
17029
|
-
reset: assign((context, event) => {
|
|
17030
|
-
return {
|
|
17031
|
-
selectedAmount: null,
|
|
17032
|
-
calculation: null,
|
|
17033
|
-
}
|
|
17034
|
-
}),
|
|
17035
|
-
setInitData: assign((context, event) => {
|
|
17036
|
-
const paymentDetails = event.data;
|
|
17037
|
-
const qrcodes = paymentDetails.filter((element) => element.category === context.currentCategory);
|
|
17038
|
-
|
|
17039
|
-
return {
|
|
17040
|
-
paymentDetails,
|
|
17041
|
-
qrcodes,
|
|
17042
|
-
selectedQrcode: qrcodes[0],
|
|
17043
|
-
currentMethod: qrcodes[0].method,
|
|
17044
|
-
options: qrcodes[0].optional,
|
|
17045
|
-
}
|
|
17046
|
-
}),
|
|
17047
|
-
setQrcode: assign((context, event) => {
|
|
17048
|
-
return {
|
|
17049
|
-
selectedQrcode: event.data,
|
|
17050
|
-
currentMethod: event.data.method,
|
|
17051
|
-
options: event.data.optional,
|
|
17052
|
-
}
|
|
17053
|
-
}),
|
|
17054
|
-
addAmount: assign((context, event) => {
|
|
17055
|
-
return { selectedAmount: (context.selectedAmount || 0) + event.data }
|
|
17056
|
-
}),
|
|
17057
|
-
setAmount: assign((context, event) => {
|
|
17058
|
-
return { selectedAmount: event.data }
|
|
17059
|
-
}),
|
|
17060
|
-
setCalculation: assign((context, event) => {
|
|
17061
|
-
return {
|
|
17062
|
-
calculation: event.data,
|
|
17063
|
-
}
|
|
17064
|
-
}),
|
|
17065
|
-
clearCalculation: assign((context, event) => {
|
|
17066
|
-
return {
|
|
17067
|
-
calculation: null,
|
|
17068
|
-
}
|
|
17069
|
-
}),
|
|
17070
|
-
setResult: assign((context, event) => {
|
|
17071
|
-
return {
|
|
17072
|
-
result: event.data,
|
|
17073
|
-
}
|
|
17074
|
-
}),
|
|
17075
|
-
},
|
|
17076
|
-
services: {
|
|
17077
|
-
fetchInitData: async (context, event) => {
|
|
17078
|
-
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
17079
|
-
},
|
|
17080
|
-
fetchBanksList: async (context, event) => {
|
|
17081
|
-
const { paymentDetails, currentCategory } = context;
|
|
17082
|
-
const method = paymentDetails.find((item) => item.category === currentCategory)?.method;
|
|
17083
|
-
return await request.send(payment.getBankList(method))
|
|
17084
|
-
},
|
|
17085
|
-
fetchCalculation: async (context, event) => {
|
|
17086
|
-
const { currentMethod, selectedAmount } = context;
|
|
17087
|
-
return await request.send(
|
|
17088
|
-
payment.getDepositExpectedResult({
|
|
17089
|
-
method: currentMethod,
|
|
17090
|
-
amount: selectedAmount,
|
|
17091
|
-
})
|
|
17092
|
-
)
|
|
17093
|
-
},
|
|
17094
|
-
submitDeposit: async (context, event) => {
|
|
17095
|
-
const { currentMethod, selectedAmount } = context;
|
|
17096
|
-
return await request.send(
|
|
17097
|
-
payment.submitDepositTransaction({
|
|
17098
|
-
method: currentMethod,
|
|
17099
|
-
amount: selectedAmount,
|
|
17100
|
-
})
|
|
17101
|
-
)
|
|
17102
|
-
},
|
|
17103
|
-
},
|
|
17104
|
-
}
|
|
17105
|
-
)
|
|
17106
|
-
}
|
|
17107
|
-
|
|
17108
16904
|
function qrcode_v2 (request) {
|
|
17109
16905
|
const { appSecret } = request.config;
|
|
17110
16906
|
return createMachine(
|
|
@@ -19705,10 +19501,151 @@ function vpay (request) {
|
|
|
19705
19501
|
)
|
|
19706
19502
|
}
|
|
19707
19503
|
|
|
19504
|
+
function usdt (request) {
|
|
19505
|
+
return createMachine(
|
|
19506
|
+
{
|
|
19507
|
+
id: 'usdt',
|
|
19508
|
+
initial: 'loading',
|
|
19509
|
+
context: {
|
|
19510
|
+
paymentDetails: [],
|
|
19511
|
+
currentCategory: 'usdt',
|
|
19512
|
+
currentPayment: null,
|
|
19513
|
+
networks: [],
|
|
19514
|
+
selectedNetwork: null,
|
|
19515
|
+
|
|
19516
|
+
resultMap: {},
|
|
19517
|
+
result: {
|
|
19518
|
+
action: '',
|
|
19519
|
+
cdtime: null,
|
|
19520
|
+
accountNumber: '', // crypto address
|
|
19521
|
+
currency: '',
|
|
19522
|
+
network: '',
|
|
19523
|
+
name: '',
|
|
19524
|
+
qrcode: '',
|
|
19525
|
+
},
|
|
19526
|
+
},
|
|
19527
|
+
states: {
|
|
19528
|
+
loading: {
|
|
19529
|
+
invoke: {
|
|
19530
|
+
src: 'fetchPayments',
|
|
19531
|
+
onDone: {
|
|
19532
|
+
target: 'fetching',
|
|
19533
|
+
actions: 'setPayment',
|
|
19534
|
+
},
|
|
19535
|
+
onError: {
|
|
19536
|
+
target: '#usdt.fail',
|
|
19537
|
+
},
|
|
19538
|
+
},
|
|
19539
|
+
},
|
|
19540
|
+
finding: {
|
|
19541
|
+
always: [
|
|
19542
|
+
{
|
|
19543
|
+
target: 'idle',
|
|
19544
|
+
actions: 'setResultFromLocal',
|
|
19545
|
+
cond: 'isFound',
|
|
19546
|
+
},
|
|
19547
|
+
{
|
|
19548
|
+
target: 'fetching',
|
|
19549
|
+
},
|
|
19550
|
+
],
|
|
19551
|
+
},
|
|
19552
|
+
fetching: {
|
|
19553
|
+
invoke: {
|
|
19554
|
+
src: 'submitDeposit',
|
|
19555
|
+
onDone: {
|
|
19556
|
+
target: 'idle',
|
|
19557
|
+
actions: 'setResult',
|
|
19558
|
+
},
|
|
19559
|
+
onError: {
|
|
19560
|
+
target: 'idle',
|
|
19561
|
+
},
|
|
19562
|
+
},
|
|
19563
|
+
},
|
|
19564
|
+
idle: {},
|
|
19565
|
+
fail: {},
|
|
19566
|
+
},
|
|
19567
|
+
on: {
|
|
19568
|
+
SET_NETWORK: {
|
|
19569
|
+
target: '.finding',
|
|
19570
|
+
actions: 'setNetwork',
|
|
19571
|
+
},
|
|
19572
|
+
},
|
|
19573
|
+
},
|
|
19574
|
+
{
|
|
19575
|
+
actions: {
|
|
19576
|
+
setPayment: assign((context, event) => {
|
|
19577
|
+
const currentPayment = event.data.find((element) => element.category === context.currentCategory);
|
|
19578
|
+
const defaultNetworks = currentPayment.networkName.map((value, i) => {
|
|
19579
|
+
return {
|
|
19580
|
+
label: currentPayment.networkOptional?.[i],
|
|
19581
|
+
value,
|
|
19582
|
+
icon: value,
|
|
19583
|
+
}
|
|
19584
|
+
});
|
|
19585
|
+
|
|
19586
|
+
return {
|
|
19587
|
+
networks: defaultNetworks,
|
|
19588
|
+
selectedNetwork: defaultNetworks[0],
|
|
19589
|
+
currentPayment,
|
|
19590
|
+
}
|
|
19591
|
+
}),
|
|
19592
|
+
setNetwork: assign((context, event) => {
|
|
19593
|
+
return { selectedNetwork: event.data }
|
|
19594
|
+
}),
|
|
19595
|
+
setResultFromLocal: assign((context, event) => {
|
|
19596
|
+
const { resultMap, selectedNetwork } = context;
|
|
19597
|
+
return { result: resultMap[selectedNetwork.value] }
|
|
19598
|
+
}),
|
|
19599
|
+
setResult: assign((context, event) => {
|
|
19600
|
+
const { resultMap, selectedNetwork } = context;
|
|
19601
|
+
const { action, cdtime, accountNumber, currency, network, name, qrcode } = event.data;
|
|
19602
|
+
const result = {
|
|
19603
|
+
action,
|
|
19604
|
+
cdtime,
|
|
19605
|
+
accountNumber,
|
|
19606
|
+
currency,
|
|
19607
|
+
network,
|
|
19608
|
+
name,
|
|
19609
|
+
qrcode,
|
|
19610
|
+
};
|
|
19611
|
+
|
|
19612
|
+
return {
|
|
19613
|
+
result,
|
|
19614
|
+
resultMap: {
|
|
19615
|
+
...resultMap,
|
|
19616
|
+
[selectedNetwork.value]: result,
|
|
19617
|
+
},
|
|
19618
|
+
}
|
|
19619
|
+
}),
|
|
19620
|
+
},
|
|
19621
|
+
guards: {
|
|
19622
|
+
isFound: (context, event) => {
|
|
19623
|
+
const { resultMap, selectedNetwork } = context;
|
|
19624
|
+
return resultMap[selectedNetwork.value]
|
|
19625
|
+
},
|
|
19626
|
+
},
|
|
19627
|
+
services: {
|
|
19628
|
+
fetchPayments: async (context, event) => {
|
|
19629
|
+
return await request.send(payment$1.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
19630
|
+
},
|
|
19631
|
+
submitDeposit: async (context, event) => {
|
|
19632
|
+
const { currentPayment, selectedNetwork } = context;
|
|
19633
|
+
return await request.send(
|
|
19634
|
+
payment$1.submitDepositTransactionCrypto({
|
|
19635
|
+
method: currentPayment.method,
|
|
19636
|
+
cryptoCurrency: currentPayment.channel,
|
|
19637
|
+
cryptoNetwork: selectedNetwork.value,
|
|
19638
|
+
})
|
|
19639
|
+
)
|
|
19640
|
+
},
|
|
19641
|
+
},
|
|
19642
|
+
}
|
|
19643
|
+
)
|
|
19644
|
+
}
|
|
19645
|
+
|
|
19708
19646
|
var deposit = {
|
|
19709
19647
|
manual_vn,
|
|
19710
19648
|
loadcard_vn,
|
|
19711
|
-
qrcode_vn,
|
|
19712
19649
|
qrcode_v2,
|
|
19713
19650
|
deposit_fc,
|
|
19714
19651
|
crypto,
|
|
@@ -19717,6 +19654,7 @@ var deposit = {
|
|
|
19717
19654
|
amb,
|
|
19718
19655
|
float,
|
|
19719
19656
|
vpay,
|
|
19657
|
+
usdt,
|
|
19720
19658
|
};
|
|
19721
19659
|
|
|
19722
19660
|
function bonus (request) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import manual_vn from './manual_vn.js'
|
|
2
2
|
import loadcard_vn from './loadcard_vn.js'
|
|
3
|
-
import qrcode_vn from './qrcode_vn.js'
|
|
4
3
|
import qrcode_v2 from './qrcode_v2.js'
|
|
5
4
|
import deposit_fc from './deposit_fc.js'
|
|
6
5
|
import crypto from './crypto.js'
|
|
@@ -9,11 +8,11 @@ import direct from './direct.js'
|
|
|
9
8
|
import amb from './amb.js'
|
|
10
9
|
import float from './float.js'
|
|
11
10
|
import vpay from './vpay.js'
|
|
11
|
+
import usdt from './usdt.js'
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
14
|
manual_vn,
|
|
15
15
|
loadcard_vn,
|
|
16
|
-
qrcode_vn,
|
|
17
16
|
qrcode_v2,
|
|
18
17
|
deposit_fc,
|
|
19
18
|
crypto,
|
|
@@ -22,4 +21,5 @@ export default {
|
|
|
22
21
|
amb,
|
|
23
22
|
float,
|
|
24
23
|
vpay,
|
|
24
|
+
usdt,
|
|
25
25
|
}
|
|
@@ -0,0 +1,144 @@
|
|
|
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: 'usdt',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
paymentDetails: [],
|
|
11
|
+
currentCategory: 'usdt',
|
|
12
|
+
currentPayment: null,
|
|
13
|
+
networks: [],
|
|
14
|
+
selectedNetwork: null,
|
|
15
|
+
|
|
16
|
+
resultMap: {},
|
|
17
|
+
result: {
|
|
18
|
+
action: '',
|
|
19
|
+
cdtime: null,
|
|
20
|
+
accountNumber: '', // crypto address
|
|
21
|
+
currency: '',
|
|
22
|
+
network: '',
|
|
23
|
+
name: '',
|
|
24
|
+
qrcode: '',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
states: {
|
|
28
|
+
loading: {
|
|
29
|
+
invoke: {
|
|
30
|
+
src: 'fetchPayments',
|
|
31
|
+
onDone: {
|
|
32
|
+
target: 'fetching',
|
|
33
|
+
actions: 'setPayment',
|
|
34
|
+
},
|
|
35
|
+
onError: {
|
|
36
|
+
target: '#usdt.fail',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
finding: {
|
|
41
|
+
always: [
|
|
42
|
+
{
|
|
43
|
+
target: 'idle',
|
|
44
|
+
actions: 'setResultFromLocal',
|
|
45
|
+
cond: 'isFound',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
target: 'fetching',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
fetching: {
|
|
53
|
+
invoke: {
|
|
54
|
+
src: 'submitDeposit',
|
|
55
|
+
onDone: {
|
|
56
|
+
target: 'idle',
|
|
57
|
+
actions: 'setResult',
|
|
58
|
+
},
|
|
59
|
+
onError: {
|
|
60
|
+
target: 'idle',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
idle: {},
|
|
65
|
+
fail: {},
|
|
66
|
+
},
|
|
67
|
+
on: {
|
|
68
|
+
SET_NETWORK: {
|
|
69
|
+
target: '.finding',
|
|
70
|
+
actions: 'setNetwork',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
actions: {
|
|
76
|
+
setPayment: assign((context, event) => {
|
|
77
|
+
const currentPayment = event.data.find((element) => element.category === context.currentCategory)
|
|
78
|
+
const defaultNetworks = currentPayment.networkName.map((value, i) => {
|
|
79
|
+
return {
|
|
80
|
+
label: currentPayment.networkOptional?.[i],
|
|
81
|
+
value,
|
|
82
|
+
icon: value,
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
networks: defaultNetworks,
|
|
88
|
+
selectedNetwork: defaultNetworks[0],
|
|
89
|
+
currentPayment,
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
setNetwork: assign((context, event) => {
|
|
93
|
+
return { selectedNetwork: event.data }
|
|
94
|
+
}),
|
|
95
|
+
setResultFromLocal: assign((context, event) => {
|
|
96
|
+
const { resultMap, selectedNetwork } = context
|
|
97
|
+
return { result: resultMap[selectedNetwork.value] }
|
|
98
|
+
}),
|
|
99
|
+
setResult: assign((context, event) => {
|
|
100
|
+
const { resultMap, selectedNetwork } = context
|
|
101
|
+
const { action, cdtime, accountNumber, currency, network, name, qrcode } = event.data
|
|
102
|
+
const result = {
|
|
103
|
+
action,
|
|
104
|
+
cdtime,
|
|
105
|
+
accountNumber,
|
|
106
|
+
currency,
|
|
107
|
+
network,
|
|
108
|
+
name,
|
|
109
|
+
qrcode,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
result,
|
|
114
|
+
resultMap: {
|
|
115
|
+
...resultMap,
|
|
116
|
+
[selectedNetwork.value]: result,
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
},
|
|
121
|
+
guards: {
|
|
122
|
+
isFound: (context, event) => {
|
|
123
|
+
const { resultMap, selectedNetwork } = context
|
|
124
|
+
return resultMap[selectedNetwork.value]
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
services: {
|
|
128
|
+
fetchPayments: async (context, event) => {
|
|
129
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
130
|
+
},
|
|
131
|
+
submitDeposit: async (context, event) => {
|
|
132
|
+
const { currentPayment, selectedNetwork } = context
|
|
133
|
+
return await request.send(
|
|
134
|
+
payment.submitDepositTransactionCrypto({
|
|
135
|
+
method: currentPayment.method,
|
|
136
|
+
cryptoCurrency: currentPayment.channel,
|
|
137
|
+
cryptoNetwork: selectedNetwork.value,
|
|
138
|
+
})
|
|
139
|
+
)
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
}
|
|
@@ -1,206 +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: 'qrcode',
|
|
8
|
-
initial: 'loading',
|
|
9
|
-
context: {
|
|
10
|
-
qrcodes: [],
|
|
11
|
-
options: [],
|
|
12
|
-
|
|
13
|
-
selectedQrcode: null,
|
|
14
|
-
selectedAmount: null,
|
|
15
|
-
|
|
16
|
-
calculation: null,
|
|
17
|
-
|
|
18
|
-
paymentDetails: [],
|
|
19
|
-
currentCategory: 'qrcode',
|
|
20
|
-
currentMethod: null,
|
|
21
|
-
|
|
22
|
-
result: null,
|
|
23
|
-
},
|
|
24
|
-
states: {
|
|
25
|
-
loading: {
|
|
26
|
-
invoke: {
|
|
27
|
-
src: 'fetchInitData',
|
|
28
|
-
onDone: {
|
|
29
|
-
target: 'loaded',
|
|
30
|
-
actions: 'setInitData',
|
|
31
|
-
},
|
|
32
|
-
onError: {
|
|
33
|
-
target: 'fail',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
loaded: {
|
|
38
|
-
entry: 'reset',
|
|
39
|
-
on: {
|
|
40
|
-
SELECT_QRCODE: {
|
|
41
|
-
actions: 'setQrcode',
|
|
42
|
-
},
|
|
43
|
-
SELECT_AMOUNT: {
|
|
44
|
-
target: 'calculable',
|
|
45
|
-
actions: 'addAmount',
|
|
46
|
-
},
|
|
47
|
-
KEY_IN: {
|
|
48
|
-
target: 'calculable',
|
|
49
|
-
actions: 'setAmount',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
fail: {},
|
|
54
|
-
calculable: {
|
|
55
|
-
entry: 'clearCalculation',
|
|
56
|
-
on: {
|
|
57
|
-
SELECT_AMOUNT: {
|
|
58
|
-
actions: 'addAmount',
|
|
59
|
-
},
|
|
60
|
-
KEY_IN: {
|
|
61
|
-
actions: 'setAmount',
|
|
62
|
-
},
|
|
63
|
-
CALCULATE: {
|
|
64
|
-
target: 'calculating',
|
|
65
|
-
},
|
|
66
|
-
BACK: {
|
|
67
|
-
target: 'loaded',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
calculating: {
|
|
72
|
-
invoke: {
|
|
73
|
-
src: 'fetchCalculation',
|
|
74
|
-
onDone: {
|
|
75
|
-
target: 'calculated',
|
|
76
|
-
actions: 'setCalculation',
|
|
77
|
-
},
|
|
78
|
-
onError: {
|
|
79
|
-
target: 'calculable',
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
calculated: {
|
|
84
|
-
on: {
|
|
85
|
-
SELECT_AMOUNT: {
|
|
86
|
-
target: 'calculable',
|
|
87
|
-
actions: 'addAmount',
|
|
88
|
-
},
|
|
89
|
-
KEY_IN: {
|
|
90
|
-
target: 'calculable',
|
|
91
|
-
actions: 'setAmount',
|
|
92
|
-
},
|
|
93
|
-
CONFIRM: {
|
|
94
|
-
target: 'submitting',
|
|
95
|
-
},
|
|
96
|
-
BACK: {
|
|
97
|
-
target: 'loaded',
|
|
98
|
-
},
|
|
99
|
-
CLEAR_CALCULATION: {
|
|
100
|
-
target: 'calculable',
|
|
101
|
-
actions: 'clearCalculation',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
submitting: {
|
|
106
|
-
invoke: {
|
|
107
|
-
src: 'submitDeposit',
|
|
108
|
-
onDone: {
|
|
109
|
-
target: 'submitted',
|
|
110
|
-
actions: 'setResult',
|
|
111
|
-
},
|
|
112
|
-
onError: {
|
|
113
|
-
target: 'calculated',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
submitted: {
|
|
118
|
-
on: {
|
|
119
|
-
SELECT_QRCODE: {
|
|
120
|
-
target: 'loaded',
|
|
121
|
-
actions: 'setQrcode',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
actions: {
|
|
129
|
-
reset: assign((context, event) => {
|
|
130
|
-
return {
|
|
131
|
-
selectedAmount: null,
|
|
132
|
-
calculation: null,
|
|
133
|
-
}
|
|
134
|
-
}),
|
|
135
|
-
setInitData: assign((context, event) => {
|
|
136
|
-
const paymentDetails = event.data
|
|
137
|
-
const qrcodes = paymentDetails.filter((element) => element.category === context.currentCategory)
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
paymentDetails,
|
|
141
|
-
qrcodes,
|
|
142
|
-
selectedQrcode: qrcodes[0],
|
|
143
|
-
currentMethod: qrcodes[0].method,
|
|
144
|
-
options: qrcodes[0].optional,
|
|
145
|
-
}
|
|
146
|
-
}),
|
|
147
|
-
setQrcode: assign((context, event) => {
|
|
148
|
-
return {
|
|
149
|
-
selectedQrcode: event.data,
|
|
150
|
-
currentMethod: event.data.method,
|
|
151
|
-
options: event.data.optional,
|
|
152
|
-
}
|
|
153
|
-
}),
|
|
154
|
-
addAmount: assign((context, event) => {
|
|
155
|
-
return { selectedAmount: (context.selectedAmount || 0) + event.data }
|
|
156
|
-
}),
|
|
157
|
-
setAmount: assign((context, event) => {
|
|
158
|
-
return { selectedAmount: event.data }
|
|
159
|
-
}),
|
|
160
|
-
setCalculation: assign((context, event) => {
|
|
161
|
-
return {
|
|
162
|
-
calculation: event.data,
|
|
163
|
-
}
|
|
164
|
-
}),
|
|
165
|
-
clearCalculation: assign((context, event) => {
|
|
166
|
-
return {
|
|
167
|
-
calculation: null,
|
|
168
|
-
}
|
|
169
|
-
}),
|
|
170
|
-
setResult: assign((context, event) => {
|
|
171
|
-
return {
|
|
172
|
-
result: event.data,
|
|
173
|
-
}
|
|
174
|
-
}),
|
|
175
|
-
},
|
|
176
|
-
services: {
|
|
177
|
-
fetchInitData: async (context, event) => {
|
|
178
|
-
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
179
|
-
},
|
|
180
|
-
fetchBanksList: async (context, event) => {
|
|
181
|
-
const { paymentDetails, currentCategory } = context
|
|
182
|
-
const method = paymentDetails.find((item) => item.category === currentCategory)?.method
|
|
183
|
-
return await request.send(payment.getBankList(method))
|
|
184
|
-
},
|
|
185
|
-
fetchCalculation: async (context, event) => {
|
|
186
|
-
const { currentMethod, selectedAmount } = context
|
|
187
|
-
return await request.send(
|
|
188
|
-
payment.getDepositExpectedResult({
|
|
189
|
-
method: currentMethod,
|
|
190
|
-
amount: selectedAmount,
|
|
191
|
-
})
|
|
192
|
-
)
|
|
193
|
-
},
|
|
194
|
-
submitDeposit: async (context, event) => {
|
|
195
|
-
const { currentMethod, selectedAmount } = context
|
|
196
|
-
return await request.send(
|
|
197
|
-
payment.submitDepositTransaction({
|
|
198
|
-
method: currentMethod,
|
|
199
|
-
amount: selectedAmount,
|
|
200
|
-
})
|
|
201
|
-
)
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
}
|
|
205
|
-
)
|
|
206
|
-
}
|