@blocklet/payment-react 1.26.1 → 1.26.3
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/checkout-v2/components/dialogs/checkout-dialogs.js +2 -0
- package/es/checkout-v2/components/left/cross-sell-card.js +3 -3
- package/es/checkout-v2/components/left/product-item-card.js +9 -3
- package/es/checkout-v2/components/left/promotion-input.d.ts +4 -1
- package/es/checkout-v2/components/left/promotion-input.js +8 -13
- package/es/checkout-v2/components/right/customer-info-card.d.ts +2 -0
- package/es/checkout-v2/components/right/customer-info-card.js +22 -14
- package/es/checkout-v2/components/right/status-feedback.js +1 -1
- package/es/checkout-v2/components/right/submit-button.js +3 -1
- package/es/checkout-v2/layouts/checkout-layout.js +13 -3
- package/es/checkout-v2/panels/left/composite-panel.js +27 -6
- package/es/checkout-v2/panels/right/payment-panel.js +40 -9
- package/es/checkout-v2/utils/format.d.ts +1 -1
- package/es/checkout-v2/utils/format.js +1 -0
- package/es/checkout-v2/views/error-view.d.ts +1 -1
- package/es/checkout-v2/views/error-view.js +9 -0
- package/es/checkout-v2/views/success-view.js +3 -1
- package/es/components/over-due-invoice-payment.js +5 -3
- package/es/components/service-suspended-dialog.d.ts +4 -0
- package/es/components/service-suspended-dialog.js +61 -0
- package/es/libs/util.d.ts +8 -0
- package/es/libs/util.js +3 -0
- package/es/locales/en.js +4 -0
- package/es/locales/zh.js +4 -0
- package/es/payment/form/index.js +17 -0
- package/es/payment/index.js +15 -4
- package/lib/checkout-v2/components/dialogs/checkout-dialogs.js +4 -0
- package/lib/checkout-v2/components/left/cross-sell-card.js +2 -2
- package/lib/checkout-v2/components/left/product-item-card.js +9 -2
- package/lib/checkout-v2/components/left/promotion-input.d.ts +4 -1
- package/lib/checkout-v2/components/left/promotion-input.js +12 -19
- package/lib/checkout-v2/components/right/customer-info-card.d.ts +2 -0
- package/lib/checkout-v2/components/right/customer-info-card.js +19 -13
- package/lib/checkout-v2/components/right/status-feedback.js +1 -1
- package/lib/checkout-v2/components/right/submit-button.js +3 -1
- package/lib/checkout-v2/layouts/checkout-layout.js +28 -5
- package/lib/checkout-v2/panels/left/composite-panel.js +20 -5
- package/lib/checkout-v2/panels/right/payment-panel.js +46 -7
- package/lib/checkout-v2/utils/format.d.ts +1 -1
- package/lib/checkout-v2/utils/format.js +7 -0
- package/lib/checkout-v2/views/error-view.d.ts +1 -1
- package/lib/checkout-v2/views/error-view.js +9 -0
- package/lib/checkout-v2/views/success-view.js +2 -0
- package/lib/components/over-due-invoice-payment.js +12 -2
- package/lib/components/service-suspended-dialog.d.ts +4 -0
- package/lib/components/service-suspended-dialog.js +97 -0
- package/lib/libs/util.d.ts +8 -0
- package/lib/libs/util.js +4 -0
- package/lib/locales/en.js +4 -0
- package/lib/locales/zh.js +4 -0
- package/lib/payment/form/index.js +23 -0
- package/lib/payment/index.js +15 -4
- package/package.json +4 -4
- package/src/checkout-v2/components/dialogs/checkout-dialogs.tsx +4 -0
- package/src/checkout-v2/components/left/cross-sell-card.tsx +3 -3
- package/src/checkout-v2/components/left/product-item-card.tsx +18 -8
- package/src/checkout-v2/components/left/promotion-input.tsx +17 -17
- package/src/checkout-v2/components/right/customer-info-card.tsx +29 -16
- package/src/checkout-v2/components/right/status-feedback.tsx +2 -2
- package/src/checkout-v2/components/right/submit-button.tsx +2 -0
- package/src/checkout-v2/layouts/checkout-layout.tsx +25 -10
- package/src/checkout-v2/panels/left/composite-panel.tsx +28 -6
- package/src/checkout-v2/panels/right/payment-panel.tsx +32 -5
- package/src/checkout-v2/utils/format.ts +2 -0
- package/src/checkout-v2/views/error-view.tsx +11 -1
- package/src/checkout-v2/views/success-view.tsx +3 -1
- package/src/components/over-due-invoice-payment.tsx +6 -3
- package/src/components/service-suspended-dialog.tsx +64 -0
- package/src/libs/util.ts +7 -0
- package/src/locales/en.tsx +4 -0
- package/src/locales/zh.tsx +4 -0
- package/src/payment/form/index.tsx +20 -0
- package/src/payment/index.tsx +26 -4
package/src/payment/index.tsx
CHANGED
|
@@ -125,6 +125,19 @@ function PaymentInner({
|
|
|
125
125
|
}, [paymentMethods]);
|
|
126
126
|
|
|
127
127
|
const defaultCurrencyId = useMemo(() => {
|
|
128
|
+
// Keep session currency stable when a promotion is already applied.
|
|
129
|
+
// Otherwise auto-picking from URL/local preference/no-wallet may switch currency
|
|
130
|
+
// on refresh and trigger a second recalculate-promotion that removes discount
|
|
131
|
+
// with `currency_incompatible`.
|
|
132
|
+
const hasAppliedDiscount = Boolean((state.checkoutSession as any)?.discounts?.length);
|
|
133
|
+
if (
|
|
134
|
+
hasAppliedDiscount &&
|
|
135
|
+
state.checkoutSession.currency_id &&
|
|
136
|
+
availableCurrencyIds.includes(state.checkoutSession.currency_id)
|
|
137
|
+
) {
|
|
138
|
+
return state.checkoutSession.currency_id;
|
|
139
|
+
}
|
|
140
|
+
|
|
128
141
|
// 1. first check url currencyId
|
|
129
142
|
if (query.currencyId && availableCurrencyIds.includes(query.currencyId)) {
|
|
130
143
|
return query.currencyId;
|
|
@@ -151,7 +164,7 @@ function PaymentInner({
|
|
|
151
164
|
return state.checkoutSession.currency_id;
|
|
152
165
|
}
|
|
153
166
|
return availableCurrencyIds?.[0];
|
|
154
|
-
}, [query.currencyId, availableCurrencyIds, session?.user, state.checkoutSession
|
|
167
|
+
}, [query.currencyId, availableCurrencyIds, session?.user, state.checkoutSession, paymentMethods]);
|
|
155
168
|
|
|
156
169
|
const defaultMethodId = paymentMethods.find((m) => m.payment_currencies.some((c) => c.id === defaultCurrencyId))?.id;
|
|
157
170
|
const hideSummaryCard = mode.endsWith('-minimal') || !showCheckoutSummary;
|
|
@@ -183,14 +196,23 @@ function PaymentInner({
|
|
|
183
196
|
});
|
|
184
197
|
|
|
185
198
|
useEffect(() => {
|
|
199
|
+
const hasAppliedDiscount = Boolean((state.checkoutSession as any)?.discounts?.length);
|
|
200
|
+
const currentCurrency = methods.getValues('payment_currency');
|
|
201
|
+
const currentMethod = methods.getValues('payment_method');
|
|
202
|
+
|
|
186
203
|
if (defaultCurrencyId) {
|
|
187
|
-
|
|
204
|
+
// Avoid overriding current currency on refresh when a promotion is already applied.
|
|
205
|
+
if (!hasAppliedDiscount || !currentCurrency) {
|
|
206
|
+
methods.setValue('payment_currency', defaultCurrencyId);
|
|
207
|
+
}
|
|
188
208
|
}
|
|
189
209
|
if (defaultMethodId) {
|
|
190
|
-
|
|
210
|
+
if (!hasAppliedDiscount || !currentMethod) {
|
|
211
|
+
methods.setValue('payment_method', defaultMethodId);
|
|
212
|
+
}
|
|
191
213
|
}
|
|
192
214
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
193
|
-
}, [defaultCurrencyId, defaultMethodId]);
|
|
215
|
+
}, [defaultCurrencyId, defaultMethodId, state.checkoutSession.discounts]);
|
|
194
216
|
|
|
195
217
|
useEffect(() => {
|
|
196
218
|
if (!isMobileSafari()) {
|