@blocklet/payment-react 1.18.12 → 1.18.14
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/link.js +1 -0
- package/es/components/over-due-invoice-payment.d.ts +3 -1
- package/es/components/over-due-invoice-payment.js +14 -3
- package/es/history/invoice/list.js +42 -32
- package/es/libs/navigation.d.ts +33 -0
- package/es/libs/navigation.js +45 -0
- package/es/libs/util.d.ts +4 -0
- package/es/libs/util.js +20 -0
- package/es/locales/en.js +2 -2
- package/es/locales/zh.js +2 -2
- package/es/payment/form/index.js +5 -0
- package/es/payment/form/stripe/form.js +41 -11
- package/es/payment/form/stripe/index.d.ts +1 -0
- package/es/payment/form/stripe/index.js +2 -1
- package/es/theme/index.js +5 -0
- package/lib/components/link.js +1 -0
- package/lib/components/over-due-invoice-payment.d.ts +3 -1
- package/lib/components/over-due-invoice-payment.js +18 -3
- package/lib/history/invoice/list.js +53 -42
- package/lib/libs/navigation.d.ts +33 -0
- package/lib/libs/navigation.js +59 -0
- package/lib/libs/util.d.ts +4 -0
- package/lib/libs/util.js +25 -0
- package/lib/locales/en.js +2 -2
- package/lib/locales/zh.js +2 -2
- package/lib/payment/form/index.js +5 -0
- package/lib/payment/form/stripe/form.js +16 -3
- package/lib/payment/form/stripe/index.d.ts +1 -0
- package/lib/payment/form/stripe/index.js +2 -1
- package/lib/theme/index.js +5 -0
- package/package.json +8 -8
- package/src/components/link.tsx +1 -0
- package/src/components/over-due-invoice-payment.tsx +14 -1
- package/src/history/invoice/list.tsx +46 -35
- package/src/libs/navigation.ts +89 -0
- package/src/libs/util.ts +25 -0
- package/src/locales/en.tsx +2 -2
- package/src/locales/zh.tsx +2 -2
- package/src/payment/form/index.tsx +5 -0
- package/src/payment/form/stripe/form.tsx +26 -3
- package/src/payment/form/stripe/index.tsx +2 -0
- package/src/theme/index.tsx +5 -0
|
@@ -12,7 +12,7 @@ var _material = require("@mui/material");
|
|
|
12
12
|
var _system = require("@mui/system");
|
|
13
13
|
var _ahooks = require("ahooks");
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
var
|
|
15
|
+
var _reactRouterDom = require("react-router-dom");
|
|
16
16
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
17
17
|
var _status = _interopRequireDefault(require("../../components/status"));
|
|
18
18
|
var _payment = require("../../contexts/payment");
|
|
@@ -20,6 +20,7 @@ var _subscription = require("../../hooks/subscription");
|
|
|
20
20
|
var _api = _interopRequireDefault(require("../../libs/api"));
|
|
21
21
|
var _util = require("../../libs/util");
|
|
22
22
|
var _table = _interopRequireDefault(require("../../components/table"));
|
|
23
|
+
var _navigation = require("../../libs/navigation");
|
|
23
24
|
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); }
|
|
24
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -45,18 +46,20 @@ const fetchData = (params = {}) => {
|
|
|
45
46
|
};
|
|
46
47
|
const getInvoiceLink = (invoice, action) => {
|
|
47
48
|
if (invoice.id.startsWith("in_")) {
|
|
49
|
+
const path = `/customer/invoice/${invoice.id}${invoice.status === "uncollectible" && action ? `?action=${action}` : ""}`;
|
|
48
50
|
return {
|
|
49
|
-
external: false,
|
|
50
51
|
connect: invoice.status === "uncollectible",
|
|
51
|
-
|
|
52
|
+
link: (0, _navigation.createLink)(path)
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
return {
|
|
55
|
-
external: true,
|
|
56
56
|
connect: false,
|
|
57
|
-
|
|
57
|
+
link: (0, _navigation.createLink)((0, _util.getTxLink)(invoice.paymentMethod, invoice.metadata?.payment_details).link, true)
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
+
const linkStyle = {
|
|
61
|
+
cursor: "pointer"
|
|
62
|
+
};
|
|
60
63
|
const InvoiceTable = _react.default.memo(props => {
|
|
61
64
|
const {
|
|
62
65
|
pageSize,
|
|
@@ -77,6 +80,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
77
80
|
t,
|
|
78
81
|
locale
|
|
79
82
|
} = (0, _context.useLocaleContext)();
|
|
83
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
80
84
|
const [search, setSearch] = (0, _react.useState)({
|
|
81
85
|
pageSize: pageSize || 10,
|
|
82
86
|
page: 1
|
|
@@ -129,6 +133,14 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
129
133
|
});
|
|
130
134
|
}
|
|
131
135
|
}, [subscription]);
|
|
136
|
+
const handleLinkClick = (e, invoice) => {
|
|
137
|
+
const {
|
|
138
|
+
link
|
|
139
|
+
} = getInvoiceLink(invoice, action);
|
|
140
|
+
(0, _navigation.handleNavigation)(e, link, navigate, {
|
|
141
|
+
target: link.external ? "_blank" : target
|
|
142
|
+
});
|
|
143
|
+
};
|
|
132
144
|
const columns = [{
|
|
133
145
|
label: t("common.amount"),
|
|
134
146
|
name: "total",
|
|
@@ -137,11 +149,9 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
137
149
|
options: {
|
|
138
150
|
customBodyRenderLite: (_, index) => {
|
|
139
151
|
const invoice = data?.list[index];
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
target: link.external ? "_blank" : target,
|
|
144
|
-
rel: "noreferrer",
|
|
152
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
153
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
154
|
+
sx: linkStyle,
|
|
145
155
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
146
156
|
children: [(0, _util.formatBNStr)(invoice.total, invoice.paymentCurrency.decimal), "\xA0", invoice.paymentCurrency.symbol]
|
|
147
157
|
})
|
|
@@ -154,11 +164,9 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
154
164
|
options: {
|
|
155
165
|
customBodyRenderLite: (_, index) => {
|
|
156
166
|
const invoice = data.list[index];
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
target: link.external ? "_blank" : target,
|
|
161
|
-
rel: "noreferrer",
|
|
167
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
168
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
169
|
+
sx: linkStyle,
|
|
162
170
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
163
171
|
label: (0, _util.getInvoiceDescriptionAndReason)(invoice, locale)?.type
|
|
164
172
|
})
|
|
@@ -171,11 +179,9 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
171
179
|
options: {
|
|
172
180
|
customBodyRenderLite: (_, index) => {
|
|
173
181
|
const invoice = data?.list[index];
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
target: link.external ? "_blank" : target,
|
|
178
|
-
rel: "noreferrer",
|
|
182
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
183
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
184
|
+
sx: linkStyle,
|
|
179
185
|
children: invoice?.number
|
|
180
186
|
});
|
|
181
187
|
}
|
|
@@ -186,11 +192,9 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
186
192
|
options: {
|
|
187
193
|
customBodyRenderLite: (val, index) => {
|
|
188
194
|
const invoice = data?.list[index];
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
target: link.external ? "_blank" : target,
|
|
193
|
-
rel: "noreferrer",
|
|
195
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
196
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
197
|
+
sx: linkStyle,
|
|
194
198
|
children: (0, _util.formatToDate)(invoice.created_at, locale, "YYYY-MM-DD HH:mm:ss")
|
|
195
199
|
});
|
|
196
200
|
}
|
|
@@ -202,11 +206,9 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
202
206
|
sort: false,
|
|
203
207
|
customBodyRenderLite: (val, index) => {
|
|
204
208
|
const invoice = data?.list[index];
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
target: link.external ? "_blank" : target,
|
|
209
|
-
rel: "noreferrer",
|
|
209
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
210
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
211
|
+
sx: linkStyle,
|
|
210
212
|
children: (0, _util.getInvoiceDescriptionAndReason)(invoice, locale)?.description || invoice.id
|
|
211
213
|
});
|
|
212
214
|
}
|
|
@@ -217,10 +219,12 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
217
219
|
options: {
|
|
218
220
|
customBodyRenderLite: (val, index) => {
|
|
219
221
|
const invoice = data?.list[index];
|
|
220
|
-
const link = getInvoiceLink(invoice, action);
|
|
221
222
|
const hidePay = invoice.billing_reason === "overdraft-protection";
|
|
223
|
+
const {
|
|
224
|
+
connect
|
|
225
|
+
} = getInvoiceLink(invoice, action);
|
|
222
226
|
if (action && !hidePay) {
|
|
223
|
-
return
|
|
227
|
+
return connect ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
224
228
|
variant: "text",
|
|
225
229
|
size: "small",
|
|
226
230
|
onClick: () => onPay(invoice.id),
|
|
@@ -232,8 +236,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
232
236
|
component: "a",
|
|
233
237
|
variant: "text",
|
|
234
238
|
size: "small",
|
|
235
|
-
|
|
236
|
-
target: link.external ? "_blank" : target,
|
|
239
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
237
240
|
sx: {
|
|
238
241
|
color: "var(--foregrounds-fg-interactive, #0086FF) !important"
|
|
239
242
|
},
|
|
@@ -241,10 +244,9 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
241
244
|
children: t("payment.customer.invoice.pay")
|
|
242
245
|
});
|
|
243
246
|
}
|
|
244
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
rel: "noreferrer",
|
|
247
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
248
|
+
onClick: e => handleLinkClick(e, invoice),
|
|
249
|
+
sx: linkStyle,
|
|
248
250
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
249
251
|
label: invoice.status,
|
|
250
252
|
color: (0, _util.getInvoiceStatusColor)(invoice.status)
|
|
@@ -330,6 +332,7 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
330
332
|
t,
|
|
331
333
|
locale
|
|
332
334
|
} = (0, _context.useLocaleContext)();
|
|
335
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
333
336
|
const {
|
|
334
337
|
data,
|
|
335
338
|
loadMore,
|
|
@@ -404,6 +407,11 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
404
407
|
}
|
|
405
408
|
const hasMore = data && data.list.length < data.count;
|
|
406
409
|
const grouped = groupByDate(data.list);
|
|
410
|
+
const handleLinkClick = (e, link) => {
|
|
411
|
+
(0, _navigation.handleNavigation)(e, link, navigate, {
|
|
412
|
+
target: link.external ? "_blank" : target
|
|
413
|
+
});
|
|
414
|
+
};
|
|
407
415
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(Root, {
|
|
408
416
|
direction: "column",
|
|
409
417
|
gap: 1,
|
|
@@ -420,7 +428,10 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
420
428
|
},
|
|
421
429
|
children: date
|
|
422
430
|
}), invoices.map(invoice => {
|
|
423
|
-
const
|
|
431
|
+
const {
|
|
432
|
+
link,
|
|
433
|
+
connect
|
|
434
|
+
} = getInvoiceLink(invoice, action);
|
|
424
435
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
425
436
|
direction: "row",
|
|
426
437
|
sx: {
|
|
@@ -439,6 +450,7 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
439
450
|
href: link.url,
|
|
440
451
|
target: link.external ? "_blank" : target,
|
|
441
452
|
rel: "noreferrer",
|
|
453
|
+
onClick: e => handleLinkClick(e, link),
|
|
442
454
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
443
455
|
direction: "row",
|
|
444
456
|
alignItems: "center",
|
|
@@ -482,7 +494,7 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
482
494
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
483
495
|
flex: 1,
|
|
484
496
|
textAlign: "right",
|
|
485
|
-
children: action ?
|
|
497
|
+
children: action ? connect ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
486
498
|
variant: "contained",
|
|
487
499
|
color: "primary",
|
|
488
500
|
size: "small",
|
|
@@ -495,8 +507,7 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
495
507
|
component: "a",
|
|
496
508
|
variant: "contained",
|
|
497
509
|
size: "small",
|
|
498
|
-
|
|
499
|
-
target: link.external ? "_blank" : target,
|
|
510
|
+
onClick: e => handleLinkClick(e, link),
|
|
500
511
|
sx: {
|
|
501
512
|
whiteSpace: "nowrap"
|
|
502
513
|
},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NavigateFunction } from 'react-router-dom';
|
|
2
|
+
export interface LinkInfo {
|
|
3
|
+
url: string;
|
|
4
|
+
external: boolean;
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Check if currently running inside Payment Kit
|
|
9
|
+
*/
|
|
10
|
+
export declare function isInPaymentKit(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Create link information object
|
|
13
|
+
* @param path Path or URL
|
|
14
|
+
* @param external Force external link behavior
|
|
15
|
+
*/
|
|
16
|
+
export declare function createLink(path: string, external?: boolean): LinkInfo;
|
|
17
|
+
/**
|
|
18
|
+
* Get HTML attributes for a link
|
|
19
|
+
* @param link Link information
|
|
20
|
+
* @param target Link target (default: _self)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getLinkProps(link: LinkInfo, target?: string): Record<string, any>;
|
|
23
|
+
/**
|
|
24
|
+
* Handle link navigation
|
|
25
|
+
* @param e Click event
|
|
26
|
+
* @param link Link information
|
|
27
|
+
* @param navigate React Router navigate function
|
|
28
|
+
* @param options Navigation options
|
|
29
|
+
*/
|
|
30
|
+
export declare function handleNavigation(e: React.MouseEvent, link: LinkInfo, navigate?: NavigateFunction, options?: {
|
|
31
|
+
replace?: boolean;
|
|
32
|
+
target?: string;
|
|
33
|
+
}): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createLink = createLink;
|
|
7
|
+
exports.getLinkProps = getLinkProps;
|
|
8
|
+
exports.handleNavigation = handleNavigation;
|
|
9
|
+
exports.isInPaymentKit = isInPaymentKit;
|
|
10
|
+
var _ufo = require("ufo");
|
|
11
|
+
var _util = require("./util");
|
|
12
|
+
function isInPaymentKit() {
|
|
13
|
+
const componentId = (window.blocklet?.componentId || "").split("/").pop();
|
|
14
|
+
return componentId === _util.PAYMENT_KIT_DID;
|
|
15
|
+
}
|
|
16
|
+
function createLink(path, external = false) {
|
|
17
|
+
const isAbsoluteUrl = /^https?:\/\//.test(path);
|
|
18
|
+
const isExternal = external || isAbsoluteUrl;
|
|
19
|
+
const url = isExternal ? path : (0, _ufo.joinURL)((0, _util.getPrefix)(), path);
|
|
20
|
+
return {
|
|
21
|
+
url,
|
|
22
|
+
external: isExternal,
|
|
23
|
+
path
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function getLinkProps(link, target = "_self") {
|
|
27
|
+
const props = {
|
|
28
|
+
href: link.url
|
|
29
|
+
};
|
|
30
|
+
if (link.external) {
|
|
31
|
+
props.target = target;
|
|
32
|
+
props.rel = target === "_blank" ? "noopener noreferrer" : void 0;
|
|
33
|
+
}
|
|
34
|
+
return props;
|
|
35
|
+
}
|
|
36
|
+
function handleNavigation(e, link, navigate, options = {}) {
|
|
37
|
+
if (e) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
}
|
|
40
|
+
const {
|
|
41
|
+
replace = false,
|
|
42
|
+
target = "_self"
|
|
43
|
+
} = options;
|
|
44
|
+
if (link.external || target === "_blank") {
|
|
45
|
+
window.open(link.url, target);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (isInPaymentKit() && navigate) {
|
|
49
|
+
navigate(link.path, {
|
|
50
|
+
replace
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (replace) {
|
|
55
|
+
window.location.replace(link.url);
|
|
56
|
+
} else {
|
|
57
|
+
window.location.href = link.url;
|
|
58
|
+
}
|
|
59
|
+
}
|
package/lib/libs/util.d.ts
CHANGED
|
@@ -114,3 +114,7 @@ export declare function getInvoiceDescriptionAndReason(invoice: TInvoiceExpanded
|
|
|
114
114
|
export declare function getPaymentKitComponent(): any;
|
|
115
115
|
export declare function openDonationSettings(openInNewTab?: boolean): void;
|
|
116
116
|
export declare function getUserProfileLink(userDid: string, locale?: string): string;
|
|
117
|
+
export declare function parseMarkedText(text: string): Array<{
|
|
118
|
+
type: 'text' | 'marked';
|
|
119
|
+
content: string;
|
|
120
|
+
}>;
|
package/lib/libs/util.js
CHANGED
|
@@ -55,6 +55,7 @@ exports.isValidCountry = isValidCountry;
|
|
|
55
55
|
exports.lazyLoad = lazyLoad;
|
|
56
56
|
exports.mergeExtraParams = void 0;
|
|
57
57
|
exports.openDonationSettings = openDonationSettings;
|
|
58
|
+
exports.parseMarkedText = parseMarkedText;
|
|
58
59
|
exports.sleep = sleep;
|
|
59
60
|
exports.stopEvent = stopEvent;
|
|
60
61
|
exports.truncateText = truncateText;
|
|
@@ -1116,4 +1117,28 @@ function getUserProfileLink(userDid, locale = "en") {
|
|
|
1116
1117
|
locale,
|
|
1117
1118
|
did: userDid
|
|
1118
1119
|
}));
|
|
1120
|
+
}
|
|
1121
|
+
function parseMarkedText(text) {
|
|
1122
|
+
if (!text) return [];
|
|
1123
|
+
const parts = text.split(/(#([^#]*)#)/);
|
|
1124
|
+
const result = [];
|
|
1125
|
+
for (let i = 0; i < parts.length; i++) {
|
|
1126
|
+
const part = parts[i];
|
|
1127
|
+
if (!part) continue;
|
|
1128
|
+
if (i % 3 === 0) {
|
|
1129
|
+
result.push({
|
|
1130
|
+
type: "text",
|
|
1131
|
+
content: part
|
|
1132
|
+
});
|
|
1133
|
+
} else if (i % 3 === 1 && part.startsWith("#") && part.endsWith("#")) {
|
|
1134
|
+
const content = part.slice(1, -1);
|
|
1135
|
+
if (content.length >= 0) {
|
|
1136
|
+
result.push({
|
|
1137
|
+
type: "marked",
|
|
1138
|
+
content
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return result.filter(p => p.content !== "");
|
|
1119
1144
|
}
|
package/lib/locales/en.js
CHANGED
|
@@ -252,8 +252,8 @@ module.exports = (0, _flat.default)({
|
|
|
252
252
|
}
|
|
253
253
|
},
|
|
254
254
|
recover: {
|
|
255
|
-
button: "
|
|
256
|
-
title: "
|
|
255
|
+
button: "Resume Subscription",
|
|
256
|
+
title: "Resume Your Subscription",
|
|
257
257
|
description: "Your subscription will not be canceled and will be automatically renewed on {date}, please confirm to continue"
|
|
258
258
|
},
|
|
259
259
|
changePlan: {
|
package/lib/locales/zh.js
CHANGED
|
@@ -252,8 +252,8 @@ module.exports = (0, _flat.default)({
|
|
|
252
252
|
}
|
|
253
253
|
},
|
|
254
254
|
recover: {
|
|
255
|
-
button: "\
|
|
256
|
-
title: "\
|
|
255
|
+
button: "\u6062\u590D\u8BA2\u9605",
|
|
256
|
+
title: "\u6062\u590D\u60A8\u7684\u8BA2\u9605",
|
|
257
257
|
description: "\u60A8\u7684\u8BA2\u9605\u5C06\u4E0D\u4F1A\u88AB\u53D6\u6D88\uFF0C\u5E76\u5C06\u5728{date}\u81EA\u52A8\u7EED\u8BA2\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u7EE7\u7EED"
|
|
258
258
|
},
|
|
259
259
|
changePlan: {
|
|
@@ -156,6 +156,11 @@ function PaymentForm({
|
|
|
156
156
|
setValue("customer_phone", session.user.phone);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
if (!session?.user) {
|
|
160
|
+
setValue("customer_name", "");
|
|
161
|
+
setValue("customer_email", "");
|
|
162
|
+
setValue("customer_phone", "");
|
|
163
|
+
}
|
|
159
164
|
}, [session?.user, getValues, setValue]);
|
|
160
165
|
(0, _react.useEffect)(() => {
|
|
161
166
|
setValue("payment_method", currencies[paymentCurrencyIndex]?.method?.id);
|
|
@@ -20,7 +20,8 @@ const {
|
|
|
20
20
|
PaymentElement,
|
|
21
21
|
useElements,
|
|
22
22
|
useStripe,
|
|
23
|
-
loadStripe
|
|
23
|
+
loadStripe,
|
|
24
|
+
LinkAuthenticationElement
|
|
24
25
|
} = globalThis.__STRIPE_COMPONENTS__;
|
|
25
26
|
function StripeCheckoutForm({
|
|
26
27
|
clientSecret,
|
|
@@ -123,13 +124,25 @@ function StripeCheckoutForm({
|
|
|
123
124
|
|
|
124
125
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(Content, {
|
|
125
126
|
onSubmit: handleSubmit,
|
|
126
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
127
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(LinkAuthenticationElement, {
|
|
128
|
+
options: {
|
|
129
|
+
defaultEmail: customer.email
|
|
130
|
+
}
|
|
131
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(PaymentElement, {
|
|
127
132
|
options: {
|
|
128
133
|
layout: "auto",
|
|
129
134
|
fields: {
|
|
130
135
|
billingDetails: "never"
|
|
131
136
|
},
|
|
132
|
-
readOnly: state.confirming
|
|
137
|
+
readOnly: state.confirming,
|
|
138
|
+
defaultValues: {
|
|
139
|
+
billingDetails: {
|
|
140
|
+
name: customer.name,
|
|
141
|
+
phone: customer.phone,
|
|
142
|
+
email: customer.email,
|
|
143
|
+
address: customer.address
|
|
144
|
+
}
|
|
145
|
+
}
|
|
133
146
|
},
|
|
134
147
|
onReady: () => setState({
|
|
135
148
|
loaded: true
|
|
@@ -12,7 +12,8 @@ module.exports = (0, _lazyLoader.createLazyComponent)(async () => {
|
|
|
12
12
|
PaymentElement: stripeReact.PaymentElement,
|
|
13
13
|
useElements: stripeReact.useElements,
|
|
14
14
|
useStripe: stripeReact.useStripe,
|
|
15
|
-
loadStripe: stripe.loadStripe
|
|
15
|
+
loadStripe: stripe.loadStripe,
|
|
16
|
+
LinkAuthenticationElement: stripeReact.LinkAuthenticationElement
|
|
16
17
|
};
|
|
17
18
|
const {
|
|
18
19
|
default: Component
|
package/lib/theme/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.14",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@arcblock/did-connect": "^2.
|
|
57
|
-
"@arcblock/ux": "^2.
|
|
58
|
-
"@arcblock/ws": "^1.19.
|
|
59
|
-
"@blocklet/ui-react": "^2.
|
|
56
|
+
"@arcblock/did-connect": "^2.12.12",
|
|
57
|
+
"@arcblock/ux": "^2.12.12",
|
|
58
|
+
"@arcblock/ws": "^1.19.15",
|
|
59
|
+
"@blocklet/ui-react": "^2.12.12",
|
|
60
60
|
"@mui/icons-material": "^5.16.6",
|
|
61
61
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
62
62
|
"@mui/material": "^5.16.6",
|
|
63
63
|
"@mui/system": "^5.16.6",
|
|
64
|
-
"@ocap/util": "^1.19.
|
|
64
|
+
"@ocap/util": "^1.19.15",
|
|
65
65
|
"@stripe/react-stripe-js": "^2.7.3",
|
|
66
66
|
"@stripe/stripe-js": "^2.4.0",
|
|
67
67
|
"@vitejs/plugin-legacy": "^5.4.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@babel/core": "^7.25.2",
|
|
93
93
|
"@babel/preset-env": "^7.25.2",
|
|
94
94
|
"@babel/preset-react": "^7.24.7",
|
|
95
|
-
"@blocklet/payment-types": "1.18.
|
|
95
|
+
"@blocklet/payment-types": "1.18.14",
|
|
96
96
|
"@storybook/addon-essentials": "^7.6.20",
|
|
97
97
|
"@storybook/addon-interactions": "^7.6.20",
|
|
98
98
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"vite-plugin-babel": "^1.2.0",
|
|
124
124
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "84cf68d98fcf1df0655e90567b98d6bab38f300e"
|
|
127
127
|
}
|
package/src/components/link.tsx
CHANGED
|
@@ -22,6 +22,7 @@ type Props = {
|
|
|
22
22
|
mode?: 'default' | 'custom';
|
|
23
23
|
onPaid?: (subscriptionId: string, currencyId: string) => void;
|
|
24
24
|
dialogProps?: DialogProps;
|
|
25
|
+
inSubscriptionDetail?: boolean;
|
|
25
26
|
children?: (
|
|
26
27
|
handlePay: (item: SummaryItem) => void,
|
|
27
28
|
data: {
|
|
@@ -56,6 +57,7 @@ function OverdueInvoicePayment({
|
|
|
56
57
|
dialogProps = {},
|
|
57
58
|
children,
|
|
58
59
|
onPaid = () => {},
|
|
60
|
+
inSubscriptionDetail = false,
|
|
59
61
|
}: Props) {
|
|
60
62
|
const { t } = useLocaleContext();
|
|
61
63
|
const { connect } = usePaymentContext();
|
|
@@ -141,8 +143,15 @@ function OverdueInvoicePayment({
|
|
|
141
143
|
dialogProps.onClose?.();
|
|
142
144
|
};
|
|
143
145
|
|
|
146
|
+
const handleViewDetailClick = (e: React.MouseEvent) => {
|
|
147
|
+
if (inSubscriptionDetail) {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
handleClose();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
144
153
|
if (loading) {
|
|
145
|
-
return
|
|
154
|
+
return null;
|
|
146
155
|
}
|
|
147
156
|
|
|
148
157
|
const renderPayButton = (item: SummaryItem, props: any) => {
|
|
@@ -184,6 +193,7 @@ function OverdueInvoicePayment({
|
|
|
184
193
|
{...(dialogProps || {})}
|
|
185
194
|
open={dialogOpen}
|
|
186
195
|
title={dialogProps?.title || t('payment.subscription.overdue.pastDue')}
|
|
196
|
+
sx={{ '& .MuiDialogContent-root': { pt: 0 } }}
|
|
187
197
|
onClose={handleClose}>
|
|
188
198
|
{error ? (
|
|
189
199
|
<Alert severity="error">{error.message}</Alert>
|
|
@@ -220,6 +230,7 @@ function OverdueInvoicePayment({
|
|
|
220
230
|
<a
|
|
221
231
|
href={subscriptionUrl}
|
|
222
232
|
target="_blank"
|
|
233
|
+
onClick={handleViewDetailClick}
|
|
223
234
|
rel="noreferrer"
|
|
224
235
|
style={{ color: 'var(--foregrounds-fg-interactive, 0086FF)' }}>
|
|
225
236
|
{t('payment.subscription.overdue.view')}
|
|
@@ -250,6 +261,7 @@ function OverdueInvoicePayment({
|
|
|
250
261
|
href={subscriptionUrl}
|
|
251
262
|
target="_blank"
|
|
252
263
|
rel="noreferrer"
|
|
264
|
+
onClick={handleViewDetailClick}
|
|
253
265
|
style={{ color: 'var(--foregrounds-fg-interactive, 0086FF)' }}>
|
|
254
266
|
{t('payment.subscription.overdue.view')}
|
|
255
267
|
</a>
|
|
@@ -303,6 +315,7 @@ OverdueInvoicePayment.defaultProps = {
|
|
|
303
315
|
open: true,
|
|
304
316
|
},
|
|
305
317
|
children: null,
|
|
318
|
+
inSubscriptionDetail: false,
|
|
306
319
|
};
|
|
307
320
|
|
|
308
321
|
export default OverdueInvoicePayment;
|