@blocklet/payment-react 1.18.23 → 1.18.24
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/es/payment/form/index.js
CHANGED
|
@@ -183,7 +183,7 @@ export default function PaymentForm({
|
|
|
183
183
|
const values = getValues();
|
|
184
184
|
let userInfo = session.user;
|
|
185
185
|
try {
|
|
186
|
-
const { data: customerInfo } = await api.get(
|
|
186
|
+
const { data: customerInfo } = await api.get("/api/customers/me?skipSummary=1&fallback=1");
|
|
187
187
|
userInfo = mergeUserInfo(customerInfo, userInfo);
|
|
188
188
|
} catch (err) {
|
|
189
189
|
userInfo = mergeUserInfo(customer || {}, userInfo);
|
|
@@ -52,12 +52,6 @@ export default function ProductDonation({
|
|
|
52
52
|
const middleIndex = Math.floor(presets.length / 2);
|
|
53
53
|
return presets[middleIndex];
|
|
54
54
|
}
|
|
55
|
-
if (settings?.amount?.preset) {
|
|
56
|
-
return formatAmount(settings.amount.preset);
|
|
57
|
-
}
|
|
58
|
-
if (presets.length > 0) {
|
|
59
|
-
return presets[0];
|
|
60
|
-
}
|
|
61
55
|
return "0";
|
|
62
56
|
};
|
|
63
57
|
const supportPreset = presets.length > 0;
|
|
@@ -106,26 +100,24 @@ export default function ProductDonation({
|
|
|
106
100
|
containerRef
|
|
107
101
|
});
|
|
108
102
|
useEffect(() => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
setPayable(false);
|
|
126
|
-
}
|
|
103
|
+
const currentPreset = getDefaultPreset();
|
|
104
|
+
const isCustom = currentPreset === "custom";
|
|
105
|
+
setState({
|
|
106
|
+
selected: isCustom ? "" : currentPreset,
|
|
107
|
+
custom: !supportPreset || currentPreset === "custom",
|
|
108
|
+
input: defaultCustomAmount,
|
|
109
|
+
error: ""
|
|
110
|
+
});
|
|
111
|
+
if (!isCustom) {
|
|
112
|
+
onChange({ priceId: item.price_id, amount: currentPreset });
|
|
113
|
+
setPayable(true);
|
|
114
|
+
} else if (defaultCustomAmount) {
|
|
115
|
+
onChange({ priceId: item.price_id, amount: defaultCustomAmount });
|
|
116
|
+
setPayable(true);
|
|
117
|
+
} else {
|
|
118
|
+
setPayable(false);
|
|
127
119
|
}
|
|
128
|
-
}, [settings.amount.preset, settings.amount.presets]);
|
|
120
|
+
}, [settings.amount.preset, settings.amount.presets, supportPreset]);
|
|
129
121
|
useEffect(() => {
|
|
130
122
|
if (containerRef.current) {
|
|
131
123
|
containerRef.current.focus();
|
|
@@ -209,7 +209,7 @@ function PaymentForm({
|
|
|
209
209
|
try {
|
|
210
210
|
const {
|
|
211
211
|
data: customerInfo
|
|
212
|
-
} = await _api.default.get(
|
|
212
|
+
} = await _api.default.get("/api/customers/me?skipSummary=1&fallback=1");
|
|
213
213
|
userInfo = mergeUserInfo(customerInfo, userInfo);
|
|
214
214
|
} catch (err) {
|
|
215
215
|
userInfo = mergeUserInfo(customer || {}, userInfo);
|
|
@@ -64,12 +64,6 @@ function ProductDonation({
|
|
|
64
64
|
const middleIndex = Math.floor(presets.length / 2);
|
|
65
65
|
return presets[middleIndex];
|
|
66
66
|
}
|
|
67
|
-
if (settings?.amount?.preset) {
|
|
68
|
-
return formatAmount(settings.amount.preset);
|
|
69
|
-
}
|
|
70
|
-
if (presets.length > 0) {
|
|
71
|
-
return presets[0];
|
|
72
|
-
}
|
|
73
67
|
return "0";
|
|
74
68
|
};
|
|
75
69
|
const supportPreset = presets.length > 0;
|
|
@@ -136,38 +130,30 @@ function ProductDonation({
|
|
|
136
130
|
containerRef
|
|
137
131
|
});
|
|
138
132
|
(0, _react.useEffect)(() => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
const currentPreset = getDefaultPreset();
|
|
134
|
+
const isCustom = currentPreset === "custom";
|
|
135
|
+
setState({
|
|
136
|
+
selected: isCustom ? "" : currentPreset,
|
|
137
|
+
custom: !supportPreset || currentPreset === "custom",
|
|
138
|
+
input: defaultCustomAmount,
|
|
139
|
+
error: ""
|
|
140
|
+
});
|
|
141
|
+
if (!isCustom) {
|
|
144
142
|
onChange({
|
|
145
143
|
priceId: item.price_id,
|
|
146
|
-
amount:
|
|
144
|
+
amount: currentPreset
|
|
147
145
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
input: isCustom ? getSavedCustomAmount() : ""
|
|
146
|
+
setPayable(true);
|
|
147
|
+
} else if (defaultCustomAmount) {
|
|
148
|
+
onChange({
|
|
149
|
+
priceId: item.price_id,
|
|
150
|
+
amount: defaultCustomAmount
|
|
154
151
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
amount: defaultPreset
|
|
159
|
-
});
|
|
160
|
-
} else if (defaultCustomAmount) {
|
|
161
|
-
onChange({
|
|
162
|
-
priceId: item.price_id,
|
|
163
|
-
amount: defaultCustomAmount
|
|
164
|
-
});
|
|
165
|
-
setPayable(true);
|
|
166
|
-
} else {
|
|
167
|
-
setPayable(false);
|
|
168
|
-
}
|
|
152
|
+
setPayable(true);
|
|
153
|
+
} else {
|
|
154
|
+
setPayable(false);
|
|
169
155
|
}
|
|
170
|
-
}, [settings.amount.preset, settings.amount.presets]);
|
|
156
|
+
}, [settings.amount.preset, settings.amount.presets, supportPreset]);
|
|
171
157
|
(0, _react.useEffect)(() => {
|
|
172
158
|
if (containerRef.current) {
|
|
173
159
|
containerRef.current.focus();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.24",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/did-connect": "^2.12.
|
|
58
|
-
"@arcblock/ux": "^2.12.
|
|
57
|
+
"@arcblock/did-connect": "^2.12.48",
|
|
58
|
+
"@arcblock/ux": "^2.12.48",
|
|
59
59
|
"@arcblock/ws": "^1.19.15",
|
|
60
|
-
"@blocklet/ui-react": "^2.12.
|
|
60
|
+
"@blocklet/ui-react": "^2.12.48",
|
|
61
61
|
"@mui/icons-material": "^5.16.6",
|
|
62
62
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
63
63
|
"@mui/material": "^5.16.6",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@babel/core": "^7.25.2",
|
|
94
94
|
"@babel/preset-env": "^7.25.2",
|
|
95
95
|
"@babel/preset-react": "^7.24.7",
|
|
96
|
-
"@blocklet/payment-types": "1.18.
|
|
96
|
+
"@blocklet/payment-types": "1.18.24",
|
|
97
97
|
"@storybook/addon-essentials": "^7.6.20",
|
|
98
98
|
"@storybook/addon-interactions": "^7.6.20",
|
|
99
99
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"vite-plugin-babel": "^1.2.0",
|
|
125
125
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "6c36b088743e696ce250cda11f8502b3886df0ef"
|
|
128
128
|
}
|
|
@@ -272,7 +272,7 @@ export default function PaymentForm({
|
|
|
272
272
|
const values = getValues();
|
|
273
273
|
let userInfo = session.user;
|
|
274
274
|
try {
|
|
275
|
-
const { data: customerInfo } = await api.get(
|
|
275
|
+
const { data: customerInfo } = await api.get('/api/customers/me?skipSummary=1&fallback=1');
|
|
276
276
|
userInfo = mergeUserInfo(customerInfo, userInfo);
|
|
277
277
|
} catch (err) {
|
|
278
278
|
// @ts-ignore
|
|
@@ -65,12 +65,6 @@ export default function ProductDonation({
|
|
|
65
65
|
const middleIndex = Math.floor(presets.length / 2);
|
|
66
66
|
return presets[middleIndex];
|
|
67
67
|
}
|
|
68
|
-
if (settings?.amount?.preset) {
|
|
69
|
-
return formatAmount(settings.amount.preset);
|
|
70
|
-
}
|
|
71
|
-
if (presets.length > 0) {
|
|
72
|
-
return presets[0];
|
|
73
|
-
}
|
|
74
68
|
return '0';
|
|
75
69
|
};
|
|
76
70
|
|
|
@@ -128,27 +122,26 @@ export default function ProductDonation({
|
|
|
128
122
|
});
|
|
129
123
|
|
|
130
124
|
useEffect(() => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
onChange({ priceId: item.price_id, amount: settings.amount.preset });
|
|
134
|
-
} else if (settings.amount.presets && settings.amount.presets.length > 0) {
|
|
135
|
-
const isCustom = defaultPreset === 'custom';
|
|
136
|
-
setState({
|
|
137
|
-
selected: isCustom ? '' : defaultPreset,
|
|
138
|
-
custom: isCustom,
|
|
139
|
-
input: isCustom ? getSavedCustomAmount() : '',
|
|
140
|
-
});
|
|
125
|
+
const currentPreset = getDefaultPreset();
|
|
126
|
+
const isCustom = currentPreset === 'custom';
|
|
141
127
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
128
|
+
setState({
|
|
129
|
+
selected: isCustom ? '' : currentPreset,
|
|
130
|
+
custom: !supportPreset || currentPreset === 'custom',
|
|
131
|
+
input: defaultCustomAmount,
|
|
132
|
+
error: '',
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!isCustom) {
|
|
136
|
+
onChange({ priceId: item.price_id, amount: currentPreset });
|
|
137
|
+
setPayable(true);
|
|
138
|
+
} else if (defaultCustomAmount) {
|
|
139
|
+
onChange({ priceId: item.price_id, amount: defaultCustomAmount });
|
|
140
|
+
setPayable(true);
|
|
141
|
+
} else {
|
|
142
|
+
setPayable(false);
|
|
150
143
|
}
|
|
151
|
-
}, [settings.amount.preset, settings.amount.presets]); // eslint-disable-line
|
|
144
|
+
}, [settings.amount.preset, settings.amount.presets, supportPreset]); // eslint-disable-line
|
|
152
145
|
|
|
153
146
|
useEffect(() => {
|
|
154
147
|
if (containerRef.current) {
|