@blocklet/payment-react 1.18.56 → 1.19.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/es/checkout/donate.d.ts +1 -15
- package/es/checkout/donate.js +301 -189
- package/es/checkout/form.d.ts +1 -15
- package/es/checkout/form.js +5 -13
- package/es/checkout/table.js +3 -3
- package/es/components/blockchain/gas.d.ts +1 -5
- package/es/components/blockchain/gas.js +10 -2
- package/es/components/blockchain/tx.d.ts +1 -8
- package/es/components/blockchain/tx.js +29 -10
- package/es/components/confirm.d.ts +1 -10
- package/es/components/confirm.js +4 -10
- package/es/components/country-select.d.ts +3 -2
- package/es/components/country-select.js +375 -352
- package/es/components/date-range-picker.d.ts +13 -0
- package/es/components/date-range-picker.js +279 -0
- package/es/components/input.d.ts +14 -20
- package/es/components/input.js +51 -44
- package/es/components/label.d.ts +7 -0
- package/es/components/label.js +49 -0
- package/es/components/lazy-loader.js +1 -2
- package/es/components/link.d.ts +2 -9
- package/es/components/link.js +9 -6
- package/es/components/livemode.d.ts +2 -8
- package/es/components/livemode.js +1 -5
- package/es/components/loading-button.d.ts +6 -1
- package/es/components/loading-button.js +56 -66
- package/es/components/over-due-invoice-payment.d.ts +0 -18
- package/es/components/over-due-invoice-payment.js +138 -95
- package/es/components/payment-beneficiaries.d.ts +2 -7
- package/es/components/payment-beneficiaries.js +86 -40
- package/es/components/pricing-item.d.ts +0 -5
- package/es/components/pricing-item.js +1 -4
- package/es/components/pricing-table.d.ts +2 -10
- package/es/components/pricing-table.js +8 -7
- package/es/components/resume-subscription.d.ts +0 -10
- package/es/components/resume-subscription.js +42 -21
- package/es/components/truncated-text.d.ts +2 -9
- package/es/components/truncated-text.js +0 -5
- package/es/contexts/donate.d.ts +0 -7
- package/es/contexts/donate.js +10 -8
- package/es/contexts/payment.d.ts +1 -4
- package/es/contexts/payment.js +7 -2
- package/es/history/credit/grants-list.d.ts +14 -0
- package/es/history/credit/grants-list.js +215 -0
- package/es/history/credit/transactions-list.d.ts +13 -0
- package/es/history/credit/transactions-list.js +255 -0
- package/es/history/invoice/list.d.ts +2 -18
- package/es/history/invoice/list.js +172 -74
- package/es/history/payment/list.js +115 -38
- package/es/hooks/keyboard.d.ts +1 -1
- package/es/hooks/keyboard.js +2 -4
- package/es/index.d.ts +5 -1
- package/es/index.js +10 -1
- package/es/libs/cached-request.js +2 -4
- package/es/libs/phone-validator.js +1 -2
- package/es/libs/util.d.ts +2 -0
- package/es/libs/util.js +14 -4
- package/es/libs/validator.js +2 -4
- package/es/locales/en.js +20 -2
- package/es/locales/zh.js +20 -2
- package/es/payment/amount.d.ts +2 -7
- package/es/payment/amount.js +1 -5
- package/es/payment/donation-form.d.ts +2 -10
- package/es/payment/donation-form.js +196 -160
- package/es/payment/error.d.ts +2 -8
- package/es/payment/error.js +40 -20
- package/es/payment/footer.d.ts +2 -3
- package/es/payment/footer.js +19 -6
- package/es/payment/form/addon.js +14 -4
- package/es/payment/form/address.d.ts +2 -9
- package/es/payment/form/address.js +3 -6
- package/es/payment/form/currency.js +45 -25
- package/es/payment/form/index.d.ts +2 -8
- package/es/payment/form/index.js +151 -71
- package/es/payment/form/phone.js +2 -4
- package/es/payment/form/stripe/form.d.ts +2 -8
- package/es/payment/form/stripe/form.js +1 -3
- package/es/payment/header.js +38 -16
- package/es/payment/index.d.ts +2 -9
- package/es/payment/index.js +23 -17
- package/es/payment/product-card.d.ts +2 -11
- package/es/payment/product-card.js +84 -50
- package/es/payment/product-donation.js +175 -114
- package/es/payment/product-item.d.ts +9 -9
- package/es/payment/product-item.js +320 -145
- package/es/payment/product-skeleton.js +2 -2
- package/es/payment/skeleton/donation.js +27 -7
- package/es/payment/skeleton/overview.js +22 -2
- package/es/payment/skeleton/payment.js +33 -5
- package/es/payment/success.d.ts +2 -9
- package/es/payment/success.js +41 -14
- package/es/payment/summary.d.ts +4 -17
- package/es/payment/summary.js +193 -111
- package/es/theme/index.d.ts +0 -5
- package/es/theme/index.js +2 -5
- package/es/theme/typography.d.ts +2 -2
- package/lib/checkout/donate.d.ts +1 -15
- package/lib/checkout/donate.js +75 -54
- package/lib/checkout/form.d.ts +1 -15
- package/lib/checkout/form.js +7 -15
- package/lib/checkout/table.js +4 -4
- package/lib/components/blockchain/gas.d.ts +1 -5
- package/lib/components/blockchain/gas.js +3 -2
- package/lib/components/blockchain/tx.d.ts +1 -8
- package/lib/components/blockchain/tx.js +15 -10
- package/lib/components/confirm.d.ts +1 -10
- package/lib/components/confirm.js +5 -11
- package/lib/components/country-select.d.ts +3 -2
- package/lib/components/country-select.js +23 -22
- package/lib/components/date-range-picker.d.ts +13 -0
- package/lib/components/date-range-picker.js +329 -0
- package/lib/components/input.d.ts +14 -20
- package/lib/components/input.js +28 -27
- package/lib/components/label.d.ts +7 -0
- package/lib/components/label.js +60 -0
- package/lib/components/lazy-loader.js +1 -1
- package/lib/components/link.d.ts +2 -9
- package/lib/components/link.js +3 -8
- package/lib/components/livemode.d.ts +2 -8
- package/lib/components/livemode.js +3 -7
- package/lib/components/loading-button.d.ts +6 -1
- package/lib/components/loading-button.js +9 -17
- package/lib/components/over-due-invoice-payment.d.ts +0 -18
- package/lib/components/over-due-invoice-payment.js +31 -33
- package/lib/components/payment-beneficiaries.d.ts +2 -7
- package/lib/components/payment-beneficiaries.js +12 -11
- package/lib/components/pricing-item.d.ts +0 -5
- package/lib/components/pricing-item.js +2 -5
- package/lib/components/pricing-table.d.ts +2 -10
- package/lib/components/pricing-table.js +5 -11
- package/lib/components/resume-subscription.d.ts +0 -10
- package/lib/components/resume-subscription.js +16 -16
- package/lib/components/table.js +1 -1
- package/lib/components/truncated-text.d.ts +2 -9
- package/lib/components/truncated-text.js +1 -6
- package/lib/contexts/donate.d.ts +0 -7
- package/lib/contexts/donate.js +4 -7
- package/lib/contexts/payment.d.ts +1 -4
- package/lib/contexts/payment.js +4 -7
- package/lib/history/credit/grants-list.d.ts +14 -0
- package/lib/history/credit/grants-list.js +277 -0
- package/lib/history/credit/transactions-list.d.ts +13 -0
- package/lib/history/credit/transactions-list.js +301 -0
- package/lib/history/invoice/list.d.ts +2 -18
- package/lib/history/invoice/list.js +73 -37
- package/lib/history/payment/list.js +30 -16
- package/lib/hooks/keyboard.d.ts +1 -1
- package/lib/hooks/mobile.js +1 -1
- package/lib/hooks/subscription.js +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +41 -2
- package/lib/libs/api.js +1 -1
- package/lib/libs/dayjs.js +1 -1
- package/lib/libs/phone-validator.js +0 -2
- package/lib/libs/theme.js +1 -1
- package/lib/libs/util.d.ts +2 -0
- package/lib/libs/util.js +15 -1
- package/lib/libs/validator.js +1 -1
- package/lib/locales/en.js +21 -3
- package/lib/locales/index.js +1 -1
- package/lib/locales/zh.js +21 -3
- package/lib/payment/amount.d.ts +2 -7
- package/lib/payment/amount.js +2 -6
- package/lib/payment/donation-form.d.ts +2 -10
- package/lib/payment/donation-form.js +33 -38
- package/lib/payment/error.d.ts +2 -8
- package/lib/payment/error.js +11 -13
- package/lib/payment/footer.d.ts +2 -3
- package/lib/payment/footer.js +5 -5
- package/lib/payment/form/addon.js +5 -3
- package/lib/payment/form/address.d.ts +2 -9
- package/lib/payment/form/address.js +5 -8
- package/lib/payment/form/currency.js +3 -3
- package/lib/payment/form/index.d.ts +2 -8
- package/lib/payment/form/index.js +64 -21
- package/lib/payment/form/phone.js +1 -1
- package/lib/payment/form/stripe/form.d.ts +2 -8
- package/lib/payment/form/stripe/form.js +3 -6
- package/lib/payment/header.js +8 -4
- package/lib/payment/index.d.ts +2 -9
- package/lib/payment/index.js +27 -18
- package/lib/payment/product-card.d.ts +2 -11
- package/lib/payment/product-card.js +13 -20
- package/lib/payment/product-donation.js +71 -66
- package/lib/payment/product-item.d.ts +9 -9
- package/lib/payment/product-item.js +168 -29
- package/lib/payment/product-skeleton.js +2 -2
- package/lib/payment/skeleton/donation.js +8 -4
- package/lib/payment/skeleton/overview.js +6 -2
- package/lib/payment/skeleton/payment.js +9 -3
- package/lib/payment/success.d.ts +2 -9
- package/lib/payment/success.js +12 -15
- package/lib/payment/summary.d.ts +4 -17
- package/lib/payment/summary.js +53 -45
- package/lib/theme/index.d.ts +0 -5
- package/lib/theme/index.js +2 -5
- package/lib/theme/typography.d.ts +2 -2
- package/package.json +40 -40
- package/src/checkout/donate.tsx +103 -35
- package/src/checkout/form.tsx +5 -14
- package/src/checkout/table.tsx +3 -3
- package/src/components/blockchain/gas.tsx +5 -3
- package/src/components/blockchain/tx.tsx +19 -11
- package/src/components/confirm.tsx +4 -11
- package/src/components/country-select.tsx +391 -378
- package/src/components/date-range-picker.tsx +310 -0
- package/src/components/input.tsx +61 -46
- package/src/components/label.tsx +58 -0
- package/src/components/link.tsx +9 -7
- package/src/components/livemode.tsx +2 -6
- package/src/components/loading-button.tsx +63 -76
- package/src/components/over-due-invoice-payment.tsx +43 -28
- package/src/components/payment-beneficiaries.tsx +33 -14
- package/src/components/pricing-item.tsx +1 -4
- package/src/components/pricing-table.tsx +8 -8
- package/src/components/resume-subscription.tsx +20 -14
- package/src/components/table.tsx +2 -2
- package/src/components/truncated-text.tsx +0 -6
- package/src/contexts/donate.tsx +6 -7
- package/src/contexts/payment.tsx +7 -3
- package/src/history/credit/grants-list.tsx +276 -0
- package/src/history/credit/transactions-list.tsx +317 -0
- package/src/history/invoice/list.tsx +92 -36
- package/src/history/payment/list.tsx +53 -16
- package/src/hooks/keyboard.ts +1 -1
- package/src/index.ts +9 -0
- package/src/libs/util.ts +14 -0
- package/src/locales/en.tsx +20 -0
- package/src/locales/zh.tsx +19 -0
- package/src/payment/amount.tsx +1 -6
- package/src/payment/donation-form.tsx +47 -29
- package/src/payment/error.tsx +16 -8
- package/src/payment/footer.tsx +11 -3
- package/src/payment/form/addon.tsx +6 -1
- package/src/payment/form/address.tsx +3 -7
- package/src/payment/form/currency.tsx +12 -2
- package/src/payment/form/index.tsx +121 -45
- package/src/payment/form/stripe/form.tsx +1 -5
- package/src/payment/header.tsx +14 -2
- package/src/payment/index.tsx +27 -22
- package/src/payment/product-card.tsx +41 -18
- package/src/payment/product-donation.tsx +85 -47
- package/src/payment/product-item.tsx +198 -28
- package/src/payment/product-skeleton.tsx +3 -2
- package/src/payment/skeleton/donation.tsx +12 -2
- package/src/payment/skeleton/overview.tsx +12 -2
- package/src/payment/skeleton/payment.tsx +16 -3
- package/src/payment/success.tsx +26 -15
- package/src/payment/summary.tsx +87 -44
- package/src/theme/index.tsx +5 -8
- package/src/theme/typography.ts +2 -2
|
@@ -21,31 +21,51 @@ export default function CurrencySelector({ value, currencies, onChange }) {
|
|
|
21
21
|
variant: "outlined",
|
|
22
22
|
onClick: () => onChange(x.id, x.method?.id),
|
|
23
23
|
className: selected ? "cko-payment-card" : "cko-payment-card-unselect",
|
|
24
|
-
children: /* @__PURE__ */ jsxs(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
24
|
+
children: /* @__PURE__ */ jsxs(
|
|
25
|
+
Stack,
|
|
26
|
+
{
|
|
27
|
+
direction: "row",
|
|
28
|
+
sx: {
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
position: "relative"
|
|
31
|
+
},
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width: 40, height: 40, marginRight: "12px" } }),
|
|
34
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
Typography,
|
|
37
|
+
{
|
|
38
|
+
variant: "h5",
|
|
39
|
+
component: "div",
|
|
40
|
+
sx: { fontSize: "16px", color: "text.primary", fontWeight: "500" },
|
|
41
|
+
children: x.symbol
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
Typography,
|
|
46
|
+
{
|
|
47
|
+
gutterBottom: true,
|
|
48
|
+
sx: {
|
|
49
|
+
color: "text.lighter",
|
|
50
|
+
fontSize: 14
|
|
51
|
+
},
|
|
52
|
+
children: x.method.name
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
] }),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
Radio,
|
|
58
|
+
{
|
|
59
|
+
checked: selected,
|
|
60
|
+
sx: {
|
|
61
|
+
position: "absolute",
|
|
62
|
+
right: 0
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
)
|
|
49
69
|
},
|
|
50
70
|
x.id
|
|
51
71
|
);
|
|
@@ -6,11 +6,5 @@ type PageData = CheckoutContext & CheckoutCallbacks & {
|
|
|
6
6
|
onlyShowBtn?: boolean;
|
|
7
7
|
isDonation?: boolean;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var defaultProps: {
|
|
12
|
-
onlyShowBtn: boolean;
|
|
13
|
-
isDonation: boolean;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export default PaymentForm;
|
|
9
|
+
export default function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, onlyShowBtn, isDonation, }: PageData): import("react").JSX.Element;
|
|
10
|
+
export {};
|
package/es/payment/form/index.js
CHANGED
|
@@ -85,10 +85,6 @@ const setUserFormValues = (userInfo, currentValues, setValue, options = {}) => {
|
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
|
-
PaymentForm.defaultProps = {
|
|
89
|
-
onlyShowBtn: false,
|
|
90
|
-
isDonation: false
|
|
91
|
-
};
|
|
92
88
|
export default function PaymentForm({
|
|
93
89
|
checkoutSession,
|
|
94
90
|
paymentMethods,
|
|
@@ -99,7 +95,7 @@ export default function PaymentForm({
|
|
|
99
95
|
onError,
|
|
100
96
|
// mode,
|
|
101
97
|
action,
|
|
102
|
-
onlyShowBtn,
|
|
98
|
+
onlyShowBtn = false,
|
|
103
99
|
isDonation = false
|
|
104
100
|
}) {
|
|
105
101
|
const { t, locale } = useLocaleContext();
|
|
@@ -135,7 +131,8 @@ export default function PaymentForm({
|
|
|
135
131
|
customer,
|
|
136
132
|
customerLimited: false,
|
|
137
133
|
stripePaying: false,
|
|
138
|
-
fastCheckoutInfo: null
|
|
134
|
+
fastCheckoutInfo: null,
|
|
135
|
+
creditInsufficientInfo: null
|
|
139
136
|
});
|
|
140
137
|
const currencies = flattenPaymentMethods(paymentMethods);
|
|
141
138
|
const onCheckoutComplete = useMemoizedFn(async ({ response }) => {
|
|
@@ -270,8 +267,7 @@ export default function PaymentForm({
|
|
|
270
267
|
}
|
|
271
268
|
};
|
|
272
269
|
const handleFastCheckoutConfirm = async () => {
|
|
273
|
-
if (!state.fastCheckoutInfo)
|
|
274
|
-
return;
|
|
270
|
+
if (!state.fastCheckoutInfo) return;
|
|
275
271
|
setState({
|
|
276
272
|
fastCheckoutInfo: {
|
|
277
273
|
...state.fastCheckoutInfo,
|
|
@@ -305,6 +301,9 @@ export default function PaymentForm({
|
|
|
305
301
|
const handleFastCheckoutCancel = () => {
|
|
306
302
|
setState({ fastCheckoutInfo: null });
|
|
307
303
|
};
|
|
304
|
+
const handleCreditInsufficientClose = () => {
|
|
305
|
+
setState({ creditInsufficientInfo: null });
|
|
306
|
+
};
|
|
308
307
|
const openConnect = () => {
|
|
309
308
|
try {
|
|
310
309
|
if (!["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
@@ -360,7 +359,27 @@ export default function PaymentForm({
|
|
|
360
359
|
customerLimited: false
|
|
361
360
|
});
|
|
362
361
|
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
363
|
-
if (
|
|
362
|
+
if (paymentCurrency?.type === "credit") {
|
|
363
|
+
if (result.data.creditSufficient === true) {
|
|
364
|
+
setState({
|
|
365
|
+
fastCheckoutInfo: {
|
|
366
|
+
open: true,
|
|
367
|
+
loading: false,
|
|
368
|
+
sourceType: "credit",
|
|
369
|
+
amount: result.data.fastPayInfo?.amount || "0",
|
|
370
|
+
payer: result.data.fastPayInfo?.payer,
|
|
371
|
+
availableCredit: result.data.fastPayInfo?.amount || "0",
|
|
372
|
+
balance: result.data.fastPayInfo?.token?.balance || "0"
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
} else {
|
|
376
|
+
setState({
|
|
377
|
+
creditInsufficientInfo: {
|
|
378
|
+
open: true
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
} else if ((result.data.balance?.sufficient || result.data.delegation?.sufficient) && !isDonationMode && result.data.fastPayInfo) {
|
|
364
383
|
setState({
|
|
365
384
|
fastCheckoutInfo: {
|
|
366
385
|
open: true,
|
|
@@ -450,45 +469,94 @@ export default function PaymentForm({
|
|
|
450
469
|
{
|
|
451
470
|
onConfirm: handleFastCheckoutConfirm,
|
|
452
471
|
onCancel: handleFastCheckoutCancel,
|
|
453
|
-
title: t("payment.checkout.fastPay.title"),
|
|
454
|
-
message: /* @__PURE__ */
|
|
472
|
+
title: state.fastCheckoutInfo.sourceType === "credit" ? t("payment.checkout.fastPay.credit.title") : t("payment.checkout.fastPay.title"),
|
|
473
|
+
message: state.fastCheckoutInfo.sourceType === "credit" ? /* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.fastPay.credit.meteringSubscriptionMessage", {
|
|
474
|
+
available: `${fromUnitToToken(state.fastCheckoutInfo?.balance || "0", paymentCurrency?.decimal || 18).toString()} ${paymentCurrency?.symbol}`
|
|
475
|
+
}) }) : /* @__PURE__ */ jsxs(Stack, { children: [
|
|
455
476
|
/* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.fastPay.autoPaymentReason") }),
|
|
456
477
|
/* @__PURE__ */ jsx(Divider, { sx: { mt: 1.5, mb: 1.5 } }),
|
|
457
478
|
/* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
|
|
458
|
-
/* @__PURE__ */ jsxs(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
479
|
+
/* @__PURE__ */ jsxs(
|
|
480
|
+
Stack,
|
|
481
|
+
{
|
|
482
|
+
sx: {
|
|
483
|
+
flexDirection: "row",
|
|
484
|
+
alignItems: "center",
|
|
485
|
+
justifyContent: "space-between"
|
|
486
|
+
},
|
|
487
|
+
children: [
|
|
488
|
+
/* @__PURE__ */ jsx(
|
|
489
|
+
Typography,
|
|
490
|
+
{
|
|
491
|
+
sx: {
|
|
492
|
+
color: "text.primary",
|
|
493
|
+
whiteSpace: "nowrap"
|
|
494
|
+
},
|
|
495
|
+
children: t("payment.checkout.fastPay.payer")
|
|
473
496
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
497
|
+
),
|
|
498
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
|
|
499
|
+
/* @__PURE__ */ jsx(DID, { did: state.fastCheckoutInfo.payer || "", compact: true, responsive: false }),
|
|
500
|
+
balanceLink && /* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.fastPay.balanceLink"), placement: "top", children: /* @__PURE__ */ jsx(
|
|
501
|
+
OpenInNew,
|
|
502
|
+
{
|
|
503
|
+
sx: {
|
|
504
|
+
color: "text.lighter",
|
|
505
|
+
fontSize: "0.85rem",
|
|
506
|
+
cursor: "pointer",
|
|
507
|
+
"&:hover": { color: "text.primary" }
|
|
508
|
+
},
|
|
509
|
+
onClick: () => {
|
|
510
|
+
window.open(balanceLink, "_blank");
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
) })
|
|
514
|
+
] })
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
/* @__PURE__ */ jsxs(
|
|
519
|
+
Stack,
|
|
520
|
+
{
|
|
521
|
+
sx: {
|
|
522
|
+
flexDirection: "row",
|
|
523
|
+
alignItems: "center",
|
|
524
|
+
justifyContent: "space-between"
|
|
525
|
+
},
|
|
526
|
+
children: [
|
|
527
|
+
/* @__PURE__ */ jsx(
|
|
528
|
+
Typography,
|
|
529
|
+
{
|
|
530
|
+
sx: {
|
|
531
|
+
color: "text.primary"
|
|
532
|
+
},
|
|
533
|
+
children: t("payment.checkout.fastPay.amount")
|
|
534
|
+
}
|
|
535
|
+
),
|
|
536
|
+
/* @__PURE__ */ jsxs(Typography, { children: [
|
|
537
|
+
fromUnitToToken(state.fastCheckoutInfo.amount, paymentCurrency?.decimal || 18).toString(),
|
|
538
|
+
" ",
|
|
539
|
+
paymentCurrency?.symbol
|
|
540
|
+
] })
|
|
541
|
+
]
|
|
542
|
+
}
|
|
543
|
+
)
|
|
486
544
|
] })
|
|
487
545
|
] }),
|
|
488
546
|
loading: state.fastCheckoutInfo.loading,
|
|
489
547
|
color: "primary"
|
|
490
548
|
}
|
|
491
549
|
);
|
|
550
|
+
const CreditInsufficientDialog = state.creditInsufficientInfo && /* @__PURE__ */ jsx(
|
|
551
|
+
ConfirmDialog,
|
|
552
|
+
{
|
|
553
|
+
onConfirm: handleCreditInsufficientClose,
|
|
554
|
+
onCancel: handleCreditInsufficientClose,
|
|
555
|
+
title: t("payment.checkout.fastPay.credit.insufficientTitle"),
|
|
556
|
+
message: /* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.fastPay.credit.insufficientMessage") }),
|
|
557
|
+
confirm: t("common.confirm")
|
|
558
|
+
}
|
|
559
|
+
);
|
|
492
560
|
if (onlyShowBtn) {
|
|
493
561
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
494
562
|
/* @__PURE__ */ jsx(Box, { className: "cko-payment-submit-btn", children: /* @__PURE__ */ jsxs(
|
|
@@ -541,7 +609,8 @@ export default function PaymentForm({
|
|
|
541
609
|
}
|
|
542
610
|
}
|
|
543
611
|
),
|
|
544
|
-
FastCheckoutConfirmDialog
|
|
612
|
+
FastCheckoutConfirmDialog,
|
|
613
|
+
CreditInsufficientDialog
|
|
545
614
|
] });
|
|
546
615
|
}
|
|
547
616
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -563,40 +632,50 @@ export default function PaymentForm({
|
|
|
563
632
|
children: t("payment.checkout.paymentDetails")
|
|
564
633
|
}
|
|
565
634
|
),
|
|
566
|
-
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
635
|
+
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(
|
|
636
|
+
Stack,
|
|
637
|
+
{
|
|
638
|
+
direction: "column",
|
|
639
|
+
className: "cko-payment-methods",
|
|
640
|
+
sx: {
|
|
641
|
+
alignItems: "flex-start"
|
|
642
|
+
},
|
|
643
|
+
children: [
|
|
644
|
+
/* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
645
|
+
Controller,
|
|
574
646
|
{
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
647
|
+
name: "payment_currency",
|
|
648
|
+
control,
|
|
649
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
650
|
+
CurrencySelector,
|
|
651
|
+
{
|
|
652
|
+
value: field.value,
|
|
653
|
+
currencies,
|
|
654
|
+
onChange: (id, methodId) => {
|
|
655
|
+
field.onChange(id);
|
|
656
|
+
setValue("payment_method", methodId);
|
|
657
|
+
saveCurrencyPreference(id, session?.user?.did);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
) }),
|
|
663
|
+
state.stripePaying && state.stripeContext && /* @__PURE__ */ jsx(
|
|
664
|
+
StripeCheckout,
|
|
665
|
+
{
|
|
666
|
+
clientSecret: state.stripeContext.client_secret,
|
|
667
|
+
intentType: state.stripeContext.intent_type,
|
|
668
|
+
publicKey: method.settings.stripe?.publishable_key,
|
|
669
|
+
customer: state.customer,
|
|
670
|
+
mode: checkoutSession.mode,
|
|
671
|
+
onConfirm: onStripeConfirm,
|
|
672
|
+
onCancel: onStripeCancel,
|
|
673
|
+
returnUrl: checkoutSession?.success_url
|
|
582
674
|
}
|
|
583
675
|
)
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
StripeCheckout,
|
|
588
|
-
{
|
|
589
|
-
clientSecret: state.stripeContext.client_secret,
|
|
590
|
-
intentType: state.stripeContext.intent_type,
|
|
591
|
-
publicKey: method.settings.stripe?.publishable_key,
|
|
592
|
-
customer: state.customer,
|
|
593
|
-
mode: checkoutSession.mode,
|
|
594
|
-
onConfirm: onStripeConfirm,
|
|
595
|
-
onCancel: onStripeCancel,
|
|
596
|
-
returnUrl: checkoutSession?.success_url
|
|
597
|
-
}
|
|
598
|
-
)
|
|
599
|
-
] }) }),
|
|
676
|
+
]
|
|
677
|
+
}
|
|
678
|
+
) }),
|
|
600
679
|
showForm && /* @__PURE__ */ jsxs(
|
|
601
680
|
Stack,
|
|
602
681
|
{
|
|
@@ -726,6 +805,7 @@ export default function PaymentForm({
|
|
|
726
805
|
}
|
|
727
806
|
}
|
|
728
807
|
),
|
|
729
|
-
FastCheckoutConfirmDialog
|
|
808
|
+
FastCheckoutConfirmDialog,
|
|
809
|
+
CreditInsufficientDialog
|
|
730
810
|
] });
|
|
731
811
|
}
|
package/es/payment/form/phone.js
CHANGED
|
@@ -15,8 +15,7 @@ export default function PhoneInput({ ...props }) {
|
|
|
15
15
|
const values = getValues();
|
|
16
16
|
const isUpdatingRef = useRef(false);
|
|
17
17
|
const safeUpdate = useCallback((callback) => {
|
|
18
|
-
if (isUpdatingRef.current)
|
|
19
|
-
return;
|
|
18
|
+
if (isUpdatingRef.current) return;
|
|
20
19
|
try {
|
|
21
20
|
isUpdatingRef.current = true;
|
|
22
21
|
callback();
|
|
@@ -39,8 +38,7 @@ export default function PhoneInput({ ...props }) {
|
|
|
39
38
|
});
|
|
40
39
|
const userCountry = useWatch({ control, name: countryFieldName });
|
|
41
40
|
useEffect(() => {
|
|
42
|
-
if (!userCountry || userCountry === country)
|
|
43
|
-
return;
|
|
41
|
+
if (!userCountry || userCountry === country) return;
|
|
44
42
|
safeUpdate(() => {
|
|
45
43
|
setCountry(userCountry);
|
|
46
44
|
});
|
|
@@ -5,7 +5,7 @@ export type StripeCheckoutFormProps = {
|
|
|
5
5
|
customer: TCustomer;
|
|
6
6
|
mode: string;
|
|
7
7
|
onConfirm: Function;
|
|
8
|
-
returnUrl
|
|
8
|
+
returnUrl?: string;
|
|
9
9
|
};
|
|
10
10
|
export type StripeCheckoutProps = {
|
|
11
11
|
clientSecret: string;
|
|
@@ -17,10 +17,4 @@ export type StripeCheckoutProps = {
|
|
|
17
17
|
onCancel: Function;
|
|
18
18
|
returnUrl?: string;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
declare namespace StripeCheckout {
|
|
22
|
-
var defaultProps: {
|
|
23
|
-
returnUrl: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export default StripeCheckout;
|
|
20
|
+
export default function StripeCheckout({ clientSecret, intentType, publicKey, mode, customer, onConfirm, onCancel, returnUrl, }: StripeCheckoutProps): import("react").JSX.Element;
|
|
@@ -79,6 +79,7 @@ function StripeCheckoutForm({
|
|
|
79
79
|
setState({ message: t("paymentCredit.preparePayMessage.processing") });
|
|
80
80
|
break;
|
|
81
81
|
case "requires_payment_method":
|
|
82
|
+
// 忽略该状态
|
|
82
83
|
default:
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
@@ -304,6 +305,3 @@ export default function StripeCheckout({
|
|
|
304
305
|
}
|
|
305
306
|
);
|
|
306
307
|
}
|
|
307
|
-
StripeCheckout.defaultProps = {
|
|
308
|
-
returnUrl: ""
|
|
309
|
-
};
|
package/es/payment/header.js
CHANGED
|
@@ -18,20 +18,42 @@ export default function PaymentHeader({ checkoutSession }) {
|
|
|
18
18
|
}
|
|
19
19
|
return false;
|
|
20
20
|
}, [domSize, theme]);
|
|
21
|
-
return /* @__PURE__ */ jsxs(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
return /* @__PURE__ */ jsxs(
|
|
22
|
+
Stack,
|
|
23
|
+
{
|
|
24
|
+
className: "cko-header",
|
|
25
|
+
direction: "row",
|
|
26
|
+
spacing: 1,
|
|
27
|
+
sx: {
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "space-between"
|
|
30
|
+
},
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsxs(
|
|
33
|
+
Stack,
|
|
34
|
+
{
|
|
35
|
+
direction: "row",
|
|
36
|
+
spacing: 1,
|
|
37
|
+
sx: {
|
|
38
|
+
alignItems: "center"
|
|
39
|
+
},
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
Avatar,
|
|
43
|
+
{
|
|
44
|
+
variant: "square",
|
|
45
|
+
src: window.blocklet.appLogo,
|
|
46
|
+
sx: { width: 32, height: 32 },
|
|
47
|
+
alt: window.blocklet?.appName || "Logo"
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsx(Typography, { sx: { color: "text.primary", fontWeight: 600 }, children: brand }),
|
|
51
|
+
!livemode && /* @__PURE__ */ jsx(Livemode, {})
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
isColumnLayout ? /* @__PURE__ */ jsx(UserButtons, {}) : null
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
);
|
|
37
59
|
}
|
package/es/payment/index.d.ts
CHANGED
|
@@ -6,16 +6,9 @@ type Props = CheckoutContext & CheckoutCallbacks & {
|
|
|
6
6
|
error?: any;
|
|
7
7
|
showCheckoutSummary?: boolean;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
declare namespace Payment {
|
|
11
|
-
var defaultProps: {
|
|
12
|
-
completed: boolean;
|
|
13
|
-
error: null;
|
|
14
|
-
showCheckoutSummary: boolean;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export default Payment;
|
|
9
|
+
export default function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, error, mode, onPaid, onError, onChange, goBack, action, showCheckoutSummary, }: Props): import("react").JSX.Element;
|
|
18
10
|
type RootProps = {
|
|
19
11
|
mode: LiteralUnion<'standalone' | 'inline' | 'popup', string>;
|
|
20
12
|
} & BoxProps;
|
|
21
13
|
export declare const Root: React.FC<RootProps>;
|
|
14
|
+
export {};
|
package/es/payment/index.js
CHANGED
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
getQueryParams,
|
|
19
19
|
getStatementDescriptor,
|
|
20
20
|
isMobileSafari,
|
|
21
|
-
isValidCountry
|
|
21
|
+
isValidCountry,
|
|
22
|
+
showStaking
|
|
22
23
|
} from "../libs/util.js";
|
|
23
24
|
import PaymentError from "./error.js";
|
|
24
25
|
import CheckoutFooter from "./footer.js";
|
|
@@ -30,17 +31,13 @@ import PaymentSummary from "./summary.js";
|
|
|
30
31
|
import { useMobile } from "../hooks/mobile.js";
|
|
31
32
|
import { formatPhone } from "../libs/phone-validator.js";
|
|
32
33
|
import { getCurrencyPreference } from "../libs/currency.js";
|
|
33
|
-
PaymentInner.defaultProps = {
|
|
34
|
-
completed: false,
|
|
35
|
-
showCheckoutSummary: true
|
|
36
|
-
};
|
|
37
34
|
function PaymentInner({
|
|
38
35
|
checkoutSession,
|
|
39
36
|
paymentMethods,
|
|
40
37
|
paymentLink,
|
|
41
38
|
paymentIntent,
|
|
42
39
|
customer,
|
|
43
|
-
completed,
|
|
40
|
+
completed = false,
|
|
44
41
|
mode,
|
|
45
42
|
onPaid,
|
|
46
43
|
onError,
|
|
@@ -170,6 +167,18 @@ function PaymentInner({
|
|
|
170
167
|
Toast.error(formatError(err));
|
|
171
168
|
}
|
|
172
169
|
};
|
|
170
|
+
const onQuantityChange = async (itemId, quantity) => {
|
|
171
|
+
try {
|
|
172
|
+
const { data } = await api.put(`/api/checkout-sessions/${state.checkoutSession.id}/adjust-quantity`, {
|
|
173
|
+
itemId,
|
|
174
|
+
quantity
|
|
175
|
+
});
|
|
176
|
+
setState({ checkoutSession: data });
|
|
177
|
+
} catch (err) {
|
|
178
|
+
console.error(err);
|
|
179
|
+
Toast.error(formatError(err));
|
|
180
|
+
}
|
|
181
|
+
};
|
|
173
182
|
const onCancelCrossSell = async () => {
|
|
174
183
|
try {
|
|
175
184
|
const { data } = await api.delete(`/api/checkout-sessions/${state.checkoutSession.id}/cross-sell`);
|
|
@@ -215,17 +224,19 @@ function PaymentInner({
|
|
|
215
224
|
// @ts-ignore
|
|
216
225
|
state.checkoutSession.subscription_data?.min_stake_amount || 0
|
|
217
226
|
),
|
|
218
|
-
showStaking: method
|
|
227
|
+
showStaking: showStaking(method, currency, !!state.checkoutSession.subscription_data?.no_stake),
|
|
219
228
|
currency,
|
|
220
229
|
onUpsell,
|
|
221
230
|
onDownsell,
|
|
231
|
+
onQuantityChange,
|
|
222
232
|
onApplyCrossSell,
|
|
223
233
|
onCancelCrossSell,
|
|
224
234
|
onChangeAmount,
|
|
225
235
|
checkoutSessionId: state.checkoutSession.id,
|
|
226
236
|
crossSellBehavior: state.checkoutSession.cross_sell_behavior,
|
|
227
237
|
donationSettings: paymentLink?.donation_settings,
|
|
228
|
-
action
|
|
238
|
+
action,
|
|
239
|
+
completed
|
|
229
240
|
}
|
|
230
241
|
),
|
|
231
242
|
mode === "standalone" && !isMobile && /* @__PURE__ */ jsx(CheckoutFooter, { className: "cko-footer", sx: { color: "text.lighter" } })
|
|
@@ -275,19 +286,14 @@ function PaymentInner({
|
|
|
275
286
|
mode === "standalone" && isMobile && /* @__PURE__ */ jsx(CheckoutFooter, { className: "cko-footer", sx: { color: "text.lighter" } })
|
|
276
287
|
] }) });
|
|
277
288
|
}
|
|
278
|
-
Payment.defaultProps = {
|
|
279
|
-
completed: false,
|
|
280
|
-
error: null,
|
|
281
|
-
showCheckoutSummary: true
|
|
282
|
-
};
|
|
283
289
|
export default function Payment({
|
|
284
290
|
checkoutSession,
|
|
285
291
|
paymentMethods,
|
|
286
292
|
paymentIntent,
|
|
287
293
|
paymentLink,
|
|
288
294
|
customer,
|
|
289
|
-
completed,
|
|
290
|
-
error,
|
|
295
|
+
completed = false,
|
|
296
|
+
error = null,
|
|
291
297
|
mode,
|
|
292
298
|
onPaid,
|
|
293
299
|
onError,
|
|
@@ -366,9 +372,9 @@ export default function Payment({
|
|
|
366
372
|
return /* @__PURE__ */ jsxs(
|
|
367
373
|
Stack,
|
|
368
374
|
{
|
|
369
|
-
display: "flex",
|
|
370
|
-
flexDirection: "column",
|
|
371
375
|
sx: {
|
|
376
|
+
display: "flex",
|
|
377
|
+
flexDirection: "column",
|
|
372
378
|
height: mode === "standalone" ? "100vh" : "auto",
|
|
373
379
|
overflow: isMobileSafariEnv ? "visible" : "hidden"
|
|
374
380
|
},
|
|
@@ -7,14 +7,5 @@ type Props = {
|
|
|
7
7
|
extra?: React.ReactNode;
|
|
8
8
|
variant?: LiteralUnion<'square' | 'rounded' | 'circular', string>;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var defaultProps: {
|
|
13
|
-
logo: string;
|
|
14
|
-
size: number;
|
|
15
|
-
description: string;
|
|
16
|
-
variant: string;
|
|
17
|
-
extra: undefined;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export default ProductCard;
|
|
10
|
+
export default function ProductCard({ size, variant, name, logo, description, extra, }: Props): import("react").JSX.Element;
|
|
11
|
+
export {};
|