@jetthai/cuora 1.1.270-fix-3 → 1.1.270-fix-4

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,8 @@
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.270-fix-4](https://github.com/jetthai/cuora-module/compare/v1.1.270-fix-3...v1.1.270-fix-4) (2024-06-04)
6
+
5
7
  ### [1.1.270-fix-3](https://github.com/jetthai/cuora-module/compare/v1.1.270-fix-2...v1.1.270-fix-3) (2024-06-04)
6
8
 
7
9
  ### [1.1.270-fix-2](https://github.com/jetthai/cuora-module/compare/v1.1.270-fix-1...v1.1.270-fix-2) (2024-06-03)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.270-fix-3",
3
+ "version": "1.1.270-fix-4",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -11,7 +11,17 @@ export default function (request) {
11
11
  context: {
12
12
  hasAnyAccount: false,
13
13
  bankList: [],
14
+ paymentList: {
15
+ bankList: [],
16
+ cryptoList: [],
17
+ ewalletList: [],
18
+ },
19
+ bindingType: 'BANK',
14
20
  bank: null,
21
+ crypto: null,
22
+ network: null,
23
+ cryptoAddress: null,
24
+ walletCode: null,
15
25
  branch: null,
16
26
  branchCode: null,
17
27
  accountNumber: null,
@@ -33,6 +43,13 @@ export default function (request) {
33
43
  },
34
44
  idle: {
35
45
  on: {
46
+ SET_BIND_TYPE: {
47
+ actions: assign((context, event) => {
48
+ return {
49
+ bindingType: event.data,
50
+ }
51
+ }),
52
+ },
36
53
  SET_BANK_CODE: {
37
54
  actions: assign((context, event) => {
38
55
  return {
@@ -40,6 +57,34 @@ export default function (request) {
40
57
  }
41
58
  }),
42
59
  },
60
+ SET_CRYPTO_CODE: {
61
+ actions: assign((context, event) => {
62
+ return {
63
+ crypto: event.data,
64
+ }
65
+ }),
66
+ },
67
+ SET_NETWORK_CODE: {
68
+ actions: assign((context, event) => {
69
+ return {
70
+ network: event.data,
71
+ }
72
+ }),
73
+ },
74
+ SET_CRYPTO_ADDRESS: {
75
+ actions: assign((context, event) => {
76
+ return {
77
+ cryptoAddress: event.data,
78
+ }
79
+ }),
80
+ },
81
+ SET_WALLET_CODE: {
82
+ actions: assign((context, event) => {
83
+ return {
84
+ walletCode: event.data,
85
+ }
86
+ }),
87
+ },
43
88
  SET_BRANCH: {
44
89
  actions: assign((context, event) => {
45
90
  return {
@@ -98,11 +143,12 @@ export default function (request) {
98
143
  {
99
144
  actions: {
100
145
  setBanks: assign((context, event) => {
101
- const { bankList = [], paymentInfo = {} } = event.data
146
+ const { bankList = [], paymentList = {}, paymentInfo = {} } = event.data
102
147
  const { bankInfo = [] } = paymentInfo
103
148
  return {
104
149
  hasAnyAccount: bankInfo.length > 0,
105
150
  holderName: bankInfo[0]?.holderName,
151
+ paymentList,
106
152
  bankList,
107
153
  bank: null, // 不預選銀行,玩家可能不知道這裡可以選 by Gordan
108
154
  }
@@ -110,23 +156,39 @@ export default function (request) {
110
156
  },
111
157
  guards: {
112
158
  isBindable: (context, event) => {
159
+ const { bindingType } = context
160
+
161
+ if (bindingType === 'CRYPTO') {
162
+ const { crypto, network, cryptoAddress, holderName } = context
163
+ return crypto && network && cryptoAddress && holderName
164
+ }
165
+ if (bindingType === 'EWALLET') {
166
+ const { walletCode, accountNumber, holderName } = context
167
+ return walletCode?.bankCode && accountNumber && holderName
168
+ }
113
169
  const { bank, accountNumber, branch, holderName } = context
114
170
  return bank.bankCode && accountNumber && branch && holderName
115
171
  },
116
172
  },
117
173
  services: {
118
174
  fetchInitData: async (context, event) => {
119
- const [bankList, paymentInfo] = await Promise.all([
175
+ const [bankList, paymentList, paymentInfo] = await Promise.all([
120
176
  request.send(payment.getBindingBankList({ appSecret })),
177
+ request.send(payment.getBindingPaymentList({ appSecret })),
121
178
  request.send(payment.getPaymentInfo()),
122
179
  ])
123
- return { bankList, paymentInfo }
180
+ return { bankList, paymentList, paymentInfo }
124
181
  },
125
182
  updatePaymentInfo: async (context, event) => {
126
- const { bank, branch, branchCode, accountNumber, holderName, pixType } = context
183
+ const { bindingType, bank, crypto, network, cryptoAddress, walletCode, branch, branchCode, accountNumber, holderName, pixType } = context
127
184
  return await request.send(
128
185
  payment.updatePaymentInfo({
129
- bankCode: bank.bankCode,
186
+ bindingType,
187
+ bankCode: bank?.bankCode || '',
188
+ cryptoCurrency: crypto?.symbol || '',
189
+ cryptoNetwork: network?.label || '',
190
+ cryptoAddress: cryptoAddress,
191
+ walletCode: walletCode?.bankCode || '',
130
192
  branch: branch === 'BLANK' ? '' : branch, // 'BLANK'會置換成空值
131
193
  branchCode,
132
194
  bankAccount: accountNumber,