@jetthai/cuora 1.0.68 → 1.0.70

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.70](https://github.com/jetthai/cuora-module/compare/v1.0.69...v1.0.70) (2022-01-02)
6
+
7
+ ### [1.0.69](https://github.com/jetthai/cuora-module/compare/v1.0.68...v1.0.69) (2021-12-29)
8
+
5
9
  ### [1.0.68](https://github.com/jetthai/cuora-module/compare/v1.0.67...v1.0.68) (2021-12-28)
6
10
 
7
11
  ### [1.0.67](https://github.com/jetthai/cuora-module/compare/v1.0.66...v1.0.67) (2021-12-24)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.68",
3
+ "version": "1.0.70",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -52,6 +52,36 @@ export default {
52
52
  method: 'post',
53
53
  params: { transferType: 'DEPOSIT', amount, card_type, card_code, card_seri },
54
54
  }),
55
+ submitDepositTransactionBank: ({
56
+ method,
57
+ amount,
58
+ applyerBankCode,
59
+ applyerAccountNumber,
60
+ applyerHolderName,
61
+ targetBankCode,
62
+ targetAccountNumber,
63
+ depositTime = '1234567890',
64
+ receipt,
65
+ }) => ({
66
+ url: `payment/v2/${method}/transaction`,
67
+ method: 'post',
68
+ params: {
69
+ transferType: 'DEPOSIT',
70
+ amount,
71
+ applyerBankCode,
72
+ applyerAccountNumber,
73
+ applyerHolderName,
74
+ targetBankCode,
75
+ targetAccountNumber,
76
+ depositTime,
77
+ receipt,
78
+ },
79
+ }),
80
+ submitDepositTransactionQrcode: ({ method, amount }) => ({
81
+ url: `payment/v2/${method}/transaction`,
82
+ method: 'post',
83
+ params: { transferType: 'DEPOSIT', amount },
84
+ }),
55
85
  submitWithdrawTransaction: ({ method, amount, cryptoCurrency, cryptoNetwork, targetAddress }) => ({
56
86
  url: `payment/v2/${method}/transaction`,
57
87
  method: 'post',
@@ -0,0 +1,75 @@
1
+ import { assign, createMachine, send } from 'xstate'
2
+ import payment from '../api/payment'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'bonus',
8
+ initial: 'loading',
9
+ context: {
10
+ bonus: null,
11
+ },
12
+ states: {
13
+ loading: {
14
+ invoke: {
15
+ src: 'fetchInitData',
16
+ onDone: {
17
+ target: 'idle',
18
+ actions: 'setBonus',
19
+ },
20
+ onError: {
21
+ target: 'idle',
22
+ },
23
+ },
24
+ },
25
+ idle: {
26
+ on: {
27
+ TOGGLE: {
28
+ target: 'updating',
29
+ },
30
+ SWITCH_ON: {
31
+ actions: send((context, event) => ({ type: 'TOGGLE', data: 1 })),
32
+ cond: (context, event) => context.bonus !== 1,
33
+ },
34
+ SWITCH_OFF: {
35
+ actions: send((context, event) => ({ type: 'TOGGLE', data: 0 })),
36
+ cond: (context, event) => context.bonus !== 0,
37
+ },
38
+ },
39
+ },
40
+ updating: {
41
+ invoke: {
42
+ src: 'toggleBonus',
43
+ onDone: {
44
+ target: 'idle',
45
+ actions: 'setBonus',
46
+ },
47
+ onError: {
48
+ target: 'idle',
49
+ },
50
+ },
51
+ },
52
+ },
53
+ },
54
+ {
55
+ actions: {
56
+ setBonus: assign((context, event) => {
57
+ return {
58
+ bonus: event.data,
59
+ }
60
+ }),
61
+ },
62
+ services: {
63
+ fetchInitData: async (context, event) => {
64
+ const { bonus } = await request.send(payment.getPaymentInfo())
65
+ return bonus
66
+ },
67
+ toggleBonus: async (context, event) => {
68
+ const bonus = context.bonus ? 0 : 1
69
+ await request.send(payment.setBonusSetting({ bonus }))
70
+ return bonus
71
+ },
72
+ },
73
+ }
74
+ )
75
+ }
@@ -1,6 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import toNumber from 'lodash/toNumber'
3
- import payment from '../api/payment'
3
+ import payment from '../../api/payment'
4
4
 
