@blocklet/payment-react 1.13.238 → 1.13.240
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/history/mini-invoice/list.js +14 -6
- package/es/libs/did-connect.d.ts +10 -0
- package/es/libs/did-connect.js +11 -0
- package/es/types/shims.d.ts +1 -3
- package/es/util.d.ts +1 -1
- package/lib/history/mini-invoice/list.js +15 -1
- package/lib/libs/did-connect.d.ts +10 -0
- package/lib/libs/did-connect.js +16 -0
- package/lib/types/shims.d.ts +1 -3
- package/lib/util.d.ts +1 -1
- package/package.json +30 -30
- package/src/history/mini-invoice/list.tsx +17 -6
- package/src/libs/did-connect.ts +20 -0
- package/src/types/shims.d.ts +1 -3
- package/src/util.ts +3 -2
|
@@ -14,9 +14,11 @@ import {
|
|
|
14
14
|
Typography
|
|
15
15
|
} from "@mui/material";
|
|
16
16
|
import { useRequest } from "ahooks";
|
|
17
|
-
import {
|
|
17
|
+
import { useMemo } from "react";
|
|
18
|
+
import { joinURL, withQuery } from "ufo";
|
|
18
19
|
import api from "../../api.js";
|
|
19
20
|
import Status from "../../components/status.js";
|
|
21
|
+
import { getDidConnectQueryParams } from "../../libs/did-connect.js";
|
|
20
22
|
import {
|
|
21
23
|
formatBNStr,
|
|
22
24
|
formatError,
|
|
@@ -57,6 +59,16 @@ export default function MiniInvoiceList() {
|
|
|
57
59
|
include_staking: true
|
|
58
60
|
})
|
|
59
61
|
);
|
|
62
|
+
const subscriptionPageUrl = useMemo(() => {
|
|
63
|
+
if (!subscription) {
|
|
64
|
+
return "#";
|
|
65
|
+
}
|
|
66
|
+
const pageUrl = joinURL(window.location.origin, getPrefix(), `/customer/subscription/${subscription.id}`);
|
|
67
|
+
return withQuery(pageUrl, {
|
|
68
|
+
source: "embed",
|
|
69
|
+
...getDidConnectQueryParams({ forceConnected: subscription.customer.did })
|
|
70
|
+
});
|
|
71
|
+
}, [subscription]);
|
|
60
72
|
if (error) {
|
|
61
73
|
return /* @__PURE__ */ jsx(Position, { children: /* @__PURE__ */ jsx(Alert, { severity: "error", children: formatError(error) }) });
|
|
62
74
|
}
|
|
@@ -152,11 +164,7 @@ export default function MiniInvoiceList() {
|
|
|
152
164
|
variant: "contained",
|
|
153
165
|
sx: { color: "#fff!important", width: subscription.service_actions?.length ? "auto" : "100%" },
|
|
154
166
|
target: "_blank",
|
|
155
|
-
href:
|
|
156
|
-
window.location.origin,
|
|
157
|
-
getPrefix(),
|
|
158
|
-
`/customer/subscription/${subscription.id}?source=embed`
|
|
159
|
-
),
|
|
167
|
+
href: subscriptionPageUrl,
|
|
160
168
|
children: t("payment.customer.subscriptions.view")
|
|
161
169
|
}
|
|
162
170
|
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DIDConnectCustomQuery {
|
|
2
|
+
forceConnected: string;
|
|
3
|
+
sourceAppPid?: string;
|
|
4
|
+
switchBehavior?: 'auto' | 'disabled' | 'required';
|
|
5
|
+
showClose?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function getDidConnectQueryParams(params: DIDConnectCustomQuery): {
|
|
8
|
+
'__did-connect__': string;
|
|
9
|
+
};
|
|
10
|
+
export { getDidConnectQueryParams };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function getDidConnectQueryParams(params) {
|
|
2
|
+
const didConnectQueryParams = {
|
|
3
|
+
switchBehavior: "auto",
|
|
4
|
+
showClose: false,
|
|
5
|
+
...params
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
"__did-connect__": Buffer.from(JSON.stringify(didConnectQueryParams), "utf8").toString("base64")
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export { getDidConnectQueryParams };
|
package/es/types/shims.d.ts
CHANGED
package/es/util.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
3
3
|
export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
4
4
|
export declare const isPaymentKitMounted: () => any;
|
|
5
|
-
export declare const getPrefix: () =>
|
|
5
|
+
export declare const getPrefix: () => string;
|
|
6
6
|
export declare function formatToDate(date: Date | string | number, locale?: string, format?: string): any;
|
|
7
7
|
export declare function formatToDatetime(date: Date | string | number, locale?: string): any;
|
|
8
8
|
export declare function formatTime(date: Date | string | number, format?: string, locale?: string): any;
|
|
@@ -8,9 +8,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
8
8
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _ahooks = require("ahooks");
|
|
11
|
+
var _react = require("react");
|
|
11
12
|
var _ufo = require("ufo");
|
|
12
13
|
var _api = _interopRequireDefault(require("../../api"));
|
|
13
14
|
var _status = _interopRequireDefault(require("../../components/status"));
|
|
15
|
+
var _didConnect = require("../../libs/did-connect");
|
|
14
16
|
var _util = require("../../util");
|
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
18
|
const fetchInvoiceData = (params = {}) => {
|
|
@@ -50,6 +52,18 @@ function MiniInvoiceList() {
|
|
|
50
52
|
ignore_zero: true,
|
|
51
53
|
include_staking: true
|
|
52
54
|
}));
|
|
55
|
+
const subscriptionPageUrl = (0, _react.useMemo)(() => {
|
|
56
|
+
if (!subscription) {
|
|
57
|
+
return "#";
|
|
58
|
+
}
|
|
59
|
+
const pageUrl = (0, _ufo.joinURL)(window.location.origin, (0, _util.getPrefix)(), `/customer/subscription/${subscription.id}`);
|
|
60
|
+
return (0, _ufo.withQuery)(pageUrl, {
|
|
61
|
+
source: "embed",
|
|
62
|
+
...(0, _didConnect.getDidConnectQueryParams)({
|
|
63
|
+
forceConnected: subscription.customer.did
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}, [subscription]);
|
|
53
67
|
if (error) {
|
|
54
68
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Position, {
|
|
55
69
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Alert, {
|
|
@@ -226,7 +240,7 @@ function MiniInvoiceList() {
|
|
|
226
240
|
width: subscription.service_actions?.length ? "auto" : "100%"
|
|
227
241
|
},
|
|
228
242
|
target: "_blank",
|
|
229
|
-
href:
|
|
243
|
+
href: subscriptionPageUrl,
|
|
230
244
|
children: t("payment.customer.subscriptions.view")
|
|
231
245
|
})]
|
|
232
246
|
})]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DIDConnectCustomQuery {
|
|
2
|
+
forceConnected: string;
|
|
3
|
+
sourceAppPid?: string;
|
|
4
|
+
switchBehavior?: 'auto' | 'disabled' | 'required';
|
|
5
|
+
showClose?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function getDidConnectQueryParams(params: DIDConnectCustomQuery): {
|
|
8
|
+
'__did-connect__': string;
|
|
9
|
+
};
|
|
10
|
+
export { getDidConnectQueryParams };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDidConnectQueryParams = getDidConnectQueryParams;
|
|
7
|
+
function getDidConnectQueryParams(params) {
|
|
8
|
+
const didConnectQueryParams = {
|
|
9
|
+
switchBehavior: "auto",
|
|
10
|
+
showClose: false,
|
|
11
|
+
...params
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
"__did-connect__": Buffer.from(JSON.stringify(didConnectQueryParams), "utf8").toString("base64")
|
|
15
|
+
};
|
|
16
|
+
}
|
package/lib/types/shims.d.ts
CHANGED
package/lib/util.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
3
3
|
export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
4
4
|
export declare const isPaymentKitMounted: () => any;
|
|
5
|
-
export declare const getPrefix: () =>
|
|
5
|
+
export declare const getPrefix: () => string;
|
|
6
6
|
export declare function formatToDate(date: Date | string | number, locale?: string, format?: string): any;
|
|
7
7
|
export declare function formatToDatetime(date: Date | string | number, locale?: string): any;
|
|
8
8
|
export declare function formatTime(date: Date | string | number, format?: string, locale?: string): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.240",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,27 +52,27 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@arcblock/did-connect": "^2.9.
|
|
56
|
-
"@arcblock/ux": "^2.9.
|
|
57
|
-
"@mui/icons-material": "^5.15.
|
|
55
|
+
"@arcblock/did-connect": "^2.9.77",
|
|
56
|
+
"@arcblock/ux": "^2.9.77",
|
|
57
|
+
"@mui/icons-material": "^5.15.16",
|
|
58
58
|
"@mui/lab": "^5.0.0-alpha.170",
|
|
59
|
-
"@mui/material": "^5.15.
|
|
60
|
-
"@mui/styles": "^5.15.
|
|
59
|
+
"@mui/material": "^5.15.16",
|
|
60
|
+
"@mui/styles": "^5.15.16",
|
|
61
61
|
"@mui/system": "^5.15.15",
|
|
62
|
-
"@ocap/util": "^1.18.
|
|
63
|
-
"@stripe/react-stripe-js": "^2.7.
|
|
62
|
+
"@ocap/util": "^1.18.116",
|
|
63
|
+
"@stripe/react-stripe-js": "^2.7.1",
|
|
64
64
|
"@stripe/stripe-js": "^2.4.0",
|
|
65
|
-
"@vitejs/plugin-legacy": "^5.
|
|
65
|
+
"@vitejs/plugin-legacy": "^5.4.0",
|
|
66
66
|
"ahooks": "^3.7.11",
|
|
67
67
|
"axios": "^0.27.2",
|
|
68
|
-
"dayjs": "^1.11.
|
|
68
|
+
"dayjs": "^1.11.11",
|
|
69
69
|
"flat": "^5.0.2",
|
|
70
70
|
"google-libphonenumber": "^3.2.34",
|
|
71
71
|
"lodash": "^4.17.21",
|
|
72
72
|
"numbro": "^2.5.0",
|
|
73
73
|
"p-wait-for": "3",
|
|
74
74
|
"react-error-boundary": "^4.0.13",
|
|
75
|
-
"react-hook-form": "^7.51.
|
|
75
|
+
"react-hook-form": "^7.51.4",
|
|
76
76
|
"react-international-phone": "^3.1.2",
|
|
77
77
|
"ufo": "^1.5.3",
|
|
78
78
|
"use-bus": "^2.5.2",
|
|
@@ -86,38 +86,38 @@
|
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@arcblock/eslint-config-ts": "^0.3.0",
|
|
89
|
-
"@babel/cli": "^7.24.
|
|
90
|
-
"@babel/core": "^7.24.
|
|
91
|
-
"@babel/preset-env": "^7.24.
|
|
89
|
+
"@babel/cli": "^7.24.5",
|
|
90
|
+
"@babel/core": "^7.24.5",
|
|
91
|
+
"@babel/preset-env": "^7.24.5",
|
|
92
92
|
"@babel/preset-react": "^7.24.1",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
94
|
-
"@storybook/addon-essentials": "^7.6.
|
|
95
|
-
"@storybook/addon-interactions": "^7.6.
|
|
96
|
-
"@storybook/addon-links": "^7.6.
|
|
93
|
+
"@blocklet/payment-types": "1.13.240",
|
|
94
|
+
"@storybook/addon-essentials": "^7.6.19",
|
|
95
|
+
"@storybook/addon-interactions": "^7.6.19",
|
|
96
|
+
"@storybook/addon-links": "^7.6.19",
|
|
97
97
|
"@storybook/addon-onboarding": "^1.0.11",
|
|
98
|
-
"@storybook/blocks": "^7.6.
|
|
99
|
-
"@storybook/react": "^7.6.
|
|
100
|
-
"@storybook/react-vite": "^7.6.
|
|
101
|
-
"@storybook/test": "^7.6.
|
|
102
|
-
"@types/react": "^18.
|
|
103
|
-
"@types/react-dom": "^18.
|
|
104
|
-
"@vitejs/plugin-legacy": "^5.
|
|
98
|
+
"@storybook/blocks": "^7.6.19",
|
|
99
|
+
"@storybook/react": "^7.6.19",
|
|
100
|
+
"@storybook/react-vite": "^7.6.19",
|
|
101
|
+
"@storybook/test": "^7.6.19",
|
|
102
|
+
"@types/react": "^18.3.1",
|
|
103
|
+
"@types/react-dom": "^18.3.0",
|
|
104
|
+
"@vitejs/plugin-legacy": "^5.4.0",
|
|
105
105
|
"eslint": "^8.57.0",
|
|
106
106
|
"glob": "^10.3.12",
|
|
107
107
|
"import-sort-style-module": "^6.0.0",
|
|
108
108
|
"jest": "^29.7.0",
|
|
109
109
|
"prettier": "^2.8.8",
|
|
110
110
|
"prettier-plugin-import-sort": "^0.0.7",
|
|
111
|
-
"react": "^18.
|
|
112
|
-
"react-dom": "^18.
|
|
111
|
+
"react": "^18.3.1",
|
|
112
|
+
"react-dom": "^18.3.1",
|
|
113
113
|
"rollup-plugin-node-builtins": "^2.1.2",
|
|
114
|
-
"storybook": "^7.6.
|
|
114
|
+
"storybook": "^7.6.19",
|
|
115
115
|
"ts-jest": "^29.1.2",
|
|
116
|
-
"type-fest": "^4.
|
|
116
|
+
"type-fest": "^4.18.2",
|
|
117
117
|
"typescript": "^4.9.5",
|
|
118
118
|
"unbuild": "^2.0.0",
|
|
119
119
|
"vite-plugin-babel": "^1.2.0",
|
|
120
120
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "02b0f1dc4e711c889dd88f7ace2b56062c5d2f0e"
|
|
123
123
|
}
|
|
@@ -15,10 +15,12 @@ import {
|
|
|
15
15
|
Typography,
|
|
16
16
|
} from '@mui/material';
|
|
17
17
|
import { useRequest } from 'ahooks';
|
|
18
|
-
import {
|
|
18
|
+
import { useMemo } from 'react';
|
|
19
|
+
import { joinURL, withQuery } from 'ufo';
|
|
19
20
|
|
|
20
21
|
import api from '../../api';
|
|
21
22
|
import Status from '../../components/status';
|
|
23
|
+
import { getDidConnectQueryParams } from '../../libs/did-connect';
|
|
22
24
|
import {
|
|
23
25
|
formatBNStr,
|
|
24
26
|
formatError,
|
|
@@ -66,6 +68,19 @@ export default function MiniInvoiceList() {
|
|
|
66
68
|
})
|
|
67
69
|
);
|
|
68
70
|
|
|
71
|
+
const subscriptionPageUrl: string = useMemo(() => {
|
|
72
|
+
if (!subscription) {
|
|
73
|
+
return '#';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const pageUrl: string = joinURL(window.location.origin, getPrefix(), `/customer/subscription/${subscription.id}`);
|
|
77
|
+
|
|
78
|
+
return withQuery(pageUrl, {
|
|
79
|
+
source: 'embed',
|
|
80
|
+
...getDidConnectQueryParams({ forceConnected: subscription.customer.did }),
|
|
81
|
+
});
|
|
82
|
+
}, [subscription]);
|
|
83
|
+
|
|
69
84
|
if (error) {
|
|
70
85
|
return (
|
|
71
86
|
<Position>
|
|
@@ -192,11 +207,7 @@ export default function MiniInvoiceList() {
|
|
|
192
207
|
variant="contained"
|
|
193
208
|
sx={{ color: '#fff!important', width: subscription.service_actions?.length ? 'auto' : '100%' }}
|
|
194
209
|
target="_blank"
|
|
195
|
-
href={
|
|
196
|
-
window.location.origin,
|
|
197
|
-
getPrefix(),
|
|
198
|
-
`/customer/subscription/${subscription.id}?source=embed`
|
|
199
|
-
)}>
|
|
210
|
+
href={subscriptionPageUrl}>
|
|
200
211
|
{t('payment.customer.subscriptions.view')}
|
|
201
212
|
</Button>
|
|
202
213
|
</Stack>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface DIDConnectCustomQuery {
|
|
2
|
+
forceConnected: string; // 填写用户的 DID
|
|
3
|
+
sourceAppPid?: string; // 应用程序 PID
|
|
4
|
+
switchBehavior?: 'auto' | 'disabled' | 'required'; // auto 代表引导切换,disabled 代表不提示,required 代表强制要求切换
|
|
5
|
+
showClose?: boolean; // 是否显示关闭按钮
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getDidConnectQueryParams(params: DIDConnectCustomQuery) {
|
|
9
|
+
const didConnectQueryParams: DIDConnectCustomQuery = {
|
|
10
|
+
switchBehavior: 'auto',
|
|
11
|
+
showClose: false,
|
|
12
|
+
...params,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
'__did-connect__': Buffer.from(JSON.stringify(didConnectQueryParams), 'utf8').toString('base64'),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { getDidConnectQueryParams };
|
package/src/types/shims.d.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
TSubscriptionExpanded,
|
|
14
14
|
TSubscriptionItemExpanded,
|
|
15
15
|
} from '@blocklet/payment-types';
|
|
16
|
+
import type { TComponent } from '@blocklet/sdk/lib/config';
|
|
16
17
|
import { BN, fromUnitToToken } from '@ocap/util';
|
|
17
18
|
import omit from 'lodash/omit';
|
|
18
19
|
import trimEnd from 'lodash/trimEnd';
|
|
@@ -29,12 +30,12 @@ export const isPaymentKitMounted = () => {
|
|
|
29
30
|
return (window.blocklet?.componentMountPoints || []).some((x: any) => x.did === PAYMENT_KIT_DID);
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
export const getPrefix = () => {
|
|
33
|
+
export const getPrefix = (): string => {
|
|
33
34
|
const componentId = (window?.blocklet?.componentId || '').split('/').pop();
|
|
34
35
|
if (componentId === PAYMENT_KIT_DID) {
|
|
35
36
|
return window.blocklet?.prefix;
|
|
36
37
|
}
|
|
37
|
-
const component = (window.blocklet?.componentMountPoints || []).find((x:
|
|
38
|
+
const component = (window.blocklet?.componentMountPoints || []).find((x: TComponent) => x.did === PAYMENT_KIT_DID);
|
|
38
39
|
if (component) {
|
|
39
40
|
return component.mountPoint;
|
|
40
41
|
}
|