@blocklet/payment-react 1.18.30 → 1.18.32

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.
Files changed (43) hide show
  1. package/es/checkout/donate.js +51 -23
  2. package/es/components/country-select.js +1 -0
  3. package/es/components/over-due-invoice-payment.js +43 -5
  4. package/es/libs/util.d.ts +1 -0
  5. package/es/libs/util.js +15 -2
  6. package/es/locales/en.js +2 -1
  7. package/es/locales/zh.js +2 -1
  8. package/es/payment/form/currency.d.ts +1 -1
  9. package/es/payment/form/currency.js +3 -3
  10. package/es/payment/form/index.d.ts +1 -1
  11. package/es/payment/form/index.js +19 -35
  12. package/es/payment/form/stripe/form.js +4 -2
  13. package/es/payment/index.js +10 -1
  14. package/es/payment/success.d.ts +3 -1
  15. package/es/payment/success.js +78 -6
  16. package/lib/checkout/donate.js +19 -11
  17. package/lib/components/country-select.js +1 -0
  18. package/lib/components/over-due-invoice-payment.js +42 -4
  19. package/lib/libs/util.d.ts +1 -0
  20. package/lib/libs/util.js +16 -2
  21. package/lib/locales/en.js +2 -1
  22. package/lib/locales/zh.js +2 -1
  23. package/lib/payment/form/currency.d.ts +1 -1
  24. package/lib/payment/form/currency.js +3 -3
  25. package/lib/payment/form/index.d.ts +1 -1
  26. package/lib/payment/form/index.js +20 -35
  27. package/lib/payment/form/stripe/form.js +4 -2
  28. package/lib/payment/index.js +10 -1
  29. package/lib/payment/success.d.ts +3 -1
  30. package/lib/payment/success.js +68 -15
  31. package/package.json +8 -8
  32. package/src/checkout/donate.tsx +23 -5
  33. package/src/components/country-select.tsx +1 -0
  34. package/src/components/over-due-invoice-payment.tsx +46 -4
  35. package/src/libs/util.ts +17 -2
  36. package/src/locales/en.tsx +1 -0
  37. package/src/locales/zh.tsx +1 -0
  38. package/src/payment/form/currency.tsx +4 -4
  39. package/src/payment/form/index.tsx +21 -47
  40. package/src/payment/form/stripe/form.tsx +4 -2
  41. package/src/payment/index.tsx +12 -1
  42. package/src/payment/success.tsx +73 -11
  43. package/src/payment/summary.tsx +1 -0
@@ -296,17 +296,31 @@ function SupporterSimple({ supporters = [], totalAmount = "0", currency, method
296
296
  symbol: currency.symbol,
297
297
  totalAmount: formatAmount(totalAmount || "0", currency.decimal)
298
298
  }) }),
299
- /* @__PURE__ */ jsx(AvatarGroup, { total: customersNum, max: 10, children: customers.map((x) => /* @__PURE__ */ jsx(
300
- Avatar,
299
+ /* @__PURE__ */ jsx(
300
+ AvatarGroup,
301
301
  {
302
- title: x.customer?.name,
303
- alt: x.customer?.metadata?.anonymous ? "" : x.customer?.name,
304
- src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
305
- variant: "circular",
306
- sx: { width: 24, height: 24 }
307
- },
308
- x.id
309
- )) })
302
+ total: customersNum,
303
+ max: 10,
304
+ spacing: 4,
305
+ sx: {
306
+ "& .MuiAvatar-root": {
307
+ width: 24,
308
+ height: 24,
309
+ fontSize: "0.6rem"
310
+ }
311
+ },
312
+ children: customers.map((x) => /* @__PURE__ */ jsx(
313
+ Avatar,
314
+ {
315
+ title: x.customer?.name,
316
+ alt: x.customer?.metadata?.anonymous ? "" : x.customer?.name,
317
+ src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
318
+ variant: "circular"
319
+ },
320
+ x.id
321
+ ))
322
+ }
323
+ )
310
324
  ]
