payment-kit 1.18.20 → 1.18.22

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/src/libs/util.ts CHANGED
@@ -21,9 +21,8 @@ import { hexToNumber } from '@ocap/util';
21
21
  import { isEmpty, isObject } from 'lodash';
22
22
  import cloneDeep from 'lodash/cloneDeep';
23
23
  import isEqual from 'lodash/isEqual';
24
- import { joinURL, withQuery } from 'ufo';
24
+ import { joinURL } from 'ufo';
25
25
 
26
- import type { LiteralUnion } from 'type-fest';
27
26
  import { t } from '../locales/index';
28
27
 
29
28
  export const formatProductPrice = (
@@ -327,22 +326,6 @@ export function getInvoiceUsageReportStartEnd(invoice: TInvoiceExpanded, showPre
327
326
  return usageReportRange;
328
327
  }
329
328
 
330
- export function getCustomerProfileUrl({
331
- locale = 'en',
332
- userDid,
333
- }: {
334
- locale: LiteralUnion<'en' | 'zh', string>;
335
- userDid: string;
336
- }) {
337
- return joinURL(
338
- getPrefix(),
339
- withQuery('.well-known/service/user', {
340
- locale,
341
- did: userDid,
342
- })
343
- );
344
- }
345
-
346
329
  export function getAppInfo(address: string): { name: string; avatar: string; type: string; url: string } | null {
347
330
  const blockletJson = window.blocklet;
348
331
  if (blockletJson) {
@@ -12,6 +12,7 @@ import {
12
12
  formatTime,
13
13
  getCustomerAvatar,
14
14
  getPayoutStatusColor,
15
+ getUserProfileLink,
15
16
  useMobile,
16
17
  } from '@blocklet/payment-react';
17
18
  import type { TCustomer, TPayoutExpanded } from '@blocklet/payment-types';
@@ -30,7 +31,7 @@ import InfoRow from '../../../../components/info-row';
30
31
  import MetadataEditor from '../../../../components/metadata/editor';
31
32
  import MetadataList from '../../../../components/metadata/list';
32
33
  import SectionHeader from '../../../../components/section/header';
33
- import { getAppInfo, getCustomerProfileUrl, goBackOrFallback } from '../../../../libs/util';
34
+ import { getAppInfo, goBackOrFallback } from '../../../../libs/util';
34
35
  import InfoCard from '../../../../components/info-card';
35
36
  import InfoRowGroup from '../../../../components/info-row-group';
36
37
 
@@ -48,7 +49,7 @@ const InfoDirection = 'column';
48
49
  const InfoAlignItems = 'flex-start';
49
50
 
50
51
  export default function PayoutDetail(props: { id: string }) {
51
- const { t } = useLocaleContext();
52
+ const { t, locale } = useLocaleContext();
52
53
  const { isMobile } = useMobile();
53
54
  const [state, setState] = useSetState({
54
55
  adding: {
@@ -227,10 +228,7 @@ export default function PayoutDetail(props: { id: string }) {
227
228
  if (isAnonymousPayer) {
228
229
  return;
229
230
  }
230
- const url = getCustomerProfileUrl({
231
- userDid: paymentIntent?.customer?.did,
232
- locale: 'zh',
233
- });
231
+ const url = getUserProfileLink(paymentIntent?.customer?.did, locale);
234
232
  window.open(url, '_blank');
235
233
  }}>
236
234
  {paymentIntent?.customer?.name}
@@ -35,7 +35,7 @@ import { styled } from '@mui/system';
35
35
  import { useRequest, useSetState } from 'ahooks';
36
36
  import { flatten, isEmpty } from 'lodash';
37
37
  import { memo, useEffect, useState } from 'react';
38
- import { useNavigate } from 'react-router-dom';
38
+ import { useNavigate, useSearchParams } from 'react-router-dom';
39
39
  import { joinURL } from 'ufo';
40
40
 
41
41
  import { useTransitionContext } from '../../components/progress-bar';
@@ -251,6 +251,8 @@ export default function CustomerHome() {
251
251
  }))
252
252
  )
253
253
  );
254
+ const [params] = useSearchParams();
255
+ const embed = params.get('embed') || sessionStorage.getItem('embed');
254
256
 
255
257
  const { livemode, setLivemode } = usePaymentContext();
256
258
  const [state, setState] = useSetState({
@@ -515,7 +517,7 @@ export default function CustomerHome() {
515
517
  color="error"
516
518
  component="a"
517
519
  size="small"
518
- href={joinURL(getPrefix(), '/customer/invoice/past-due')}
520
+ href={joinURL(getPrefix(), '/customer/invoice/past-due', `${embed === '1' ? '?embed=1' : ''}`)}
519
521
  target="_blank"
520
522
  rel="noreferrer"
521
523
  style={{ textDecoration: 'none', fontSize: 13 }}>
@@ -9,6 +9,7 @@ import {
9
9
  formatTime,
10
10
  getCustomerAvatar,
11
11
  getPayoutStatusColor,
12
+ getUserProfileLink,
12
13
  useMobile,
13
14
  } from '@blocklet/payment-react';
14
15
  import type { TCustomer, TPaymentLink, TPayoutExpanded } from '@blocklet/payment-types';
@@ -22,7 +23,7 @@ import DID from '@arcblock/ux/lib/DID';
22
23
  import InfoMetric from '../../../components/info-metric';
23
24
  import InfoRow from '../../../components/info-row';
24
25
  import SectionHeader from '../../../components/section/header';
25
- import { getCustomerProfileUrl, goBackOrFallback } from '../../../libs/util';
26
+ import { goBackOrFallback } from '../../../libs/util';
26
27
  import CustomerLink from '../../../components/customer/link';
27
28
  import InfoCard from '../../../components/info-card';
28
29
  import InfoRowGroup from '../../../components/info-row-group';
@@ -39,7 +40,7 @@ const fetchData = (
39
40
  };
40
41
 
41
42
  export default function PayoutDetail() {
42
- const { t } = useLocaleContext();
43
+ const { t, locale } = useLocaleContext();
43
44
  const { isMobile } = useMobile();
44
45
  const params = useParams<{ id: string }>();
45
46
  const { loading, error, data } = useRequest(() => fetchData(params.id!), {
@@ -178,10 +179,7 @@ export default function PayoutDetail() {
178
179
  if (isAnonymousPayer) {
179
180
  return;
180
181
  }
181
- const url = getCustomerProfileUrl({
182
- userDid: paymentIntent?.customer?.did,
183
- locale: 'zh',
184
- });
182
+ const url = getUserProfileLink(paymentIntent?.customer?.did, locale);
185
183
  window.open(url, '_blank');
186
184
  }}>
187
185
  {paymentIntent?.customer?.name}