@blocklet/payment-react 1.24.4 → 1.25.0
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/components/auto-topup/modal.d.ts +2 -0
- package/es/components/auto-topup/modal.js +48 -6
- package/es/components/auto-topup/product-card.d.ts +16 -1
- package/es/components/auto-topup/product-card.js +97 -15
- package/es/components/dynamic-pricing-unavailable.d.ts +9 -0
- package/es/components/dynamic-pricing-unavailable.js +58 -0
- package/es/components/loading-amount.d.ts +17 -0
- package/es/components/loading-amount.js +46 -0
- package/es/components/price-change-confirm.d.ts +18 -0
- package/es/components/price-change-confirm.js +107 -0
- package/es/components/quote-details-panel.d.ts +21 -0
- package/es/components/quote-details-panel.js +170 -0
- package/es/components/quote-lock-banner.d.ts +7 -0
- package/es/components/quote-lock-banner.js +79 -0
- package/es/components/slippage-config.d.ts +20 -0
- package/es/components/slippage-config.js +261 -0
- package/es/history/invoice/list.js +125 -15
- package/es/hooks/dynamic-pricing.d.ts +102 -0
- package/es/hooks/dynamic-pricing.js +393 -0
- package/es/index.d.ts +6 -1
- package/es/index.js +9 -1
- package/es/libs/util.d.ts +42 -5
- package/es/libs/util.js +345 -57
- package/es/locales/en.js +114 -3
- package/es/locales/zh.js +114 -3
- package/es/payment/form/index.d.ts +4 -1
- package/es/payment/form/index.js +454 -22
- package/es/payment/index.d.ts +1 -1
- package/es/payment/index.js +279 -16
- package/es/payment/product-item.d.ts +26 -1
- package/es/payment/product-item.js +330 -51
- package/es/payment/summary-section/promotion-section.d.ts +32 -0
- package/es/payment/summary-section/promotion-section.js +143 -0
- package/es/payment/summary-section/total-section.d.ts +39 -0
- package/es/payment/summary-section/total-section.js +83 -0
- package/es/payment/summary.d.ts +17 -2
- package/es/payment/summary.js +300 -253
- package/es/types/index.d.ts +11 -0
- package/lib/components/auto-topup/modal.d.ts +2 -0
- package/lib/components/auto-topup/modal.js +54 -6
- package/lib/components/auto-topup/product-card.d.ts +16 -1
- package/lib/components/auto-topup/product-card.js +75 -7
- package/lib/components/dynamic-pricing-unavailable.d.ts +9 -0
- package/lib/components/dynamic-pricing-unavailable.js +81 -0
- package/lib/components/loading-amount.d.ts +17 -0
- package/lib/components/loading-amount.js +53 -0
- package/lib/components/price-change-confirm.d.ts +18 -0
- package/lib/components/price-change-confirm.js +157 -0
- package/lib/components/quote-details-panel.d.ts +21 -0
- package/lib/components/quote-details-panel.js +226 -0
- package/lib/components/quote-lock-banner.d.ts +7 -0
- package/lib/components/quote-lock-banner.js +93 -0
- package/lib/components/slippage-config.d.ts +20 -0
- package/lib/components/slippage-config.js +316 -0
- package/lib/history/invoice/list.js +167 -27
- package/lib/hooks/dynamic-pricing.d.ts +102 -0
- package/lib/hooks/dynamic-pricing.js +390 -0
- package/lib/index.d.ts +6 -1
- package/lib/index.js +32 -0
- package/lib/libs/util.d.ts +42 -5
- package/lib/libs/util.js +367 -49
- package/lib/locales/en.js +114 -3
- package/lib/locales/zh.js +114 -3
- package/lib/payment/form/index.d.ts +4 -1
- package/lib/payment/form/index.js +476 -20
- package/lib/payment/index.d.ts +1 -1
- package/lib/payment/index.js +308 -14
- package/lib/payment/product-item.d.ts +26 -1
- package/lib/payment/product-item.js +270 -35
- package/lib/payment/summary-section/promotion-section.d.ts +32 -0
- package/lib/payment/summary-section/promotion-section.js +133 -0
- package/lib/payment/summary-section/total-section.d.ts +39 -0
- package/lib/payment/summary-section/total-section.js +117 -0
- package/lib/payment/summary.d.ts +17 -2
- package/lib/payment/summary.js +205 -127
- package/lib/types/index.d.ts +11 -0
- package/package.json +3 -3
- package/src/components/auto-topup/modal.tsx +59 -6
- package/src/components/auto-topup/product-card.tsx +118 -11
- package/src/components/dynamic-pricing-unavailable.tsx +69 -0
- package/src/components/loading-amount.tsx +66 -0
- package/src/components/price-change-confirm.tsx +136 -0
- package/src/components/quote-details-panel.tsx +218 -0
- package/src/components/quote-lock-banner.tsx +99 -0
- package/src/components/slippage-config.tsx +336 -0
- package/src/history/invoice/list.tsx +143 -9
- package/src/hooks/dynamic-pricing.ts +617 -0
- package/src/index.ts +9 -0
- package/src/libs/util.ts +473 -58
- package/src/locales/en.tsx +117 -0
- package/src/locales/zh.tsx +111 -0
- package/src/payment/form/index.tsx +561 -19
- package/src/payment/index.tsx +349 -10
- package/src/payment/product-item.tsx +451 -37
- package/src/payment/summary-section/promotion-section.tsx +172 -0
- package/src/payment/summary-section/total-section.tsx +141 -0
- package/src/payment/summary.tsx +334 -192
- package/src/types/index.ts +15 -0
|
@@ -14,12 +14,13 @@ var _ahooks = require("ahooks");
|
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
var _reactRouterDom = require("react-router-dom");
|
|
16
16
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
17
|
+
var _util = require("@ocap/util");
|
|
17
18
|
var _status = _interopRequireDefault(require("../../components/status"));
|
|
18
19
|
var _payment = require("../../contexts/payment");
|
|
19
20
|
var _subscription = require("../../hooks/subscription");
|
|
20
21
|
var _api = _interopRequireDefault(require("../../libs/api"));
|
|
21
22
|
var _stripePaymentAction = _interopRequireDefault(require("../../components/stripe-payment-action"));
|
|
22
|
-
var
|
|
23
|
+
var _util2 = require("../../libs/util");
|
|
23
24
|
var _table = _interopRequireDefault(require("../../components/table"));
|
|
24
25
|
var _navigation = require("../../libs/navigation");
|
|
25
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -38,13 +39,27 @@ const groupByDate = items => {
|
|
|
38
39
|
};
|
|
39
40
|
const fetchData = (params = {}) => {
|
|
40
41
|
const search = new URLSearchParams();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const mergedParams = {
|
|
43
|
+
include_quote: true,
|
|
44
|
+
...params
|
|
45
|
+
};
|
|
46
|
+
Object.keys(mergedParams).forEach(key => {
|
|
47
|
+
if (mergedParams[key]) {
|
|
48
|
+
search.set(key, String(mergedParams[key]));
|
|
44
49
|
}
|
|
45
50
|
});
|
|
46
51
|
return _api.default.get(`/api/invoices?${search.toString()}`).then(res => res.data);
|
|
47
52
|
};
|
|
53
|
+
const getInvoiceQuoteInfo = invoice => {
|
|
54
|
+
const lines = invoice.lines || [];
|
|
55
|
+
for (const line of lines) {
|
|
56
|
+
const quote = line.metadata?.quote;
|
|
57
|
+
if (quote?.exchange_rate) {
|
|
58
|
+
return quote;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
};
|
|
48
63
|
const getInvoiceLink = (invoice, action) => {
|
|
49
64
|
if (invoice.id.startsWith("in_")) {
|
|
50
65
|
const path = `/customer/invoice/${invoice.id}${invoice.status === "uncollectible" && action ? `?action=${action}` : ""}`;
|
|
@@ -55,7 +70,7 @@ const getInvoiceLink = (invoice, action) => {
|
|
|
55
70
|
}
|
|
56
71
|
return {
|
|
57
72
|
connect: false,
|
|
58
|
-
link: (0, _navigation.createLink)((0,
|
|
73
|
+
link: (0, _navigation.createLink)((0, _util2.getTxLink)(invoice.paymentMethod, invoice.metadata?.payment_details).link, true)
|
|
59
74
|
};
|
|
60
75
|
};
|
|
61
76
|
const linkStyle = {
|
|
@@ -160,14 +175,129 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
160
175
|
customBodyRenderLite: (_, index) => {
|
|
161
176
|
const invoice = data?.list[index];
|
|
162
177
|
const isVoid = invoice.status === "void";
|
|
178
|
+
const quoteInfo = getInvoiceQuoteInfo(invoice);
|
|
179
|
+
const providers = quoteInfo?.providers || [];
|
|
180
|
+
const providerNames = providers.map(provider => provider.provider_name).filter(Boolean);
|
|
181
|
+
const providerDisplay = providerNames.length > 0 ? providerNames.join(", ") : quoteInfo?.rate_provider_name || quoteInfo?.rate_provider_id || "\u2014";
|
|
182
|
+
const providerRates = quoteInfo?.providers?.map(provider => {
|
|
183
|
+
const name = provider.provider_name || provider.provider_id || "\u2014";
|
|
184
|
+
return provider.rate ? `${name}` : name;
|
|
185
|
+
}).filter(Boolean) || [];
|
|
186
|
+
const rateTimestamp = quoteInfo?.rate_timestamp_ms ? (0, _util2.formatTime)(quoteInfo.rate_timestamp_ms) : "\u2014";
|
|
187
|
+
const formattedRate = (0, _util2.formatExchangeRate)(quoteInfo?.exchange_rate || null);
|
|
188
|
+
const rateLine = formattedRate ? (() => {
|
|
189
|
+
const currencyMap = {
|
|
190
|
+
USD: "$",
|
|
191
|
+
CNY: "\xA5"
|
|
192
|
+
};
|
|
193
|
+
const currencySymbol = currencyMap[quoteInfo?.base_currency];
|
|
194
|
+
return `1 ${invoice.paymentCurrency.symbol} \u2248 ${currencySymbol ? `${currencySymbol}${formattedRate}` : `${formattedRate} ${quoteInfo?.base_currency || "USD"}`}`;
|
|
195
|
+
})() : null;
|
|
196
|
+
let usdAmount = null;
|
|
197
|
+
if (quoteInfo?.base_amount) {
|
|
198
|
+
usdAmount = (0, _util2.formatUsdAmount)(quoteInfo.base_amount, locale);
|
|
199
|
+
} else if (quoteInfo?.exchange_rate && invoice.total) {
|
|
200
|
+
const calculatedUsd = (0, _util2.getUsdAmountFromTokenUnits)(new _util.BN(invoice.total), invoice.paymentCurrency.decimal, quoteInfo.exchange_rate);
|
|
201
|
+
if (calculatedUsd) {
|
|
202
|
+
usdAmount = (0, _util2.formatUsdAmount)(calculatedUsd, locale);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const tooltipContent = quoteInfo ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
206
|
+
spacing: 0.5,
|
|
207
|
+
sx: {
|
|
208
|
+
p: 1
|
|
209
|
+
},
|
|
210
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
211
|
+
direction: "row",
|
|
212
|
+
justifyContent: "space-between",
|
|
213
|
+
spacing: 2,
|
|
214
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
215
|
+
variant: "caption",
|
|
216
|
+
sx: {
|
|
217
|
+
color: "text.secondary"
|
|
218
|
+
},
|
|
219
|
+
children: [t("payment.customer.invoice.quote.providers"), ":"]
|
|
220
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
221
|
+
variant: "caption",
|
|
222
|
+
sx: {
|
|
223
|
+
color: "text.primary"
|
|
224
|
+
},
|
|
225
|
+
children: (providerRates.length > 0 ? providerRates.join(", ") : providerDisplay) || "\u2014"
|
|
226
|
+
})]
|
|
227
|
+
}), rateLine && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
228
|
+
direction: "row",
|
|
229
|
+
justifyContent: "space-between",
|
|
230
|
+
spacing: 2,
|
|
231
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
232
|
+
variant: "caption",
|
|
233
|
+
sx: {
|
|
234
|
+
color: "text.secondary"
|
|
235
|
+
},
|
|
236
|
+
children: [t("payment.customer.invoice.quote.exchangeRate"), ":"]
|
|
237
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
238
|
+
variant: "caption",
|
|
239
|
+
sx: {
|
|
240
|
+
color: "text.primary"
|
|
241
|
+
},
|
|
242
|
+
children: rateLine
|
|
243
|
+
})]
|
|
244
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
245
|
+
direction: "row",
|
|
246
|
+
justifyContent: "space-between",
|
|
247
|
+
spacing: 2,
|
|
248
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
249
|
+
variant: "caption",
|
|
250
|
+
sx: {
|
|
251
|
+
color: "text.secondary"
|
|
252
|
+
},
|
|
253
|
+
children: [t("payment.customer.invoice.quote.rateTimestamp"), ":"]
|
|
254
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
255
|
+
variant: "caption",
|
|
256
|
+
sx: {
|
|
257
|
+
color: "text.primary"
|
|
258
|
+
},
|
|
259
|
+
children: rateTimestamp
|
|
260
|
+
})]
|
|
261
|
+
})]
|
|
262
|
+
}) : null;
|
|
163
263
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
164
264
|
onClick: e => handleLinkClick(e, invoice),
|
|
165
265
|
sx: linkStyle,
|
|
166
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
266
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
267
|
+
spacing: 0.25,
|
|
268
|
+
alignItems: "flex-end",
|
|
269
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
270
|
+
sx: isVoid ? {
|
|
271
|
+
textDecoration: "line-through"
|
|
272
|
+
} : {},
|
|
273
|
+
children: [(0, _util2.formatAmount)(invoice.total, invoice.paymentCurrency.decimal), "\xA0", invoice.paymentCurrency.symbol]
|
|
274
|
+
}), (usdAmount || rateLine) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
275
|
+
title: tooltipContent,
|
|
276
|
+
placement: "top",
|
|
277
|
+
arrow: true,
|
|
278
|
+
slotProps: {
|
|
279
|
+
tooltip: {
|
|
280
|
+
sx: {
|
|
281
|
+
backgroundColor: "background.paper",
|
|
282
|
+
boxShadow: 1
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
287
|
+
spacing: 0.25,
|
|
288
|
+
alignItems: "flex-end",
|
|
289
|
+
children: usdAmount && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
290
|
+
variant: "caption",
|
|
291
|
+
sx: {
|
|
292
|
+
color: "text.secondary",
|
|
293
|
+
fontSize: "0.75rem",
|
|
294
|
+
fontWeight: 400,
|
|
295
|
+
lineHeight: 1.2
|
|
296
|
+
},
|
|
297
|
+
children: ["\u2248 $", usdAmount]
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
})]
|
|
171
301
|
})
|
|
172
302
|
});
|
|
173
303
|
}
|
|
@@ -206,7 +336,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
206
336
|
onClick: e => handleLinkClick(e, invoice),
|
|
207
337
|
sx: linkStyle,
|
|
208
338
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
209
|
-
label: (0,
|
|
339
|
+
label: (0, _util2.getInvoiceDescriptionAndReason)(invoice, locale)?.type
|
|
210
340
|
})
|
|
211
341
|
});
|
|
212
342
|
}
|
|
@@ -308,7 +438,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
308
438
|
const quantity = Number(line.quantity || 0);
|
|
309
439
|
const totalAmount = creditAmount * (Number.isFinite(quantity) && quantity > 0 ? quantity : 1);
|
|
310
440
|
const currencySymbol = getCurrency(creditConfig?.currency_id)?.symbol || creditConfig?.currency_id || "Credits";
|
|
311
|
-
pushCreditItem("amount", `+${(0,
|
|
441
|
+
pushCreditItem("amount", `+${(0, _util2.formatCreditAmount)(String(totalAmount), currencySymbol)}`);
|
|
312
442
|
return;
|
|
313
443
|
}
|
|
314
444
|
const scheduleConfig = creditConfig?.schedule;
|
|
@@ -317,14 +447,14 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
317
447
|
const quantity = Number(line.quantity || 0);
|
|
318
448
|
const totalAmount = scheduledAmount * (Number.isFinite(quantity) && quantity > 0 ? quantity : 1);
|
|
319
449
|
const currencySymbol = getCurrency(creditConfig?.currency_id)?.symbol || creditConfig?.currency_id || "Credits";
|
|
320
|
-
pushCreditItem("schedule", `+${(0,
|
|
450
|
+
pushCreditItem("schedule", `+${(0, _util2.formatCreditAmount)(String(totalAmount), currencySymbol)}`);
|
|
321
451
|
return;
|
|
322
452
|
}
|
|
323
453
|
const creditInfo = line.price?.credit;
|
|
324
454
|
const creditInfoAmount = Number(creditInfo?.amount || 0);
|
|
325
455
|
if (creditInfoAmount > 0) {
|
|
326
456
|
const currencySymbol = creditInfo.currency?.symbol || "Credits";
|
|
327
|
-
pushCreditItem("credit", `+${(0,
|
|
457
|
+
pushCreditItem("credit", `+${(0, _util2.formatCreditAmount)(String(creditInfoAmount), currencySymbol)}`);
|
|
328
458
|
}
|
|
329
459
|
});
|
|
330
460
|
if (creditItems.length === 0) {
|
|
@@ -352,7 +482,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
352
482
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
353
483
|
onClick: e => handleLinkClick(e, invoice),
|
|
354
484
|
sx: linkStyle,
|
|
355
|
-
children: (0,
|
|
485
|
+
children: (0, _util2.formatToDate)(invoice.created_at, locale, relatedSubscription ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD HH:mm:ss")
|
|
356
486
|
});
|
|
357
487
|
}
|
|
358
488
|
}
|
|
@@ -424,12 +554,12 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
424
554
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
425
555
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
426
556
|
label: invoice.status,
|
|
427
|
-
color: (0,
|
|
557
|
+
color: (0, _util2.getInvoiceStatusColor)(invoice.status)
|
|
428
558
|
})
|
|
429
559
|
})
|
|
430
560
|
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
431
561
|
label: invoice.status,
|
|
432
|
-
color: (0,
|
|
562
|
+
color: (0, _util2.getInvoiceStatusColor)(invoice.status)
|
|
433
563
|
})
|
|
434
564
|
});
|
|
435
565
|
}
|
|
@@ -573,7 +703,7 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
573
703
|
my: 0.5
|
|
574
704
|
},
|
|
575
705
|
children: t("payment.customer.invoice.next", {
|
|
576
|
-
date: (0,
|
|
706
|
+
date: (0, _util2.formatToDatetime)(data.subscription.current_period_end * 1e3)
|
|
577
707
|
})
|
|
578
708
|
});
|
|
579
709
|
}
|
|
@@ -613,6 +743,9 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
613
743
|
connect
|
|
614
744
|
} = getInvoiceLink(invoice, action);
|
|
615
745
|
const isVoid = invoice.status === "void";
|
|
746
|
+
const quoteInfo = getInvoiceQuoteInfo(invoice);
|
|
747
|
+
const formattedRate = (0, _util2.formatExchangeRate)(quoteInfo?.exchange_rate || null);
|
|
748
|
+
const rateLine = formattedRate ? `1 ${invoice.paymentCurrency.symbol} \u2248 ${formattedRate} ${quoteInfo?.base_currency || "USD"}` : null;
|
|
616
749
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
617
750
|
direction: "row",
|
|
618
751
|
sx: {
|
|
@@ -655,24 +788,31 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
655
788
|
})]
|
|
656
789
|
})
|
|
657
790
|
})
|
|
658
|
-
}), /* @__PURE__ */(0, _jsxRuntime.
|
|
791
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
659
792
|
sx: {
|
|
660
793
|
flex: 1,
|
|
661
794
|
textAlign: "right"
|
|
662
795
|
},
|
|
663
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
796
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
664
797
|
sx: isVoid ? {
|
|
665
798
|
textDecoration: "line-through"
|
|
666
799
|
} : {},
|
|
667
|
-
children: [(0,
|
|
668
|
-
})
|
|
800
|
+
children: [(0, _util2.formatAmount)(invoice.total, invoice.paymentCurrency.decimal), "\xA0", invoice.paymentCurrency.symbol]
|
|
801
|
+
}), rateLine && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
802
|
+
variant: "caption",
|
|
803
|
+
sx: {
|
|
804
|
+
color: "text.secondary",
|
|
805
|
+
display: "block"
|
|
806
|
+
},
|
|
807
|
+
children: rateLine
|
|
808
|
+
})]
|
|
669
809
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
670
810
|
sx: {
|
|
671
811
|
flex: 1,
|
|
672
812
|
textAlign: "right"
|
|
673
813
|
},
|
|
674
814
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
675
|
-
children: (0,
|
|
815
|
+
children: (0, _util2.formatToDate)(invoice.created_at, locale, "HH:mm:ss")
|
|
676
816
|
})
|
|
677
817
|
}), !action && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
678
818
|
className: "invoice-description",
|
|
@@ -739,12 +879,12 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
739
879
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
740
880
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
741
881
|
label: invoice.status,
|
|
742
|
-
color: (0,
|
|
882
|
+
color: (0, _util2.getInvoiceStatusColor)(invoice.status)
|
|
743
883
|
})
|
|
744
884
|
})
|
|
745
885
|
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
746
886
|
label: invoice.status,
|
|
747
|
-
color: (0,
|
|
887
|
+
color: (0, _util2.getInvoiceStatusColor)(invoice.status)
|
|
748
888
|
})
|
|
749
889
|
})]
|
|
750
890
|
}, invoice.id);
|
|
@@ -812,7 +952,7 @@ function CustomerInvoiceList(rawProps) {
|
|
|
812
952
|
action: "collect",
|
|
813
953
|
saveConnect: false,
|
|
814
954
|
locale,
|
|
815
|
-
useSocket: (0,
|
|
955
|
+
useSocket: (0, _util2.isCrossOrigin)() === false,
|
|
816
956
|
messages: {
|
|
817
957
|
scan: "",
|
|
818
958
|
title: t(`payment.customer.invoice.${action || "pay"}`),
|
|
@@ -840,7 +980,7 @@ function CustomerInvoiceList(rawProps) {
|
|
|
840
980
|
setState({
|
|
841
981
|
paying: ""
|
|
842
982
|
});
|
|
843
|
-
_Toast.default.error((0,
|
|
983
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
844
984
|
}
|
|
845
985
|
});
|
|
846
986
|
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useDynamicPricing Hook
|
|
3
|
+
*
|
|
4
|
+
* Extracts and centralizes all dynamic pricing related calculations
|
|
5
|
+
* for the checkout summary component.
|
|
6
|
+
*
|
|
7
|
+
* Final Freeze Architecture: Quotes are created at Submit time only.
|
|
8
|
+
* This hook handles preview-time display calculations.
|
|
9
|
+
*/
|
|
10
|
+
import type { TCheckoutSession, TLineItemExpanded, TPaymentCurrency, TPaymentIntent } from '@blocklet/payment-types';
|
|
11
|
+
export interface LiveRateInfo {
|
|
12
|
+
rate?: string;
|
|
13
|
+
provider_id?: string;
|
|
14
|
+
provider_name?: string;
|
|
15
|
+
provider_display?: string;
|
|
16
|
+
base_currency?: string;
|
|
17
|
+
timestamp_ms?: number;
|
|
18
|
+
fetched_at?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface LiveQuoteSnapshot {
|
|
21
|
+
id: string;
|
|
22
|
+
quoted_amount: string;
|
|
23
|
+
exchange_rate: string;
|
|
24
|
+
expires_at: number;
|
|
25
|
+
rate_timestamp_ms?: number | null;
|
|
26
|
+
renewed?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface DiscountInfo {
|
|
29
|
+
promotion_code?: string;
|
|
30
|
+
coupon?: string;
|
|
31
|
+
discount_amount?: string;
|
|
32
|
+
coupon_details?: {
|
|
33
|
+
percent_off?: number;
|
|
34
|
+
amount_off?: string;
|
|
35
|
+
currency_id?: string;
|
|
36
|
+
currency_options?: Record<string, {
|
|
37
|
+
amount_off?: string;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface DynamicPricingOptions {
|
|
42
|
+
items: TLineItemExpanded[];
|
|
43
|
+
currency: TPaymentCurrency;
|
|
44
|
+
liveRate?: LiveRateInfo;
|
|
45
|
+
liveQuoteSnapshot?: LiveQuoteSnapshot;
|
|
46
|
+
checkoutSession?: TCheckoutSession;
|
|
47
|
+
paymentIntent?: TPaymentIntent | null;
|
|
48
|
+
locale?: string;
|
|
49
|
+
isStripePayment?: boolean;
|
|
50
|
+
isSubscription?: boolean;
|
|
51
|
+
slippageConfig?: {
|
|
52
|
+
mode?: 'percent' | 'rate';
|
|
53
|
+
percent?: number | null;
|
|
54
|
+
min_acceptable_rate?: string;
|
|
55
|
+
base_currency?: string;
|
|
56
|
+
};
|
|
57
|
+
trialInDays?: number;
|
|
58
|
+
trialEnd?: number;
|
|
59
|
+
discounts?: DiscountInfo[];
|
|
60
|
+
}
|
|
61
|
+
export interface RateInfo {
|
|
62
|
+
exchangeRate: string | null;
|
|
63
|
+
baseCurrency: string;
|
|
64
|
+
providerName: string | null;
|
|
65
|
+
providerId: string | null;
|
|
66
|
+
timestampMs: number | null;
|
|
67
|
+
fetchedAt: number | null;
|
|
68
|
+
}
|
|
69
|
+
export interface QuoteMeta {
|
|
70
|
+
exchangeRate: string | null;
|
|
71
|
+
baseCurrency: string;
|
|
72
|
+
expiresAt: number | null;
|
|
73
|
+
providerName: string | null;
|
|
74
|
+
providerId: string | null;
|
|
75
|
+
rateTimestampMs: number | null;
|
|
76
|
+
slippagePercent: number | null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Custom hook for dynamic pricing calculations
|
|
80
|
+
*/
|
|
81
|
+
export declare function useDynamicPricing(options: DynamicPricingOptions): {
|
|
82
|
+
hasDynamicPricing: boolean;
|
|
83
|
+
isPriceLocked: boolean;
|
|
84
|
+
lockExpired: boolean;
|
|
85
|
+
quoteMeta: QuoteMeta | null;
|
|
86
|
+
rateInfo: RateInfo;
|
|
87
|
+
quoteLockedAt: number | null;
|
|
88
|
+
calculatedTokenAmount: string | null;
|
|
89
|
+
calculatedDiscountAmount: any;
|
|
90
|
+
currentSlippagePercent: number;
|
|
91
|
+
rateDisplay: string | null;
|
|
92
|
+
providerDisplay: string;
|
|
93
|
+
formatTotalDisplay: (totalAmountValue: string, fallback?: string) => string;
|
|
94
|
+
calculateUsdDisplay: (totalAmountValue: string) => string | null;
|
|
95
|
+
buildQuoteDetailRows: (t: (key: string) => string) => {
|
|
96
|
+
label: string;
|
|
97
|
+
value: string | React.ReactNode;
|
|
98
|
+
isSlippage?: boolean;
|
|
99
|
+
tooltip?: string;
|
|
100
|
+
}[];
|
|
101
|
+
};
|
|
102
|
+
export default useDynamicPricing;
|