5
5
  export default function (request) {
6
6
  return createMachine(
@@ -0,0 +1,6 @@
1
+ import manual_vn from './manual_vn'
2
+ import loadcard_vn from './loadcard_vn'
3
+ import qrcode_vn from './qrcode_vn'
4
+ import deposit_fc from './deposit_fc'
5
+
6
+ export default { manual_vn, loadcard_vn, qrcode_vn, deposit_fc }
@@ -0,0 +1,230 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'loadcard',
8
+ initial: 'loading',
9
+ context: {
10
+ cards: [
11
+ { name: 'mobifone', code: 'VMS' },
12
+ { name: 'viettel', code: 'VTT' },
13
+ { name: 'vinaphone', code: 'VNP' },
14
+ // { name: 'vietnam mobile', code: 'VNM' },
15
+ // { name: 'thẻ zing', code: 'ZING' },
16
+ // { name: 'thẻ gate', code: 'GATE' },
17
+ // { name: 'thẻ garena', code: 'GARENA' },
18
+ ],
19
+ options: [],
20
+
21
+ selectedCard: null,
22
+ selectedAmount: null,
23
+ cardNumber: null,
24
+ serialNumber: null,
25
+
26
+ calculation: null,
27
+
28
+ paymentDetails: [],
29
+ currentMethodType: 'loadcard',
30
+ currentMethod: null,
31
+ currentPayment: null,
32
+ },
33
+ states: {
34
+ loading: {
35
+ invoke: {
36
+ src: 'fetchInitData',
37
+ onDone: {
38
+ target: 'loaded',
39
+ actions: 'setInitData',
40
+ },
41
+ onError: {
42
+ target: 'fail',
43
+ },
44
+ },
45
+ },
46
+ loaded: {
47
+ entry: 'reset',
48
+ on: {
49
+ SELECT_CARD: {
50
+ actions: 'setCard',
51
+ },
52
+ SELECT_AMOUNT: {
53
+ target: 'calculable',
54
+ actions: 'setAmount',
55
+ },
56
+ },
57
+ },
58
+ fail: {},
59
+ calculable: {
60
+ entry: 'clearCalculation',
61
+ on: {
62
+ SELECT_AMOUNT: {
63
+ actions: 'setAmount',
64
+ },
65
+ CALCULATE: {
66
+ target: 'calculating',
67
+ },
68
+ BACK: {
69
+ target: 'loaded',
70
+ },
71
+ },
72
+ },
73
+ calculating: {
74
+ invoke: {
75
+ src: 'fetchCalculation',
76
+ onDone: {
77
+ target: 'calculated',
78
+ actions: 'setCalculation',
79
+ },
80
+ onError: {
81
+ target: 'calculable',
82
+ },
83
+ },
84
+ },
85
+ calculated: {
86
+ on: {
87
+ SELECT_AMOUNT: {
88
+ target: 'calculable',
89
+ actions: 'setAmount',
90
+ },
91
+ CONFIRM: {
92
+ target: 'cardInfo',
93
+ },
94
+ BACK: {
95
+ target: 'loaded',
96
+ },
97
+ CLEAR_CALCULATION: {
98
+ target: 'calculable',
99
+ actions: 'clearCalculation',
100
+ },
101
+ },
102
+ },
103
+ cardInfo: {
104
+ on: {
105
+ INPUT_CARD_NUMBER: {
106
+ actions: 'setCardNumber',
107
+ },
108
+ INPUT_SERIAL_NUMBER: {
109
+ actions: 'setSerialNumber',
110
+ },
111
+ SUBMIT: {
112
+ target: 'submitting',
113
+ cond: 'isSubmittable',
114
+ },
115
+ SELECT_CARD: {
116
+ target: 'loaded',
117
+ actions: 'setCard',
118
+ },
119
+ },
120
+ },
121
+ submitting: {
122
+ invoke: {
123
+ src: 'submitDeposit',
124
+ onDone: {
125
+ target: 'submitted',
126
+ },
127
+ onError: {
128
+ target: 'cardInfo',
129
+ },
130
+ },
131
+ },
132
+ submitted: {
133
+ on: {
134
+ BACK: {
135
+ target: 'loaded',
136
+ },
137
+ },
138
+ },
139
+ },
140
+ },
141
+ {
142
+ actions: {
143
+ reset: assign((context, event) => {
144
+ return {
145
+ selectedAmount: null,
146
+ cardNumber: null,
147
+ serialNumber: null,
148
+ calculation: null,
149
+ }
150
+ }),
151
+ setInitData: assign((context, event) => {
152
+ const paymentDetails = event.data
153
+ const currentPayment = paymentDetails.find((element) => element.methodType === context.currentMethodType)
154
+ return {
155
+ paymentDetails,
156
+ currentPayment,
157
+ currentMethod: currentPayment.method,
158
+ options: currentPayment.optional,
159
+ selectedCard: context.cards[0],
160
+ }
161
+ }),
162
+ setCard: assign((context, event) => {
163
+ return {
164
+ selectedCard: event.data,
165
+ }
166
+ }),
167
+ setCardNumber: assign((context, event) => {
168
+ return {
169
+ cardNumber: event.data,
170
+ }
171
+ }),
172
+ setSerialNumber: assign((context, event) => {
173
+ return {
174
+ serialNumber: event.data,
175
+ }
176
+ }),
177
+ setAmount: assign((context, event) => {
178
+ return { selectedAmount: event.data }
179
+ }),
180
+ setCalculation: assign((context, event) => {
181
+ return {
182
+ calculation: event.data,
183
+ }
184
+ }),
185
+ clearCalculation: assign((context, event) => {
186
+ return {
187
+ calculation: null,
188
+ }
189
+ }),
190
+ },
191
+ guards: {
192
+ isSubmittable: (context, event) => {
193
+ const { cardNumber, serialNumber } = context
194
+ return cardNumber && serialNumber
195
+ },
196
+ },
197
+ services: {
198
+ fetchInitData: async (context, event) => {
199
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
200
+ },
201
+ fetchBanksList: async (context, event) => {
202
+ const { paymentDetails, currentMethodType } = context
203
+ const method = paymentDetails.find((item) => item.methodType === currentMethodType)?.method
204
+ return await request.send(payment.getBankList(method))
205
+ },
206
+ fetchCalculation: async (context, event) => {
207
+ const { currentMethod, selectedAmount } = context
208
+ return await request.send(
209
+ payment.getDepositExpectedResult({
210
+ method: currentMethod,
211
+ amount: selectedAmount,
212
+ })
213
+ )
214
+ },
215
+ submitDeposit: async (context, event) => {
216
+ const { currentMethod, selectedCard, selectedAmount, cardNumber, serialNumber } = context
217
+ return await request.send(
218
+ payment.submitDepositTransactionLoadcard({
219
+ method: currentMethod,
220
+ amount: selectedAmount,
221
+ card_type: selectedCard.code,
222
+ card_code: cardNumber,
223
+ card_seri: serialNumber,
224
+ })
225
+ )
226
+ },
227
+ },
228
+ }
229
+ )
230
+ }
@@ -0,0 +1,320 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'manual',
8
+ initial: 'loading',
9
+ context: {
10
+ paymentDetails: [],
11
+
12
+ houseBanks: [],
13
+ playerBanks: [],
14
+ banks: [],
15
+
16
+ amount: null,
17
+ selectedHouseBank: null,
18
+ selectedUserBank: null,
19
+ userAccountNumber: null,
20
+ userAccountName: null,
21
+ depositTime: null,
22
+ receipt: null,
23
+
24
+ currentMethodType: 'manual',
25
+ method: null,
26
+ currentPayment: null,
27
+ currentApplyerBank: null,
28
+
29
+ calculation: null,
30
+ processing: null,
31
+ },
32
+ states: {
33
+ loading: {
34
+ initial: 'init1',
35
+ states: {
36
+ init1: {
37
+ invoke: {
38
+ src: 'fetchInitData',
39
+ onDone: {
40
+ target: 'init2',
41
+ actions: 'setInitData',
42
+ },
43
+ onError: {
44
+ target: '#manual.fail',
45
+ },
46
+ },
47
+ },
48
+ init2: {
49
+ always: [
50
+ {
51
+ target: '#manual.processing',
52
+ cond: 'isProcessing',
53
+ },
54
+ ],
55
+ invoke: {
56
+ src: 'fetchBanksList',
57
+ onDone: {
58
+ target: '#manual.step1',
59
+ actions: 'setBanks',
60
+ },
61
+ onError: {
62
+ target: '#manual.fail',
63
+ },
64
+ },
65
+ },
66
+ },
67
+ },
68
+ step1: {
69
+ initial: 'idle',
70
+ states: {
71
+ idle: {
72
+ on: {
73
+ SET_AMOUNT: {
74
+ actions: ['setAmount', 'clearCalculation'],
75
+ },
76
+ CALCULATE: {
77
+ target: 'calculating',
78
+ cond: 'isCalculable',
79
+ },
80
+ SELECT_HOUSE_BANK: {
81
+ actions: 'setHouseBank',
82
+ },
83
+ CLEAR_CALCULATION: {
84
+ actions: 'clearCalculation',
85
+ },
86
+ TRANSACT: {
87
+ target: '#manual.step2',
88
+ cond: 'isCalculated',
89
+ },
90
+ },
91
+ },
92
+ calculating: {
93
+ invoke: {
94
+ src: 'fetchCalculation',
95
+ onDone: {
96
+ target: 'idle',
97
+ actions: 'setCalculation',
98
+ },
99
+ onError: {
100
+ target: 'idle',
101
+ },
102
+ },
103
+ },
104
+ },
105
+ },
106
+ step2: {
107
+ initial: 'idle',
108
+ states: {
109
+ idle: {
110
+ on: {
111
+ SET_AMOUNT: {
112
+ actions: ['setAmount', 'clearCalculation'],
113
+ },
114
+ CALCULATE: {
115
+ target: 'calculating',
116
+ cond: 'isCalculable',
117
+ },
118
+ SELECT_HOUSE_BANK: {
119
+ actions: 'setHouseBank',
120
+ },
121
+ SELECT_USER_BANK: {
122
+ actions: 'setUserBank',
123
+ },
124
+ INPUT_USER_ACCOUNT_NUMBER: {
125
+ actions: 'setUserAccountNumber',
126
+ },
127
+ INPUT_USER_ACCOUNT_NAME: {
128
+ actions: 'setUserAccountName',
129
+ },
130
+ SET_DEPOSIT_TIME: {
131
+ actions: 'setDepositTime',
132
+ },
133
+ SET_RECEIPT: {
134
+ actions: 'setReceipt',
135
+ },
136
+ CLEAR_CALCULATION: {
137
+ actions: 'clearCalculation',
138
+ },
139
+ SUBMIT: {
140
+ target: 'submitting',
141
+ cond: 'isSubmittable',
142
+ },
143
+ },
144
+ },
145
+ calculating: {
146
+ invoke: {
147
+ src: 'fetchCalculation',
148
+ onDone: {
149
+ target: 'idle',
150
+ actions: 'setCalculation',
151
+ },
152
+ onError: {
153
+ target: 'idle',
154
+ },
155
+ },
156
+ },
157
+ submitting: {
158
+ invoke: {
159
+ src: 'submitDeposit',
160
+ onDone: {
161
+ target: '#manual.submitted',
162
+ actions: 'setProcessing',
163
+ },
164
+ onError: {
165
+ target: 'idle',
166
+ },
167
+ },
168
+ },
169
+ },
170
+ },
171
+ processing: {},
172
+ submitted: {},
173
+ fail: {},
174
+ },
175
+ },
176
+ {
177
+ actions: {
178
+ setInitData: assign((context, event) => {
179
+ const { paymentInfo, paymentDetails } = event.data
180
+ const bankInfoList = paymentInfo?.bankInfo || []
181
+ const currentPayment = paymentDetails.find((element) => element.methodType === context.currentMethodType)
182
+ const houseBanks = currentPayment.banks.map((item) => {
183
+ item.bankCode = item.bankName
184
+ return item
185
+ })
186
+ return {
187
+ paymentDetails,
188
+ currentPayment,
189
+ method: currentPayment.method,
190
+ houseBanks,
191
+ selectedHouseBank: houseBanks[0],
192
+ playerBanks: bankInfoList,
193
+ processing: currentPayment.processing?.[0],
194
+ }
195
+ }),
196
+ setBanks: assign((context, event) => {
197
+ const { playerBanks } = context
198
+
199
+ const formattedPlayerBanks = playerBanks.map((bank) => {
200
+ bank.shortName = `${bank.bankCode} ${bank.accountNumber.slice(-5)}`
201
+ return bank
202
+ })
203
+
204
+ const banks = [...formattedPlayerBanks, ...event.data]
205
+
206
+ return {
207
+ banks,
208
+ selectedUserBank: banks[0],
209
+ userAccountNumber: banks[0].accountNumber,
210
+ userAccountName: banks[0].holderName,
211
+ }
212
+ }),
213
+ setHouseBank: assign((context, event) => {
214
+ return {
215
+ selectedHouseBank: event.data,
216
+ }
217
+ }),
218
+ setAmount: assign((context, event) => {
219
+ return {
220
+ amount: event.data,
221
+ }
222
+ }),
223
+ setCalculation: assign((context, event) => {
224
+ return {
225
+ calculation: event.data,
226
+ }
227
+ }),
228
+ setProcessing: assign((context, event) => {
229
+ return {
230
+ processing: event.data,
231
+ }
232
+ }),
233
+ clearCalculation: assign((context, event) => {
234
+ return {
235
+ calculation: null,
236
+ }
237
+ }),
238
+ setUserBank: assign((context, event) => {
239
+ const { accountNumber, holderName } = event.data
240
+ return {
241
+ selectedUserBank: event.data,
242
+ userAccountNumber: accountNumber,
243
+ userAccountName: holderName,
244
+ }
245
+ }),
246
+ setUserAccountNumber: assign((context, event) => {
247
+ return {
248
+ userAccountNumber: event.data,
249
+ }
250
+ }),
251
+ setUserAccountName: assign((context, event) => {
252
+ return {
253
+ userAccountName: event.data,
254
+ }
255
+ }),
256
+ setDepositTime: assign((context, event) => {
257
+ return {
258
+ depositTime: event.data,
259
+ }
260
+ }),
261
+ setReceipt: assign((context, event) => {
262
+ return {
263
+ receipt: event.data,
264
+ }
265
+ }),
266
+ },
267
+ guards: {
268
+ isCalculable: (context, event) => {
269
+ return context.amount
270
+ },
271
+ isCalculated: (context, event) => {
272
+ return context.calculation
273
+ },
274
+ isSubmittable: (context, event) => {
275
+ const { amount, userAccountNumber, userAccountName, depositTime, receipt } = context
276
+ return amount && userAccountNumber && userAccountName && depositTime && receipt
277
+ },
278
+ isProcessing: (context, event) => {
279
+ return context.processing
280
+ },
281
+ },
282
+ services: {
283
+ fetchInitData: async (context, event) => {
284
+ const [paymentInfo, paymentDetails] = await Promise.all([
285
+ request.send(payment.getPaymentInfo()),
286
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
287
+ ])
288
+ return {
289
+ paymentInfo,
290
+ paymentDetails,
291
+ }
292
+ },
293
+ fetchBanksList: async (context, event) => {
294
+ const { method } = context
295
+ return await request.send(payment.getBankList(method))
296
+ },
297
+ fetchCalculation: async (context, event) => {
298
+ const { method, amount } = context
299
+ return await request.send(payment.getDepositExpectedResult({ method, amount }))
300
+ },
301
+ submitDeposit: async (context, event) => {
302
+ const { method, amount, selectedHouseBank, selectedUserBank, userAccountNumber, userAccountName, depositTime, receipt } = context
303
+ return await request.send(
304
+ payment.submitDepositTransactionBank({
305
+ method,
306
+ amount,
307
+ targetBankCode: selectedHouseBank.bankName,
308
+ targetAccountNumber: selectedHouseBank.accountNumber,
309
+ applyerBankCode: selectedUserBank.bankCode,
310
+ applyerAccountNumber: userAccountNumber,
311
+ applyerHolderName: userAccountName,
312
+ depositTime,
313
+ receipt,
314
+ })
315
+ )
316
+ },
317
+ },
318
+ }
319
+ )
320
+ }
@@ -0,0 +1,195 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment'
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
+ currentMethodType: '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
+ },
48
+ },
49
+ fail: {},
50
+ calculable: {
51
+ entry: 'clearCalculation',
52
+ on: {
53
+ SELECT_AMOUNT: {
54
+ actions: 'addAmount',
55
+ },
56
+ CALCULATE: {
57
+ target: 'calculating',
58
+ },
59
+ BACK: {
60
+ target: 'loaded',
61
+ },
62
+ },
63
+ },
64
+ calculating: {
65
+ invoke: {
66
+ src: 'fetchCalculation',
67
+ onDone: {
68
+ target: 'calculated',
69
+ actions: 'setCalculation',
70
+ },
71
+ onError: {
72
+ target: 'calculable',
73
+ },
74
+ },
75
+ },
76
+ calculated: {
77
+ on: {
78
+ SELECT_AMOUNT: {
79
+ target: 'calculable',
80
+ actions: 'addAmount',
81
+ },
82
+ CONFIRM: {
83
+ target: 'submitting',
84
+ },
85
+ BACK: {
86
+ target: 'loaded',
87
+ },
88
+ CLEAR_CALCULATION: {
89
+ target: 'calculable',
90
+ actions: 'clearCalculation',
91
+ },
92
+ },
93
+ },
94
+ submitting: {
95
+ invoke: {
96
+ src: 'submitDeposit',
97
+ onDone: {
98
+ target: 'submitted',
99
+ actions: 'setResult',
100
+ },
101
+ onError: {
102
+ target: 'calculated',
103
+ },
104
+ },
105
+ },
106
+ submitted: {
107
+ on: {
108
+ SELECT_QRCODE: {
109
+ target: 'loaded',
110
+ actions: 'setQrcode',
111
+ },
112
+ },
113
+ },
114
+ },
115
+ },
116
+ {
117
+ actions: {
118
+ reset: assign((context, event) => {
119
+ return {
120
+ selectedAmount: null,
121
+ calculation: null,
122
+ }
123
+ }),
124
+ setInitData: assign((context, event) => {
125
+ const paymentDetails = event.data
126
+ const qrcodes = paymentDetails.filter((element) => element.methodType === context.currentMethodType)
127
+
128
+ return {
129
+ paymentDetails,
130
+ qrcodes,
131
+ selectedQrcode: qrcodes[0],
132
+ currentMethod: qrcodes[0].method,
133
+ options: qrcodes[0].optional,
134
+ }
135
+ }),
136
+ setQrcode: assign((context, event) => {
137
+ return {
138
+ selectedQrcode: event.data,
139
+ currentMethod: event.data.method,
140
+ options: event.data.optional,
141
+ }
142
+ }),
143
+ addAmount: assign((context, event) => {
144
+ return { selectedAmount: (context.selectedAmount || 0) + event.data }
145
+ }),
146
+ setCalculation: assign((context, event) => {
147
+ return {
148
+ calculation: event.data,
149
+ }
150
+ }),
151
+ clearCalculation: assign((context, event) => {
152
+ return {
153
+ calculation: null,
154
+ }
155
+ }),
156
+ setResult: assign((context, event) => {
157
+ return {
158
+ result: event.data,
159
+ }
160
+ }),
161
+ },
162
+ guards: {
163
+ isSubmittable: (context, event) => {},
164
+ },
165
+ services: {
166
+ fetchInitData: async (context, event) => {
167
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
168
+ },
169
+ fetchBanksList: async (context, event) => {
170
+ const { paymentDetails, currentMethodType } = context
171
+ const method = paymentDetails.find((item) => item.methodType === currentMethodType)?.method
172
+ return await request.send(payment.getBankList(method))
173
+ },
174
+ fetchCalculation: async (context, event) => {
175
+ const { currentMethod, selectedAmount } = context
176
+ return await request.send(
177
+ payment.getDepositExpectedResult({
178
+ method: currentMethod,
179
+ amount: selectedAmount,
180
+ })
181
+ )
182
+ },
183
+ submitDeposit: async (context, event) => {
184
+ const { currentMethod, selectedAmount } = context
185
+ return await request.send(
186
+ payment.submitDepositTransactionQrcode({
187
+ method: currentMethod,
188
+ amount: selectedAmount,
189
+ })
190
+ )
191
+ },
192
+ },
193
+ }
194
+ )
195
+ }
@@ -3,7 +3,6 @@ import auth from './auth'
3
3
  import auth_otp from './auth_otp'
4
4
  import welcome from './welcome'
5
5
  import common from './common'
6
- import deposit from './deposit'
7
6
  import error from './error'
8
7
  import game from './game'
9
8
  import game_favorite from './game_favorite'
@@ -21,6 +20,8 @@ import user_sign_up from './user_sign_up'
21
20
  import user_reset_password from './user_reset_password'
22
21
  import bank_binding from './bank_binding'
23
22
  import withdraw_vn from './withdraw_vn'
23
+ import deposit from './deposit'
24
+ import bonus from './bonus'
24
25
 
25
26
  export default {
26
27
  ...activity,
@@ -46,4 +47,6 @@ export default {
46
47
  user_reset_password,
47
48
  bank_binding,
48
49
  withdraw_vn,
50
+ ...deposit,
51
+ bonus,
49
52
  }