@jetthai/cuora 1.1.269 → 1.1.270-dev-5

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.
@@ -50,6 +50,9 @@ export default function (request, context) {
50
50
  SUBMIT: {
51
51
  target: 'submitting',
52
52
  },
53
+ SUBMIT_CRYPTO: {
54
+ target: 'submitting_crypto',
55
+ },
53
56
  },
54
57
  },
55
58
  submitting: {
@@ -71,6 +74,25 @@ export default function (request, context) {
71
74
  },
72
75
  },
73
76
  },
77
+ submitting_crypto: {
78
+ invoke: {
79
+ src: 'submitWithdrawCrypto',
80
+ onDone: [
81
+ {
82
+ target: 'otp',
83
+ actions: 'setOtp',
84
+ cond: 'isOtpRequired',
85
+ },
86
+ {
87
+ target: 'submitted',
88
+ actions: 'setProcessing',
89
+ },
90
+ ],
91
+ onError: {
92
+ target: 'calculated',
93
+ },
94
+ },
95
+ },
74
96
  submitted: {},
75
97
  otp: {
76
98
  type: 'parallel',
@@ -153,25 +175,12 @@ export default function (request, context) {
153
175
  {
154
176
  actions: {
155
177
  setInitData: assign((context, event) => {
156
- const { currentPayment, banks, paymentInfo, withdrawRule, processing } = event.data
157
-
158
- const withdrawBanks = (paymentInfo?.bankInfo || [])
159
- .map((item) => {
160
- const matchedBank = banks.find((bank) => bank.bankCode === item.bankCode)
161
- return matchedBank ? { ...item, ...matchedBank } : null
162
- })
163
- .filter(Boolean)
164
-
165
- const userBanks = (withdrawBanks || []).map((bank) => {
166
- bank.displayText = `${bank.bankCode} - ${bank.accountNumber}`
167
- bank.imageUrl = banks.find((item) => item.bankCode === bank.bankCode)?.imageUrl
168
- return bank
169
- })
178
+ const { currentPayment, paymentInfo, withdrawRule, processing } = event.data
179
+ const userBanks = [...paymentInfo.bankList, ...paymentInfo.cryptoList, ...paymentInfo.ewalletList]
170
180
 
171
181
  return {
172
182
  currentPayment,
173
183
  processing,
174
- banks,
175
184
  paymentInfo,
176
185
  withdrawRule,
177
186
  userBanks,
@@ -234,18 +243,17 @@ export default function (request, context) {
234
243
  },
235
244
  services: {
236
245
  fetchInitData: async (context, event) => {
237
- const currentPayment = context.paymentDetail.find((element) => element.category === 'manual' && element.transferType === 'withdraw')
246
+ const { paymentDetail = [] } = context
247
+ const currentPayment = paymentDetail.find((element) => element.category === 'manual' && element.transferType === 'withdraw')
238
248
 
239
- const [banks, paymentInfo, withdrawRule, orders] = await Promise.all([
240
- request.send(payment.getWithdrawBankList()),
241
- request.send(payment.getPaymentInfo()),
249
+ const [paymentInfo, withdrawRule, orders] = await Promise.all([
250
+ request.send(payment.getBindingPaymentInfo()),
242
251
  request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
243
252
  request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
244
253
  ])
245
254
 
246
255
  return {
247
256
  currentPayment,
248
- banks,
249
257
  paymentInfo,
250
258
  withdrawRule,
251
259
  processing: orders[0],
@@ -260,8 +268,23 @@ export default function (request, context) {
260
268
  amount: selectedAmount,
261
269
  applyerBankCode: selectedUserBank.bankCode,
262
270
  applyerAccountNumber: selectedUserBank.accountNumber,
271
+ applyerIfscCode: selectedUserBank.ifscCode,
263
272
  branch: branchTemp,
264
- holderName: selectedUserBank.holderName,
273
+ applyerHolderName: selectedUserBank.holderName,
274
+ })
275
+ )
276
+ },
277
+ submitWithdrawCrypto: async (context, event) => {
278
+ const { currentPayment, selectedUserBank, selectedAmount } = context
279
+ const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(selectedUserBank.bankCode) ? '' : selectedUserBank.branch
280
+ return await request.send(
281
+ payment.submitWithdrawTransactionCrypto({
282
+ method: currentPayment.method,
283
+ amount: selectedAmount,
284
+ cryptoCurrency: selectedUserBank.cryptoCurrency,
285
+ cryptoNetwork: selectedUserBank.cryptoNetwork,
286
+ targetAddress: selectedUserBank.cryptoAddress,
287
+ applyerHolderName: selectedUserBank.holderName,
265
288
  })
266
289
  )
267
290
  },