@jetthai/cuora 1.1.272 → 1.1.273-withdraw-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/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.273-withdraw-1](https://github.com/jetthai/cuora-module/compare/v1.1.273...v1.1.273-withdraw-1) (2024-05-28)
6
+
7
+ ### [1.1.273](https://github.com/jetthai/cuora-module/compare/v1.1.272...v1.1.273) (2024-05-27)
8
+
5
9
  ### [1.1.272](https://github.com/jetthai/cuora-module/compare/v1.1.270...v1.1.272) (2024-05-21)
6
10
 
7
11
  ### [1.1.271](https://github.com/jetthai/cuora-module/compare/v1.1.270...v1.1.271) (2024-05-21)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.272",
3
+ "version": "1.1.273-withdraw-1",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -93,6 +93,11 @@ export default {
93
93
  method: 'post',
94
94
  params: { transferType: 'DEPOSIT', amount, cryptoCurrency, promotionsNo },
95
95
  }),
96
+ getCryptoWithdrawExpectedResult: ({ method, amount, cryptoCurrency, promotionsNo }) => ({
97
+ url: `payment/v2/${method}/crypto/expected/result`,
98
+ method: 'post',
99
+ params: { transferType: 'WITHDRAW', amount, cryptoCurrency, promotionsNo },
100
+ }),
96
101
  getWithdrawExpectedResult: ({ method, amount, cryptoNetwork }) => ({
97
102
  url: `payment/v2/${method}/expected/result`,
98
103
  method: 'post',
@@ -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',
@@ -155,18 +177,20 @@ export default function (request, context) {
155
177
  setInitData: assign((context, event) => {
156
178
  const { currentPayment, banks, paymentInfo, withdrawRule, processing } = event.data
157
179
 
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)
180
+ // const withdrawBanks = (paymentInfo?.bankInfo || [])
181
+ // .map((item) => {
182
+ // const matchedBank = banks.find((bank) => bank.bankCode === item.bankCode)
183
+ // return matchedBank ? { ...item, ...matchedBank } : null
184
+ // })
185
+ // .filter(Boolean)
186
+
187
+ // const userBanks = (paymentInfo.bankList || []).map((bank) => {
188
+ // bank.displayText = `${bank.bankCode} - ${bank.accountNumber}`
189
+ // bank.imageUrl = banks.find((item) => item.bankCode === bank.bankCode)?.imageUrl
190
+ // return bank
191
+ // })
164
192
 
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
- })
193
+ const userBanks = [...paymentInfo.bankList, ...paymentInfo.cryptoList, ...paymentInfo.ewalletList]
170
194
 
171
195
  return {
172
196
  currentPayment,
@@ -238,7 +262,8 @@ export default function (request, context) {
238
262
 
239
263
  const [banks, paymentInfo, withdrawRule, orders] = await Promise.all([
240
264
  request.send(payment.getWithdrawBankList()),
241
- request.send(payment.getPaymentInfo()),
265
+ // request.send(payment.getPaymentInfo()),
266
+ request.send(payment.getBindingPaymentInfo()),
242
267
  request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
243
268
  request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
244
269
  ])
@@ -265,6 +290,19 @@ export default function (request, context) {
265
290
  })
266
291
  )
267
292
  },
293
+ submitWithdrawCrypto: async (context, event) => {
294
+ const { currentPayment, selectedUserBank, selectedAmount } = context
295
+ const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(selectedUserBank.bankCode) ? '' : selectedUserBank.branch
296
+ return await request.send(
297
+ payment.submitWithdrawTransactionCrypto({
298
+ method: currentPayment.method,
299
+ amount: selectedAmount,
300
+ cryptoCurrency: selectedUserBank.cryptoCurrency,
301
+ cryptoNetwork: selectedUserBank.cryptoNetwork,
302
+ targetAddress: selectedUserBank.cryptoAddress,
303
+ })
304
+ )
305
+ },
268
306
  resetOtp: async (context, event) => {
269
307
  const { requestId, target } = context
270
308
  return await request.send(user.otpReset({ requestId, target }))