311
325
  }
312
326
  );
@@ -593,20 +607,34 @@ function CheckoutDonateInner({
593
607
  ] }),
594
608
  maxWidth: "md",
595
609
  toolbar: isMobile ? null : /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", gap: 1, sx: { color: "text.secondary" }, children: [
596
- /* @__PURE__ */ jsx(AvatarGroup, { total: customers?.length, max: 5, children: customers.map((x) => /* @__PURE__ */ jsx(
597
- Avatar,
610
+ /* @__PURE__ */ jsx(
611
+ AvatarGroup,
598
612
  {
599
- title: x.customer?.name,
600
- src: getCustomerAvatar(
601
- x.customer?.did,
602
- x?.updated_at ? new Date(x.updated_at).toISOString() : "",
603
- 18
604
- ),
605
- variant: "circular",
606
- sx: { width: 18, height: 18 }
607
- },
608
- x.id
609
- )) }),
613
+ total: customers?.length,
614
+ max: 5,
615
+ spacing: 4,
616
+ sx: {
617
+ "& .MuiAvatar-root": {
618
+ width: 18,
619
+ height: 18,
620
+ fontSize: "0.6rem"
621
+ }
622
+ },
623
+ children: customers.map((x) => /* @__PURE__ */ jsx(
624
+ Avatar,
625
+ {
626
+ title: x.customer?.name,
627
+ src: getCustomerAvatar(
628
+ x.customer?.did,
629
+ x?.updated_at ? new Date(x.updated_at).toISOString() : "",
630
+ 24
631
+ ),
632
+ variant: "circular"
633
+ },
634
+ x.id
635
+ ))
636
+ }
637
+ ),
610
638
  customers?.length > 0 && t("payment.checkout.donation.gaveTips", { count: customers?.length })
611
639
  ] }),
612
640
  showCloseButton: false,
@@ -194,6 +194,7 @@ const CountrySelect = forwardRef(({ value, onChange, name, sx }, ref) => {
194
194
  },
195
195
  sx: {
196
196
  width: "100%",
197
+ minWidth: "60px",
197
198
  fieldset: {
198
199
  display: "none"
199
200
  },
@@ -1,10 +1,11 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useState } from "react";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Button, Typography, Stack, Alert } from "@mui/material";
4
4
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
5
5
  import Toast from "@arcblock/ux/lib/Toast";
6
6
  import { joinURL } from "ufo";
7
7
  import { useRequest } from "ahooks";
8
+ import pWaitFor from "p-wait-for";
8
9
  import { Dialog } from "@arcblock/ux";
9
10
  import { CheckCircle as CheckCircleIcon } from "@mui/icons-material";
10
11
  import debounce from "lodash/debounce";
