@jetthai/cuora 1.0.146 → 1.0.147
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
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.0.147](https://github.com/jetthai/cuora-module/compare/v1.0.146...v1.0.147) (2022-07-21)
|
|
6
|
+
|
|
7
|
+
### [1.0.144-1](https://github.com/jetthai/cuora-module/compare/v1.0.141-1...v1.0.144-1) (2022-07-18)
|
|
8
|
+
|
|
5
9
|
### [1.0.146](https://github.com/jetthai/cuora-module/compare/v1.0.145...v1.0.146) (2022-07-19)
|
|
6
10
|
|
|
7
11
|
### [1.0.145](https://github.com/jetthai/cuora-module/compare/v1.0.141-2...v1.0.145) (2022-07-19)
|
|
@@ -10,6 +14,8 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
10
14
|
|
|
11
15
|
### [1.0.143](https://github.com/jetthai/cuora-module/compare/v1.0.141...v1.0.143) (2022-07-14)
|
|
12
16
|
|
|
17
|
+
### [1.0.144-1](https://github.com/jetthai/cuora-module/compare/v1.0.144...v1.0.144-1) (2022-07-18)
|
|
18
|
+
|
|
13
19
|
### [1.0.144](https://github.com/jetthai/cuora-module/compare/v1.0.140-2...v1.0.144) (2022-07-17)
|
|
14
20
|
|
|
15
21
|
### [1.0.143](https://github.com/jetthai/cuora-module/compare/v1.0.141...v1.0.143) (2022-07-14)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -291,14 +291,14 @@ export default function (request) {
|
|
|
291
291
|
const redirectURL = urljoin(
|
|
292
292
|
request.config.fullURL,
|
|
293
293
|
'login?' +
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
294
|
+
qs.stringify({
|
|
295
|
+
provider,
|
|
296
|
+
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
297
|
+
channel: cookies.get('channel') || channel || defaultChannel || 'official',
|
|
298
|
+
subchannel: cookies.get('subchannel') || subchannel || defaultSubchannel || 'pwa',
|
|
299
|
+
// dt,
|
|
300
|
+
platform: 'pwa',
|
|
301
|
+
})
|
|
302
302
|
)
|
|
303
303
|
window.location.href = redirectURL
|
|
304
304
|
},
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'direct',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
paymentDetails: [],
|
|
11
|
+
directs: [],
|
|
12
|
+
currentDirect: null,
|
|
13
|
+
banks: [],
|
|
14
|
+
selectedBank: null,
|
|
15
|
+
calculation: null,
|
|
16
|
+
currentCategory: 'direct',
|
|
17
|
+
currentMethod: null,
|
|
18
|
+
amount: null,
|
|
19
|
+
result: null
|
|
20
|
+
},
|
|
21
|
+
states: {
|
|
22
|
+
loading: {
|
|
23
|
+
initial: 'step1',
|
|
24
|
+
states: {
|
|
25
|
+
step1: {
|
|
26
|
+
invoke: {
|
|
27
|
+
src: 'fetchInitData',
|
|
28
|
+
onDone: {
|
|
29
|
+
target: 'step2',
|
|
30
|
+
actions: 'setInitData',
|
|
31
|
+
},
|
|
32
|
+
onError: {
|
|
33
|
+
target: '#direct.fail',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
step2: {
|
|
38
|
+
invoke: {
|
|
39
|
+
src: 'fetchBanksList',
|
|
40
|
+
onDone: {
|
|
41
|
+
target: '#direct.loaded',
|
|
42
|
+
actions: 'setBanks',
|
|
43
|
+
},
|
|
44
|
+
onError: {
|
|
45
|
+
target: '#direct.fail',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
loaded: {
|
|
52
|
+
on: {
|
|
53
|
+
SELECT_DIRECT: {
|
|
54
|
+
actions: ['setDirect', 'reset']
|
|
55
|
+
},
|
|
56
|
+
SELECT_BANK: {
|
|
57
|
+
actions: 'setSelectedBank',
|
|
58
|
+
},
|
|
59
|
+
SET_AMOUNT: {
|
|
60
|
+
actions: ['setAmount', 'clearCalculation'],
|
|
61
|
+
},
|
|
62
|
+
CLEAR_CALCULATION: {
|
|
63
|
+
actions: 'clearCalculation',
|
|
64
|
+
},
|
|
65
|
+
CALCULATE: {
|
|
66
|
+
target: 'calculating',
|
|
67
|
+
cond: 'isCalculable',
|
|
68
|
+
},
|
|
69
|
+
SUBMIT: {
|
|
70
|
+
target: 'submitting',
|
|
71
|
+
cond: 'isSubmittable',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
calculating: {
|
|
76
|
+
invoke: {
|
|
77
|
+
src: 'fetchCalculation',
|
|
78
|
+
onDone: {
|
|
79
|
+
target: 'loaded',
|
|
80
|
+
actions: 'setCalculation',
|
|
81
|
+
},
|
|
82
|
+
onError: {
|
|
83
|
+
target: 'loaded',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
submitting: {
|
|
88
|
+
invoke: {
|
|
89
|
+
src: 'submitDeposit',
|
|
90
|
+
onDone: {
|
|
91
|
+
target: 'submitted',
|
|
92
|
+
actions: 'setResult',
|
|
93
|
+
},
|
|
94
|
+
onError: {
|
|
95
|
+
target: 'loaded',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
submitted: {},
|
|
100
|
+
fail: {},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
actions: {
|
|
105
|
+
reset: assign((context, event) => {
|
|
106
|
+
const { banks } = context
|
|
107
|
+
return {
|
|
108
|
+
amount: null,
|
|
109
|
+
selectedBank: banks[0],
|
|
110
|
+
calculation: null,
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
setInitData: assign((context, event) => {
|
|
114
|
+
const paymentDetails = event.data
|
|
115
|
+
const directs = paymentDetails.filter((element) => element.category === context.currentCategory)
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
paymentDetails,
|
|
119
|
+
directs,
|
|
120
|
+
currentDirect: directs[0],
|
|
121
|
+
currentMethod: directs[0]?.method,
|
|
122
|
+
}
|
|
123
|
+
}),
|
|
124
|
+
setBanks: assign((context, event) => {
|
|
125
|
+
const banks = event.data
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
banks,
|
|
129
|
+
selectedBank: banks[0],
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
setDirect: assign((context, event) => {
|
|
133
|
+
return {
|
|
134
|
+
currentDirect: event.data,
|
|
135
|
+
currentMethod: event.data.method,
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
setSelectedBank: assign((context, event) => {
|
|
139
|
+
return {
|
|
140
|
+
selectedBank: event.data,
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
setAmount: assign((context, event) => {
|
|
144
|
+
return {
|
|
145
|
+
amount: event.data
|
|
146
|
+
}
|
|
147
|
+
}),
|
|
148
|
+
setCalculation: assign((context, event) => {
|
|
149
|
+
return {
|
|
150
|
+
calculation: event.data,
|
|
151
|
+
}
|
|
152
|
+
}),
|
|
153
|
+
clearCalculation: assign((context, event) => {
|
|
154
|
+
return {
|
|
155
|
+
calculation: null,
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
setResult: assign((context, event) => {
|
|
159
|
+
return {
|
|
160
|
+
result: event.data,
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
},
|
|
164
|
+
guards: {
|
|
165
|
+
isCalculable: (context, event) => {
|
|
166
|
+
const {
|
|
167
|
+
amount,
|
|
168
|
+
currentDirect: { maximum, minimum },
|
|
169
|
+
} = context
|
|
170
|
+
|
|
171
|
+
return amount && minimum <= +amount && +amount <= maximum
|
|
172
|
+
},
|
|
173
|
+
isSubmittable: (context, event) => {
|
|
174
|
+
const { amount, currentMethod, selectedBank } = context
|
|
175
|
+
return amount && currentMethod && selectedBank?.bankCode
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
services: {
|
|
179
|
+
fetchInitData: async (context, event) => {
|
|
180
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
181
|
+
},
|
|
182
|
+
fetchBanksList: async (context, event) => {
|
|
183
|
+
const { paymentDetails } = context
|
|
184
|
+
const method = paymentDetails.find((item) => item.category === 'manual')?.method
|
|
185
|
+
return await request.send(payment.getBankList(method))
|
|
186
|
+
},
|
|
187
|
+
fetchCalculation: async (context, event) => {
|
|
188
|
+
const { currentMethod, amount } = context
|
|
189
|
+
|
|
190
|
+
return await request.send(
|
|
191
|
+
payment.getDepositExpectedResult({
|
|
192
|
+
method: currentMethod,
|
|
193
|
+
amount,
|
|
194
|
+
})
|
|
195
|
+
)
|
|
196
|
+
},
|
|
197
|
+
submitDeposit: async (context, event) => {
|
|
198
|
+
const { currentMethod, amount, selectedBank } = context
|
|
199
|
+
return await request.send(
|
|
200
|
+
payment.submitDepositTransactionBank({
|
|
201
|
+
method: currentMethod,
|
|
202
|
+
amount,
|
|
203
|
+
applyerBankCode: selectedBank.bankCode
|
|
204
|
+
})
|
|
205
|
+
)
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
@@ -4,5 +4,6 @@ import qrcode_vn from './qrcode_vn'
|
|
|
4
4
|
import qrcode_v2 from './qrcode_v2'
|
|
5
5
|
import deposit_fc from './deposit_fc'
|
|
6
6
|
import crypto from './crypto'
|
|
7
|
+
import direct from './direct'
|
|
7
8
|
|
|
8
|
-
export default { manual_vn, loadcard_vn, qrcode_vn, qrcode_v2, deposit_fc, crypto }
|
|
9
|
+
export default { manual_vn, loadcard_vn, qrcode_vn, qrcode_v2, deposit_fc, crypto, direct }
|
|
@@ -15,7 +15,7 @@ export default function (request) {
|
|
|
15
15
|
channel: null,
|
|
16
16
|
subchannel: null,
|
|
17
17
|
signUpData: {},
|
|
18
|
-
reCaptchaToken: null
|
|
18
|
+
reCaptchaToken: null
|
|
19
19
|
},
|
|
20
20
|
states: {
|
|
21
21
|
idle: {
|
|
@@ -49,7 +49,7 @@ export default function (request) {
|
|
|
49
49
|
setReCaptchaToken: assign((context, event) => {
|
|
50
50
|
const { reCaptchaToken } = event.data
|
|
51
51
|
return {
|
|
52
|
-
reCaptchaToken
|
|
52
|
+
reCaptchaToken
|
|
53
53
|
}
|
|
54
54
|
}),
|
|
55
55
|
setSignUpPhone: assign((context, event) => {
|
|
@@ -89,7 +89,7 @@ export default function (request) {
|
|
|
89
89
|
channel: cookies.get('channel') || defaultChannel || channel,
|
|
90
90
|
subchannel: cookies.get('subchannel') || defaultSubchannel || subchannel,
|
|
91
91
|
dt,
|
|
92
|
-
reCaptchaToken: context.reCaptchaToken
|
|
92
|
+
reCaptchaToken: context.reCaptchaToken
|
|
93
93
|
})
|
|
94
94
|
)
|
|
95
95
|
},
|