@@ -49,6 +50,7 @@ function OverdueInvoicePayment({
49
50
  const sourceType = subscriptionId ? "subscription" : "customer";
50
51
  const effectiveCustomerId = customerId || session?.user?.did;
51
52
  const sourceId = subscriptionId || effectiveCustomerId;
53
+ const customerIdRef = useRef(effectiveCustomerId);
52
54
  const {
53
55
  data = {
54
56
  summary: {},
@@ -58,7 +60,12 @@ function OverdueInvoicePayment({
58
60
  loading,
59
61
  runAsync: refresh
60
62
  } = useRequest(() => fetchOverdueInvoices({ subscriptionId, customerId: effectiveCustomerId, authToken }), {
61
- ready: !!subscriptionId || !!effectiveCustomerId
63
+ ready: !!subscriptionId || !!effectiveCustomerId,
64
+ onSuccess: (res) => {
65
+ if (res.customer?.id && res.customer?.id !== customerIdRef.current) {
66
+ customerIdRef.current = res.customer?.id;
67
+ }
68
+ }
62
69
  });
63
70
  const detailUrl = useMemo(() => {
64
71
  if (subscriptionId) {
@@ -95,13 +102,43 @@ function OverdueInvoicePayment({
95
102
  maxWait: 5e3
96
103
  }
97
104
  );
105
+ const isCrossOriginRequest = isCrossOrigin();
98
106
  const subscription = useSubscription("events");
107
+ const waitForInvoiceAllPaid = async () => {
108
+ let isPaid = false;
109
+ await pWaitFor(
110
+ async () => {
111
+ const res = await refresh();
112
+ isPaid = res.invoices?.length === 0;
113
+ return isPaid;
114
+ },
115
+ { interval: 2e3, timeout: 3 * 60 * 1e3 }
116
+ );
117
+ return isPaid;
118
+ };
119
+ const handleConnected = async () => {
120
+ if (isCrossOriginRequest) {
121
+ try {
122
+ const paid = await waitForInvoiceAllPaid();
123
+ if (successToast) {
124
+ Toast.close();
125
+ Toast.success(t("payment.customer.invoice.paySuccess"));
126
+ }
127
+ if (paid) {
128
+ setDialogOpen(false);
129
+ onPaid(sourceId, selectCurrencyId, sourceType);
130
+ }
131
+ } catch (err) {
132
+ console.error("Check payment status failed:", err);
133
+ }
134
+ }
135
+ };
99
136
  useEffect(() => {
100
- if (subscription) {
137
+ if (subscription && !isCrossOriginRequest) {
101
138
  subscription.on("invoice.paid", ({ response }) => {
102
139
  const relevantId = subscriptionId || response.customer_id;
103
140
  const uniqueKey = `${relevantId}-${response.currency_id}`;
104
- if (subscriptionId && response.subscription_id === subscriptionId || effectiveCustomerId && [data.customer?.id, effectiveCustomerId].includes(response.customer_id)) {
141
+ if (subscriptionId && response.subscription_id === subscriptionId || effectiveCustomerId && effectiveCustomerId === response.customer_id || customerIdRef.current && customerIdRef.current === response.customer_id) {
105
142
  if (!processedCurrencies[uniqueKey]) {
106
143
  setProcessedCurrencies((prev) => ({ ...prev, [uniqueKey]: 1 }));
107
144
  debouncedHandleInvoicePaid(response.currency_id);
@@ -137,10 +174,11 @@ function OverdueInvoicePayment({
137
174
  saveConnect: false,
138
175
  action: "collect-batch",
139
176
  prefix: joinURL(getPrefix(), "/api/did"),
140
- useSocket: isCrossOrigin() === false,
177
+ useSocket: !isCrossOriginRequest,
141
178
  extraParams,
142
179
  onSuccess: () => {
143
180
  connect.close();
181
+ handleConnected();
144
182
  setPayLoading(false);
145
183
  setPaymentStatus((prev) => ({
146
184
  ...prev,
package/es/libs/util.d.ts CHANGED
@@ -50,6 +50,7 @@ export declare function formatPriceDisplay({ amount, then, actualAmount, showThe
50
50
  actualAmount: string;
51
51
  showThen?: boolean;
52
52
  }, recurring: string, hasMetered: boolean, locale?: string): string;
53
+ export declare function hasMultipleRecurringIntervals(items: TLineItemExpanded[]): boolean;
53
54
  export declare function getFreeTrialTime({ trialInDays, trialEnd }: {
54
55
  trialInDays: number;
55
56
  trialEnd: number;
package/es/libs/util.js CHANGED
@@ -439,6 +439,18 @@ export function formatPriceDisplay({ amount, then, actualAmount, showThen }, rec
439
439
  }
440
440
  return [amount, then].filter(Boolean).join(" ");
441
441
  }
442
+ export function hasMultipleRecurringIntervals(items) {
443
+ const intervals = /* @__PURE__ */ new Set();
444
+ for (const item of items) {
445
+ if (item.price?.recurring?.interval && item.price?.type === "recurring") {
446
+ intervals.add(`${item.price.recurring.interval}-${item.price.recurring.interval_count}`);
447
+ if (intervals.size > 1) {
448
+ return true;
449
+ }
450
+ }
451
+ }
452
+ return false;
453
+ }
442
454
  export function getFreeTrialTime({ trialInDays, trialEnd }, locale = "en") {
443
455
  const now = dayjs().unix();
444
456
  if (trialEnd > 0 && trialEnd > now) {
@@ -501,6 +513,7 @@ export function formatCheckoutHeadlines(items, currency, { trialInDays, trialEnd
501
513
  locale
502
514
  );
503
515
  const hasMetered = items.some((x) => x.price.type === "recurring" && x.price.recurring?.usage_type === "metered");
516
+ const differentRecurring = hasMultipleRecurringIntervals(items);
504
517
  if (items.every((x) => x.price.type === "recurring")) {
505
518
  const subscription2 = [
506
519
  hasMetered ? t("payment.checkout.least", locale) : "",
@@ -560,7 +573,7 @@ export function formatCheckoutHeadlines(items, currency, { trialInDays, trialEnd
560
573
  action: t("payment.checkout.sub1", locale, { name }),
561
574
  amount,
562
575
  then: hasMetered ? t("payment.checkout.meteredThen", locale, { recurring }) : recurring,
563
- showThen: hasMetered,
576
+ showThen: hasMetered && !differentRecurring,
564
577
  actualAmount
565
578
  };
566
579
  return {
@@ -586,7 +599,7 @@ export function formatCheckoutHeadlines(items, currency, { trialInDays, trialEnd
586
599
  hasMetered && Number(subscription) === 0,
587
600
  locale
588
601
  ),
589
- showThen: true,
602
+ showThen: !differentRecurring,
590
603
  actualAmount
591
604
  };
592
605
  return {
package/es/locales/en.js CHANGED
@@ -115,7 +115,8 @@ export default flat({
115
115
  login: "Login to load and save contact information",
116
116
  next: {
117
117
  subscription: "View subscription",
118
- invoice: "View invoice"
118
+ invoice: "View invoice",
119
+ view: "View"
119
120
  },
120
121
  paymentRequired: "Payment Required",
121
122
  staking: {
package/es/locales/zh.js CHANGED
@@ -115,7 +115,8 @@ export default flat({
115
115
  login: "\u767B\u5F55\u4EE5\u52A0\u8F7D\u5E76\u4FDD\u5B58\u8054\u7CFB\u4FE1\u606F",
116
116
  next: {
117
117
  subscription: "\u67E5\u770B\u8BA2\u9605",
118
- invoice: "\u67E5\u770B\u8D26\u5355"
118
+ invoice: "\u67E5\u770B\u8D26\u5355",
119
+ view: "\u67E5\u770B"
119
120
  },
120
121
  paymentRequired: "\u652F\u4ED8\u91D1\u989D",
121
122
  staking: {
@@ -1,6 +1,6 @@
1
1
  import type { TPaymentCurrency } from '@blocklet/payment-types';
2
2
  type Props = {
3
- value: number;
3
+ value: string;
4
4
  currencies: TPaymentCurrency[];
5
5
  onChange: Function;
6
6
  };
@@ -12,13 +12,13 @@ export default function CurrencySelector({ value, currencies, onChange }) {
12
12
  gap: 12,
13
13
  gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))"
14
14
  },
15
- children: currencies.map((x, i) => {
16
- const selected = i === value;
15
+ children: currencies.map((x) => {
16
+ const selected = x.id === value;
17
17
  return /* @__PURE__ */ jsx(
18
18
  Card,
19
19
  {
20
20
  variant: "outlined",
21
- onClick: () => onChange(i),
21
+ onClick: () => onChange(x.id, x.method?.id),
22
22
  className: selected ? "cko-payment-card" : "cko-payment-card-unselect",
23
23
  children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", sx: { position: "relative" }, children: [
24
24
  /* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width: 40, height: 40, marginRight: "12px" } }),
@@ -6,7 +6,7 @@ type PageData = CheckoutContext & CheckoutCallbacks & {
6
6
  onlyShowBtn?: boolean;
7
7
  isDonation?: boolean;
8
8
  };
9
- declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, currencyId, onlyShowBtn, isDonation, }: PageData): import("react").JSX.Element;
9
+ declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, onlyShowBtn, isDonation, }: PageData): import("react").JSX.Element;
10
10
  declare namespace PaymentForm {
11
11
  var defaultProps: {
12
12
  onlyShowBtn: boolean;
@@ -5,7 +5,7 @@ import Toast from "@arcblock/ux/lib/Toast";
5
5
  import { Box, Button, CircularProgress, Divider, Fade, FormLabel, Stack, Typography } from "@mui/material";
6
6
  import { useMemoizedFn, useSetState } from "ahooks";
7
7
  import pWaitFor from "p-wait-for";
8
- import { useEffect, useMemo, useRef, useState } from "react";
8
+ import { useEffect, useMemo, useRef } from "react";
9
9
  import { Controller, useFormContext, useWatch } from "react-hook-form";
10
10
  import { joinURL } from "ufo";
11
11
  import { dispatch } from "use-bus";
@@ -20,7 +20,6 @@ import {
20
20
  formatError,
21
21
  formatQuantityInventory,
22
22
  getPrefix,
23
- getQueryParams,
24
23
  getStatementDescriptor,
25
24
  isCrossOrigin
26
25
  } from "../../libs/util.js";
@@ -94,7 +93,6 @@ export default function PaymentForm({
94
93
  onError,
95
94
  // mode,
96
95
  action,
97
- currencyId,
98
96
  onlyShowBtn,
99
97
  isDonation = false
100
98
  }) {
@@ -131,33 +129,14 @@ export default function PaymentForm({
131
129
  stripePaying: false
132
130
  });
133
131
  const currencies = flattenPaymentMethods(paymentMethods);
134
- const [paymentCurrencyIndex, setPaymentCurrencyIndex] = useState(() => {
135
- const query = getQueryParams(window.location.href);
136
- const queryCurrencyId = query.currencyId || currencyId;
137
- const index = currencies.findIndex((x) => x.id === queryCurrencyId);
138
- return index >= 0 ? index : 0;
139
- });
140
- const handleCurrencyChange = (index) => {
141
- setPaymentCurrencyIndex(index);
142
- const selectedCurrencyId = currencies[index]?.id;
143
- if (selectedCurrencyId) {
144
- saveCurrencyPreference(selectedCurrencyId, session?.user?.did);
145
- }
146
- };
147
132
  const onCheckoutComplete = useMemoizedFn(async ({ response }) => {
148
133
  if (response.id === checkoutSession.id && state.paid === false) {
149
134
  await handleConnected();
150
135
  }
151
136
  });
152
- const onInvoicePaid = useMemoizedFn(async ({ response }) => {
153
- if (response.customer_id === customer?.id && state.customerLimited) {
154
- await onAction();
155
- }
156
- });
157
137
  useEffect(() => {
158
138
  if (subscription) {
159
139
  subscription.on("checkout.session.completed", onCheckoutComplete);
160
- subscription.on("invoice.paid", onInvoicePaid);
161
140
  }
162
141
  }, [subscription]);
163
142
  const mergeUserInfo = (customerInfo, userInfo) => {
@@ -224,10 +203,6 @@ export default function PaymentForm({
224
203
  };
225
204
  initUserInfo();
226
205
  }, [session?.user, checkoutSession.phone_number_collection?.enabled]);
227
- useEffect(() => {
228
- setValue("payment_method", currencies[paymentCurrencyIndex]?.method?.id);
229
- setValue("payment_currency", currencies[paymentCurrencyIndex]?.id);
230
- }, [paymentCurrencyIndex, currencies, setValue]);
231
206
  const paymentMethod = useWatch({ control, name: "payment_method" });
232
207
  const afterUserLoggedIn = useMemoizedFn(() => {
233
208
  if (hasDidWallet(session.user) || skipBindWallet) {
@@ -326,6 +301,11 @@ export default function PaymentForm({
326
301
  console.error(err);
327
302
  setState({ submitting: false, paying: false });
328
303
  onError(err);
304
+ },
305
+ messages: {
306
+ title: "DID Connect",
307
+ scan: "Use following methods to complete this payment",
308
+ confirm: "Confirm"
329
309
  }
330
310
  });
331
311
  }
@@ -373,13 +353,13 @@ export default function PaymentForm({
373
353
  }
374
354
  if (hasDidWallet(session.user)) {
375
355
  handleSubmit(onFormSubmit, onFormError)();
376
- } else {
377
- session.bindWallet(() => {
378
- setTimeout(() => {
379
- handleSubmit(onFormSubmit, onFormError)();
380
- }, 2e3);
381
- });
356
+ return;
382
357
  }
358
+ session.bindWallet(() => {
359
+ setTimeout(() => {
360
+ handleSubmit(onFormSubmit, onFormError)();
361
+ }, 2e3);
362
+ });
383
363
  } else {
384
364
  if (isDonationMode) {
385
365
  handleSubmit(onFormSubmit, onFormError)();
@@ -491,12 +471,16 @@ export default function PaymentForm({
491
471
  {
492
472
  name: "payment_currency",
493
473
  control,
494
- render: () => /* @__PURE__ */ jsx(
474
+ render: ({ field }) => /* @__PURE__ */ jsx(
495
475
  CurrencySelector,
496
476
  {
497
- value: paymentCurrencyIndex,
477
+ value: field.value,
498
478
  currencies,
499
- onChange: handleCurrencyChange
479
+ onChange: (id, methodId) => {
480
+ field.onChange(id);
481
+ setValue("payment_method", methodId);
482
+ saveCurrencyPreference(id, session?.user?.did);
483
+ }
500
484
  }
501
485
  )
502
486
  }
@@ -144,11 +144,13 @@ function StripeCheckoutForm({
144
144
  // eslint-disable-line
145
145
  );
146
146
  return /* @__PURE__ */ jsxs(Content, { onSubmit: handleSubmit, children: [
147
- (!state.paymentMethod || state.paymentMethod === "card") && /* @__PURE__ */ jsx(
147
+ (!state.paymentMethod || ["link", "card"].includes(state.paymentMethod)) && /* @__PURE__ */ jsx(
148
148
  LinkAuthenticationElement,
149
149
  {
150
150
  options: {
151
- defaultEmail: customer.email
151
+ defaultValues: {
152
+ email: customer.email
153
+ }
152
154
  }
153
155
  }
154
156
  ),
@@ -108,6 +108,14 @@ function PaymentInner({
108
108
  )
109
109
  }
110
110
  });
111
+ useEffect(() => {
112
+ if (defaultCurrencyId) {
113
+ methods.setValue("payment_currency", defaultCurrencyId);
114
+ }
115
+ if (defaultMethodId) {
116
+ methods.setValue("payment_method", defaultMethodId);
117
+ }
118
+ }, [defaultCurrencyId, defaultMethodId]);
111
119
  useEffect(() => {
112
120
  if (!isMobileSafari()) {
113
121
  return () => {
@@ -207,7 +215,7 @@ function PaymentInner({
207
215
  // @ts-ignore
208
216
  state.checkoutSession.subscription_data?.min_stake_amount || 0
209
217
  ),
210
- showStaking: method.type === "arcblock",
218
+ showStaking: method.type === "arcblock" && !state.checkoutSession.subscription_data?.no_stake,
211
219
  currency,
212
220
  onUpsell,
213
221
  onDownsell,
@@ -240,6 +248,7 @@ function PaymentInner({
240
248
  action: state.checkoutSession.mode,
241
249
  invoiceId: state.checkoutSession.invoice_id,
242
250
  subscriptionId: state.checkoutSession.subscription_id,
251
+ subscriptions: state.checkoutSession.subscriptions,
243
252
  message: paymentLink?.after_completion?.hosted_confirmation?.custom_message || t(
244
253
  `payment.checkout.completed.${state.checkoutSession.submit_type === "donate" ? "donate" : state.checkoutSession.mode}`
245
254
  )
@@ -5,12 +5,14 @@ type Props = {
5
5
  payee: string;
6
6
  invoiceId?: string;
7
7
  subscriptionId?: string;
8
+ subscriptions?: any[];
8
9
  };
9
- declare function PaymentSuccess({ mode, message, action, payee, invoiceId, subscriptionId }: Props): import("react").JSX.Element;
10
+ declare function PaymentSuccess({ mode, message, action, payee, invoiceId, subscriptionId, subscriptions, }: Props): import("react").JSX.Element;
10
11
  declare namespace PaymentSuccess {
11
12
  var defaultProps: {
12
13
  invoiceId: string;
13
14
  subscriptionId: string;
15
+ subscriptions: never[];
14
16
  };
15
17
  }
16
18
  export default PaymentSuccess;
@@ -1,15 +1,86 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
3
- import { Grow, Link, Stack, Typography } from "@mui/material";
3
+ import { Grow, Link, Stack, Typography, Box, Paper } from "@mui/material";
4
4
  import { styled } from "@mui/system";
5
5
  import { joinURL } from "ufo";
6
+ import { Button } from "@arcblock/ux";
6
7
  import { usePaymentContext } from "../contexts/payment.js";
7
- export default function PaymentSuccess({ mode, message, action, payee, invoiceId, subscriptionId }) {
8
+ export default function PaymentSuccess({
9
+ mode,
10
+ message,
11
+ action,
12
+ payee,
13
+ invoiceId,
14
+ subscriptionId,
15
+ subscriptions
16
+ }) {
8
17
  const { t } = useLocaleContext();
9
18
  const { prefix } = usePaymentContext();
10
19
  let next = null;
11
- if (["subscription", "setup"].includes(action) && subscriptionId) {
12
- next = /* @__PURE__ */ jsx(Typography, { textAlign: "center", sx: { mt: 2 }, children: /* @__PURE__ */ jsx(Link, { href: joinURL(prefix, `/customer/subscription/${subscriptionId}`), children: t("payment.checkout.next.subscription", { payee }) }) });
20
+ if (["subscription", "setup"].includes(action)) {
21
+ if (subscriptions && subscriptions.length > 1) {
22
+ next = /* @__PURE__ */ jsx(
23
+ Paper,
24
+ {
25
+ elevation: 0,
26
+ sx: {
27
+ p: 3,
28
+ backgroundColor: "grey.50",
29
+ borderRadius: 2,
30
+ width: "100%",
31
+ mt: 2,
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ gap: 2
35
+ },
36
+ children: subscriptions.map((subscription) => /* @__PURE__ */ jsxs(
37
+ Box,
38
+ {
39
+ sx: {
40
+ display: "flex",
41
+ alignItems: "center",
42
+ justifyContent: "space-between"
43
+ },
44
+ children: [
45
+ /* @__PURE__ */ jsx(
46
+ Typography,
47
+ {
48
+ variant: "body2",
49
+ sx: {
50
+ color: "text.secondary",
51
+ fontWeight: 500
52
+ },
53
+ children: subscription.description
54
+ }
55
+ ),
56
+ /* @__PURE__ */ jsx(
57
+ Box,
58
+ {
59
+ sx: {
60
+ flex: 1,
61
+ borderBottom: "1px dashed",
62
+ borderColor: "grey.300",
63
+ mx: 2
64
+ }
65
+ }
66
+ ),
67
+ /* @__PURE__ */ jsx(Button, { variant: "text", color: "primary", size: "small", children: /* @__PURE__ */ jsx(
68
+ Link,
69
+ {
70
+ href: joinURL(prefix, `/customer/subscription/${subscription.id}`),
71
+ sx: { color: "text.secondary" },
72
+ children: t("payment.checkout.next.view")
73
+ }
74
+ ) })
75
+ ]
76
+ },
77
+ subscription.id
78
+ ))
79
+ }
80
+ );
81
+ } else if (subscriptionId) {
82
+ next = /* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", sx: { mt: 2 }, children: /* @__PURE__ */ jsx(Link, { href: joinURL(prefix, `/customer/subscription/${subscriptionId}`), children: t("payment.checkout.next.subscription", { payee }) }) });
83
+ }
13
84
  } else if (invoiceId) {
14
85
  next = /* @__PURE__ */ jsx(Typography, { textAlign: "center", sx: { mt: 2 }, children: /* @__PURE__ */ jsx(Link, { href: joinURL(prefix, `/customer/invoice/${invoiceId}`), children: t("payment.checkout.next.invoice", { payee }) }) });
15
86
  }
@@ -19,7 +90,7 @@ export default function PaymentSuccess({ mode, message, action, payee, invoiceId
19
90
  direction: "column",
20
91
  alignItems: "center",
21
92
  justifyContent: mode === "standalone" ? "center" : "flex-start",
22
- sx: { height: mode === "standalone" ? 360 : 300 },
93
+ sx: { height: mode === "standalone" ? "fit-content" : 300 },
23
94
  children: [
24
95
  /* @__PURE__ */ jsx(Div, { children: /* @__PURE__ */ jsxs("div", { className: "check-icon", children: [
25
96
  /* @__PURE__ */ jsx("span", { className: "icon-line line-tip" }),
@@ -36,7 +107,8 @@ export default function PaymentSuccess({ mode, message, action, payee, invoiceId
36
107
  }
37
108
  PaymentSuccess.defaultProps = {
38
109
  invoiceId: "",
39
- subscriptionId: ""
110
+ subscriptionId: "",
111
+ subscriptions: []
40
112
  };
41
113
  const Div = styled("div")`
42
114
  width: 80px;
@@ -314,15 +314,19 @@ function SupporterSimple({
314
314
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.AvatarGroup, {
315
315
  total: customersNum,
316
316
  max: 10,
317
+ spacing: 4,
318
+ sx: {
319
+ "& .MuiAvatar-root": {
320
+ width: 24,
321
+ height: 24,
322
+ fontSize: "0.6rem"
323
+ }
324
+ },
317
325
  children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
318
326
  title: x.customer?.name,
319
327
  alt: x.customer?.metadata?.anonymous ? "" : x.customer?.name,
320
328
  src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
321
- variant: "circular",
322
- sx: {
323
- width: 24,
324
- height: 24
325
- }
329
+ variant: "circular"
326
330
  }, x.id))
327
331
  })]
328
332
  });
@@ -665,14 +669,18 @@ function CheckoutDonateInner({
665
669
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.AvatarGroup, {
666
670
  total: customers?.length,
667
671
  max: 5,
668
- children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
669
- title: x.customer?.name,
670
- src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 18),
671
- variant: "circular",
672
- sx: {
672
+ spacing: 4,
673
+ sx: {
674
+ "& .MuiAvatar-root": {
673
675
  width: 18,
674
- height: 18
676
+ height: 18,
677
+ fontSize: "0.6rem"
675
678
  }
679
+ },
680
+ children: customers.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
681
+ title: x.customer?.name,
682
+ src: (0, _util.getCustomerAvatar)(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 24),
683
+ variant: "circular"
676
684
  }, x.id))
677
685
  }), customers?.length > 0 && t("payment.checkout.donation.gaveTips", {
678
686
  count: customers?.length
@@ -202,6 +202,7 @@ const CountrySelect = (0, _react.forwardRef)(({
202
202
  },
203
203
  sx: {
204
204
  width: "100%",
205
+ minWidth: "60px",
205
206
  fieldset: {
206
207
  display: "none"
207
208
  },