@blocklet/payment-react 1.13.240 → 1.13.242
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.js +7 -5
- package/es/checkout/form.js +2 -2
- package/es/checkout/table.js +2 -2
- package/es/components/blockchain/gas.js +1 -1
- package/es/components/blockchain/tx.js +1 -1
- package/es/components/confirm.d.ts +4 -2
- package/es/components/confirm.js +5 -2
- package/es/components/pricing-table.js +1 -1
- package/es/components/safe-guard.js +1 -1
- package/es/contexts/payment.js +2 -2
- package/es/history/invoice/list.js +62 -10
- package/es/history/mini-invoice/list.js +2 -2
- package/es/history/payment/list.js +2 -2
- package/es/hooks/subscription.d.ts +7 -0
- package/es/hooks/subscription.js +55 -0
- package/es/index.d.ts +4 -3
- package/es/index.js +4 -3
- package/es/{api.js → libs/api.js} +6 -2
- package/es/{util.js → libs/util.js} +1 -1
- package/es/locales/en.js +1 -0
- package/es/locales/zh.js +1 -0
- package/es/payment/form/index.js +28 -6
- package/es/payment/form/phone.js +1 -1
- package/es/payment/header.js +1 -1
- package/es/payment/index.js +9 -2
- package/es/payment/product-card.js +34 -14
- package/es/payment/product-item.js +26 -16
- package/es/payment/summary.js +12 -3
- package/lib/checkout/donate.js +6 -5
- package/lib/checkout/form.js +2 -2
- package/lib/checkout/table.js +2 -2
- package/lib/components/blockchain/gas.js +1 -1
- package/lib/components/blockchain/tx.js +1 -1
- package/lib/components/confirm.d.ts +4 -2
- package/lib/components/confirm.js +5 -2
- package/lib/components/pricing-table.js +1 -1
- package/lib/components/safe-guard.js +1 -1
- package/lib/contexts/payment.js +2 -2
- package/lib/history/invoice/list.js +77 -9
- package/lib/history/mini-invoice/list.js +2 -2
- package/lib/history/payment/list.js +2 -2
- package/lib/hooks/subscription.d.ts +7 -0
- package/lib/hooks/subscription.js +62 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +17 -5
- package/lib/{api.js → libs/api.js} +5 -2
- package/lib/{util.js → libs/util.js} +1 -1
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/payment/form/index.js +35 -9
- package/lib/payment/form/phone.js +1 -1
- package/lib/payment/header.js +1 -1
- package/lib/payment/index.js +9 -2
- package/lib/payment/product-card.js +10 -0
- package/lib/payment/product-item.js +3 -2
- package/lib/payment/summary.js +4 -2
- package/package.json +4 -3
- package/src/checkout/donate.tsx +7 -5
- package/src/checkout/form.tsx +2 -2
- package/src/checkout/table.tsx +2 -2
- package/src/components/blockchain/gas.tsx +1 -1
- package/src/components/blockchain/tx.tsx +1 -1
- package/src/components/confirm.tsx +7 -3
- package/src/components/pricing-table.tsx +1 -1
- package/src/components/safe-guard.tsx +1 -1
- package/src/contexts/payment.tsx +2 -2
- package/src/history/invoice/list.tsx +83 -19
- package/src/history/mini-invoice/list.tsx +2 -2
- package/src/history/payment/list.tsx +2 -2
- package/src/hooks/subscription.ts +68 -0
- package/src/index.ts +4 -3
- package/src/{api.ts → libs/api.ts} +7 -2
- package/src/{util.ts → libs/util.ts} +1 -1
- package/src/locales/en.tsx +1 -0
- package/src/locales/zh.tsx +1 -0
- package/src/payment/form/index.tsx +36 -5
- package/src/payment/form/phone.tsx +1 -1
- package/src/payment/header.tsx +1 -1
- package/src/payment/index.tsx +9 -2
- package/src/payment/product-card.tsx +13 -3
- package/src/payment/product-item.tsx +7 -2
- package/src/payment/summary.tsx +7 -3
- /package/es/{api.d.ts → libs/api.d.ts} +0 -0
- /package/es/{dayjs.d.ts → libs/dayjs.d.ts} +0 -0
- /package/es/{dayjs.js → libs/dayjs.js} +0 -0
- /package/es/{theme.d.ts → libs/theme.d.ts} +0 -0
- /package/es/{theme.js → libs/theme.js} +0 -0
- /package/es/{util.d.ts → libs/util.d.ts} +0 -0
- /package/lib/{api.d.ts → libs/api.d.ts} +0 -0
- /package/lib/{dayjs.d.ts → libs/dayjs.d.ts} +0 -0
- /package/lib/{dayjs.js → libs/dayjs.js} +0 -0
- /package/lib/{theme.d.ts → libs/theme.d.ts} +0 -0
- /package/lib/{theme.js → libs/theme.js} +0 -0
- /package/lib/{util.d.ts → libs/util.d.ts} +0 -0
- /package/src/{dayjs.ts → libs/dayjs.ts} +0 -0
- /package/src/{theme.ts → libs/theme.ts} +0 -0
package/lib/index.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
api: true,
|
|
8
7
|
CheckoutDonate: true,
|
|
9
8
|
CheckoutForm: true,
|
|
10
9
|
CheckoutTable: true,
|
|
@@ -17,10 +16,11 @@ var _exportNames = {
|
|
|
17
16
|
SafeGuard: true,
|
|
18
17
|
Status: true,
|
|
19
18
|
Switch: true,
|
|
20
|
-
dayjs: true,
|
|
21
19
|
CustomerInvoiceList: true,
|
|
22
20
|
MiniInvoiceList: true,
|
|
23
21
|
CustomerPaymentList: true,
|
|
22
|
+
api: true,
|
|
23
|
+
dayjs: true,
|
|
24
24
|
Amount: true,
|
|
25
25
|
AddressForm: true,
|
|
26
26
|
CurrencySelector: true,
|
|
@@ -194,7 +194,6 @@ Object.defineProperty(exports, "translations", {
|
|
|
194
194
|
return _locales.translations;
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
|
-
var _api = _interopRequireDefault(require("./api"));
|
|
198
197
|
var _donate = _interopRequireDefault(require("./checkout/donate"));
|
|
199
198
|
var _form = _interopRequireDefault(require("./checkout/form"));
|
|
200
199
|
var _table = _interopRequireDefault(require("./checkout/table"));
|
|
@@ -207,10 +206,11 @@ var _pricingTable = _interopRequireDefault(require("./components/pricing-table")
|
|
|
207
206
|
var _safeGuard = _interopRequireDefault(require("./components/safe-guard"));
|
|
208
207
|
var _status = _interopRequireDefault(require("./components/status"));
|
|
209
208
|
var _switchButton = _interopRequireDefault(require("./components/switch-button"));
|
|
210
|
-
var _dayjs = _interopRequireDefault(require("./dayjs"));
|
|
211
209
|
var _list = _interopRequireDefault(require("./history/invoice/list"));
|
|
212
210
|
var _list2 = _interopRequireDefault(require("./history/mini-invoice/list"));
|
|
213
211
|
var _list3 = _interopRequireDefault(require("./history/payment/list"));
|
|
212
|
+
var _api = _interopRequireDefault(require("./libs/api"));
|
|
213
|
+
var _dayjs = _interopRequireDefault(require("./libs/dayjs"));
|
|
214
214
|
var _amount = _interopRequireDefault(require("./payment/amount"));
|
|
215
215
|
var _address = _interopRequireDefault(require("./payment/form/address"));
|
|
216
216
|
var _currency = _interopRequireDefault(require("./payment/form/currency"));
|
|
@@ -219,7 +219,7 @@ var _stripe = _interopRequireDefault(require("./payment/form/stripe"));
|
|
|
219
219
|
var _index = _interopRequireDefault(require("./payment/index"));
|
|
220
220
|
var _productSkeleton = _interopRequireDefault(require("./payment/product-skeleton"));
|
|
221
221
|
var _summary = _interopRequireDefault(require("./payment/summary"));
|
|
222
|
-
var _util = require("./util");
|
|
222
|
+
var _util = require("./libs/util");
|
|
223
223
|
Object.keys(_util).forEach(function (key) {
|
|
224
224
|
if (key === "default" || key === "__esModule") return;
|
|
225
225
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -243,5 +243,17 @@ Object.keys(_payment).forEach(function (key) {
|
|
|
243
243
|
}
|
|
244
244
|
});
|
|
245
245
|
});
|
|
246
|
+
var _subscription = require("./hooks/subscription");
|
|
247
|
+
Object.keys(_subscription).forEach(function (key) {
|
|
248
|
+
if (key === "default" || key === "__esModule") return;
|
|
249
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
250
|
+
if (key in exports && exports[key] === _subscription[key]) return;
|
|
251
|
+
Object.defineProperty(exports, key, {
|
|
252
|
+
enumerable: true,
|
|
253
|
+
get: function () {
|
|
254
|
+
return _subscription[key];
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
});
|
|
246
258
|
var _locales = require("./locales");
|
|
247
259
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -13,13 +13,16 @@ const api = _axios.default.create();
|
|
|
13
13
|
api.interceptors.request.use(config => {
|
|
14
14
|
const prefix = (0, _util.getPrefix)();
|
|
15
15
|
config.baseURL = prefix || "";
|
|
16
|
-
const livemode = localStorage.getItem("livemode");
|
|
17
16
|
const locale = (0, _context.getLocale)(window.blocklet?.languages);
|
|
17
|
+
const query = new URLSearchParams(config.url?.split("?").pop());
|
|
18
18
|
config.params = {
|
|
19
19
|
...(config.params || {}),
|
|
20
|
-
livemode: (0, _isNull.default)(livemode) ? true : JSON.parse(livemode),
|
|
21
20
|
locale
|
|
22
21
|
};
|
|
22
|
+
if (typeof config.params.livemode === "undefined" && query.has("livemode") === false) {
|
|
23
|
+
const livemode = localStorage.getItem("livemode");
|
|
24
|
+
config.params.livemode = (0, _isNull.default)(livemode) ? true : JSON.parse(livemode);
|
|
25
|
+
}
|
|
23
26
|
return config;
|
|
24
27
|
}, err => Promise.reject(err));
|
|
25
28
|
module.exports = api;
|
|
@@ -46,8 +46,8 @@ var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
|
|
|
46
46
|
var _numbro = _interopRequireDefault(require("numbro"));
|
|
47
47
|
var _reactInternationalPhone = require("react-international-phone");
|
|
48
48
|
var _ufo = require("ufo");
|
|
49
|
+
var _locales = require("../locales");
|
|
49
50
|
var _dayjs = _interopRequireDefault(require("./dayjs"));
|
|
50
|
-
var _locales = require("./locales");
|
|
51
51
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
52
52
|
const PAYMENT_KIT_DID = exports.PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
53
53
|
const isPaymentKitMounted = () => {
|
package/lib/locales/en.js
CHANGED
|
@@ -270,6 +270,7 @@ module.exports = (0, _flat.default)({
|
|
|
270
270
|
title: "Manage subscriptions",
|
|
271
271
|
view: "View Subscription",
|
|
272
272
|
current: "Current subscription",
|
|
273
|
+
viewAll: "View all",
|
|
273
274
|
empty: "There are no subscriptions here",
|
|
274
275
|
changePayment: "Change payment method"
|
|
275
276
|
}
|
package/lib/locales/zh.js
CHANGED
|
@@ -270,6 +270,7 @@ module.exports = (0, _flat.default)({
|
|
|
270
270
|
title: "\u8BA2\u9605\u7BA1\u7406",
|
|
271
271
|
view: "\u7BA1\u7406\u8BA2\u9605",
|
|
272
272
|
current: "\u5F53\u524D\u8BA2\u9605",
|
|
273
|
+
viewAll: "\u67E5\u770B\u6240\u6709",
|
|
273
274
|
empty: "\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605",
|
|
274
275
|
changePayment: "\u5207\u6362\u652F\u4ED8\u65B9\u5F0F"
|
|
275
276
|
}
|
|
@@ -19,11 +19,12 @@ var _reactHookForm = require("react-hook-form");
|
|
|
19
19
|
var _ufo = require("ufo");
|
|
20
20
|
var _useBus = require("use-bus");
|
|
21
21
|
var _isEmail = _interopRequireDefault(require("validator/es/lib/isEmail"));
|
|
22
|
-
var _api = _interopRequireDefault(require("../../api"));
|
|
23
22
|
var _confirm = _interopRequireDefault(require("../../components/confirm"));
|
|
24
23
|
var _input = _interopRequireDefault(require("../../components/input"));
|
|
25
24
|
var _payment = require("../../contexts/payment");
|
|
26
|
-
var
|
|
25
|
+
var _subscription = require("../../hooks/subscription");
|
|
26
|
+
var _api = _interopRequireDefault(require("../../libs/api"));
|
|
27
|
+
var _util = require("../../libs/util");
|
|
27
28
|
var _addon = _interopRequireDefault(require("./addon"));
|
|
28
29
|
var _address = _interopRequireDefault(require("./address"));
|
|
29
30
|
var _currency = _interopRequireDefault(require("./currency"));
|
|
@@ -72,6 +73,7 @@ function PaymentForm({
|
|
|
72
73
|
session,
|
|
73
74
|
connect
|
|
74
75
|
} = (0, _payment.usePaymentContext)();
|
|
76
|
+
const subscription = (0, _subscription.useSubscription)("events");
|
|
75
77
|
const {
|
|
76
78
|
control,
|
|
77
79
|
getValues,
|
|
@@ -90,6 +92,26 @@ function PaymentForm({
|
|
|
90
92
|
});
|
|
91
93
|
const currencies = (0, _util.flattenPaymentMethods)(paymentMethods);
|
|
92
94
|
const [paymentCurrencyIndex, setPaymentCurrencyIndex] = (0, _react.useState)(0);
|
|
95
|
+
const onCheckoutComplete = (0, _ahooks.useMemoizedFn)(async ({
|
|
96
|
+
response
|
|
97
|
+
}) => {
|
|
98
|
+
if (response.id === checkoutSession.id && state.paid === false) {
|
|
99
|
+
await handleConnected();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const onInvoicePaid = (0, _ahooks.useMemoizedFn)(async ({
|
|
103
|
+
response
|
|
104
|
+
}) => {
|
|
105
|
+
if (response.customer_id === customer?.id && state.customerLimited) {
|
|
106
|
+
await onAction();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
(0, _react.useEffect)(() => {
|
|
110
|
+
if (subscription) {
|
|
111
|
+
subscription.on("checkout.session.completed", onCheckoutComplete);
|
|
112
|
+
subscription.on("invoice.paid", onInvoicePaid);
|
|
113
|
+
}
|
|
114
|
+
}, [subscription]);
|
|
93
115
|
(0, _react.useEffect)(() => {
|
|
94
116
|
if (session?.user) {
|
|
95
117
|
const values = getValues();
|
|
@@ -150,11 +172,13 @@ function PaymentForm({
|
|
|
150
172
|
const handleConnected = async () => {
|
|
151
173
|
try {
|
|
152
174
|
const result = await waitForCheckoutComplete(checkoutSession.id);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
175
|
+
if (state.paid === false) {
|
|
176
|
+
setState({
|
|
177
|
+
paid: true,
|
|
178
|
+
paying: false
|
|
179
|
+
});
|
|
180
|
+
onPaid(result);
|
|
181
|
+
}
|
|
158
182
|
} catch (err) {
|
|
159
183
|
_Toast.default.error((0, _util.formatError)(err));
|
|
160
184
|
} finally {
|
|
@@ -208,7 +232,8 @@ function PaymentForm({
|
|
|
208
232
|
paymentIntent: result.data.paymentIntent,
|
|
209
233
|
stripeContext: result.data.stripeContext,
|
|
210
234
|
customer: result.data.customer,
|
|
211
|
-
submitting: false
|
|
235
|
+
submitting: false,
|
|
236
|
+
customerLimited: false
|
|
212
237
|
});
|
|
213
238
|
if (["arcblock", "ethereum"].includes(method.type)) {
|
|
214
239
|
setState({
|
|
@@ -465,7 +490,8 @@ function PaymentForm({
|
|
|
465
490
|
}),
|
|
466
491
|
confirm: t("payment.customer.pastDue.alert.confirm"),
|
|
467
492
|
title: t("payment.customer.pastDue.alert.title"),
|
|
468
|
-
message: t("payment.customer.pastDue.alert.description")
|
|
493
|
+
message: t("payment.customer.pastDue.alert.description"),
|
|
494
|
+
color: "primary"
|
|
469
495
|
})]
|
|
470
496
|
});
|
|
471
497
|
}
|
|
@@ -11,7 +11,7 @@ var _react = require("react");
|
|
|
11
11
|
var _reactHookForm = require("react-hook-form");
|
|
12
12
|
var _reactInternationalPhone = require("react-international-phone");
|
|
13
13
|
var _input = _interopRequireDefault(require("../../components/input"));
|
|
14
|
-
var _util = require("../../util");
|
|
14
|
+
var _util = require("../../libs/util");
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
function PhoneInput({
|
|
17
17
|
...props
|
package/lib/payment/header.js
CHANGED
|
@@ -9,7 +9,7 @@ var _Theme = require("@arcblock/ux/lib/Theme");
|
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _ahooks = require("ahooks");
|
|
11
11
|
var _livemode = _interopRequireDefault(require("../components/livemode"));
|
|
12
|
-
var _util = require("../util");
|
|
12
|
+
var _util = require("../libs/util");
|
|
13
13
|
var _addon = _interopRequireDefault(require("./form/addon"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function PaymentHeader({
|
package/lib/payment/index.js
CHANGED
|
@@ -16,9 +16,9 @@ var _util = require("@ocap/util");
|
|
|
16
16
|
var _ahooks = require("ahooks");
|
|
17
17
|
var _react = require("react");
|
|
18
18
|
var _reactHookForm = require("react-hook-form");
|
|
19
|
-
var _api = _interopRequireDefault(require("../api"));
|
|
20
19
|
var _payment = require("../contexts/payment");
|
|
21
|
-
var
|
|
20
|
+
var _api = _interopRequireDefault(require("../libs/api"));
|
|
21
|
+
var _util2 = require("../libs/util");
|
|
22
22
|
var _error = _interopRequireDefault(require("./error"));
|
|
23
23
|
var _footer = _interopRequireDefault(require("./footer"));
|
|
24
24
|
var _form = _interopRequireDefault(require("./form"));
|
|
@@ -407,6 +407,13 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
|
|
|
407
407
|
margin-top: ${props => props.mode === "standalone" ? "64px" : "0"};
|
|
408
408
|
}
|
|
409
409
|
.cko-product-summary {
|
|
410
|
+
width: 100%;
|
|
411
|
+
}
|
|
412
|
+
.cko-ellipsis {
|
|
413
|
+
width: 100%;
|
|
414
|
+
white-space: nowrap;
|
|
415
|
+
overflow: hidden;
|
|
416
|
+
text-overflow: ellipsis;
|
|
410
417
|
}
|
|
411
418
|
|
|
412
419
|
.cko-payment {
|
|
@@ -23,6 +23,9 @@ function ProductCard({
|
|
|
23
23
|
alignItems: "flex-start",
|
|
24
24
|
spacing: 1,
|
|
25
25
|
flex: 2,
|
|
26
|
+
sx: {
|
|
27
|
+
width: "100%"
|
|
28
|
+
},
|
|
26
29
|
children: [logo ?
|
|
27
30
|
// @ts-ignore
|
|
28
31
|
/* @__PURE__ */
|
|
@@ -42,8 +45,14 @@ function ProductCard({
|
|
|
42
45
|
direction: "column",
|
|
43
46
|
alignItems: "flex-start",
|
|
44
47
|
justifyContent: "space-around",
|
|
48
|
+
sx: {
|
|
49
|
+
flexShrink: 1,
|
|
50
|
+
overflow: "hidden"
|
|
51
|
+
},
|
|
45
52
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
53
|
+
className: "cko-ellipsis",
|
|
46
54
|
variant: "body1",
|
|
55
|
+
title: name,
|
|
47
56
|
sx: {
|
|
48
57
|
fontWeight: 500,
|
|
49
58
|
mb: 0.5,
|
|
@@ -53,6 +62,7 @@ function ProductCard({
|
|
|
53
62
|
children: name
|
|
54
63
|
}), description && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
55
64
|
variant: "body1",
|
|
65
|
+
title: description,
|
|
56
66
|
sx: {
|
|
57
67
|
fontSize: "0.85rem",
|
|
58
68
|
mb: 0.5,
|
|
@@ -9,7 +9,7 @@ var _context = require("@arcblock/ux/lib/Locale/context");
|
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _status = _interopRequireDefault(require("../components/status"));
|
|
11
11
|
var _switchButton = _interopRequireDefault(require("../components/switch-button"));
|
|
12
|
-
var _util = require("../util");
|
|
12
|
+
var _util = require("../libs/util");
|
|
13
13
|
var _productCard = _interopRequireDefault(require("./product-card"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
ProductItem.defaultProps = {
|
|
@@ -49,7 +49,8 @@ function ProductItem({
|
|
|
49
49
|
},
|
|
50
50
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
51
51
|
direction: "row",
|
|
52
|
-
alignItems: "
|
|
52
|
+
alignItems: "flex-start",
|
|
53
|
+
spacing: 0.5,
|
|
53
54
|
justifyContent: "space-between",
|
|
54
55
|
sx: {
|
|
55
56
|
width: "100%"
|
package/lib/payment/summary.js
CHANGED
|
@@ -13,9 +13,9 @@ var _util = require("@ocap/util");
|
|
|
13
13
|
var _ahooks = require("ahooks");
|
|
14
14
|
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
15
15
|
var _useBus = _interopRequireDefault(require("use-bus"));
|
|
16
|
-
var _api = _interopRequireDefault(require("../api"));
|
|
17
16
|
var _status = _interopRequireDefault(require("../components/status"));
|
|
18
|
-
var
|
|
17
|
+
var _api = _interopRequireDefault(require("../libs/api"));
|
|
18
|
+
var _util2 = require("../libs/util");
|
|
19
19
|
var _amount = _interopRequireDefault(require("./amount"));
|
|
20
20
|
var _productDonation = _interopRequireDefault(require("./product-donation"));
|
|
21
21
|
var _productItem = _interopRequireDefault(require("./product-item"));
|
|
@@ -182,7 +182,9 @@ function PaymentSummary({
|
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
185
|
+
className: "cko-ellipsis",
|
|
185
186
|
component: "div",
|
|
187
|
+
title: action || headlines.action,
|
|
186
188
|
sx: {
|
|
187
189
|
fontWeight: 500,
|
|
188
190
|
fontSize: "1.15rem",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.242",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@arcblock/did-connect": "^2.9.77",
|
|
56
56
|
"@arcblock/ux": "^2.9.77",
|
|
57
|
+
"@arcblock/ws": "^1.18.116",
|
|
57
58
|
"@mui/icons-material": "^5.15.16",
|
|
58
59
|
"@mui/lab": "^5.0.0-alpha.170",
|
|
59
60
|
"@mui/material": "^5.15.16",
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
"@babel/core": "^7.24.5",
|
|
91
92
|
"@babel/preset-env": "^7.24.5",
|
|
92
93
|
"@babel/preset-react": "^7.24.1",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
94
|
+
"@blocklet/payment-types": "1.13.242",
|
|
94
95
|
"@storybook/addon-essentials": "^7.6.19",
|
|
95
96
|
"@storybook/addon-interactions": "^7.6.19",
|
|
96
97
|
"@storybook/addon-links": "^7.6.19",
|
|
@@ -119,5 +120,5 @@
|
|
|
119
120
|
"vite-plugin-babel": "^1.2.0",
|
|
120
121
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
121
122
|
},
|
|
122
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "ec356f3a242ca99c4f86cc2707dc7057c3f2c38d"
|
|
123
124
|
}
|
package/src/checkout/donate.tsx
CHANGED
|
@@ -27,10 +27,10 @@ import omit from 'lodash/omit';
|
|
|
27
27
|
import uniqBy from 'lodash/unionBy';
|
|
28
28
|
import { useEffect } from 'react';
|
|
29
29
|
|
|
30
|
-
import api from '../api';
|
|
31
30
|
import TxLink from '../components/blockchain/tx';
|
|
31
|
+
import api from '../libs/api';
|
|
32
|
+
import { formatBNStr, formatDateTime, formatError } from '../libs/util';
|
|
32
33
|
import { CheckoutProps } from '../types';
|
|
33
|
-
import { formatBNStr, formatDateTime, formatError } from '../util';
|
|
34
34
|
import CheckoutForm from './form';
|
|
35
35
|
|
|
36
36
|
export type DonateHistory = {
|
|
@@ -61,10 +61,10 @@ const createOrUpdateDonation = (settings: DonationSettings, livemode: boolean =
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const supporterCache: { [key: string]: Promise<DonateHistory> } = {};
|
|
64
|
-
const fetchSupporters = (target: string): Promise<DonateHistory> => {
|
|
64
|
+
const fetchSupporters = (target: string, livemode: boolean = true): Promise<DonateHistory> => {
|
|
65
65
|
if (!supporterCache[target]) {
|
|
66
66
|
supporterCache[target] = api
|
|
67
|
-
.get('/api/donations', { params: { target } })
|
|
67
|
+
.get('/api/donations', { params: { target, livemode } })
|
|
68
68
|
.then((res) => res.data)
|
|
69
69
|
.finally(() => {
|
|
70
70
|
setTimeout(() => {
|
|
@@ -178,7 +178,9 @@ export default function CheckoutDonate({ settings, livemode, onPaid, onError }:
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
const donation = useRequest(() => createOrUpdateDonation(settings, livemode));
|
|
181
|
-
const supporters = useRequest(() =>
|
|
181
|
+
const supporters = useRequest(() =>
|
|
182
|
+
donation.data ? fetchSupporters(donation.data.id, livemode) : Promise.resolve({})
|
|
183
|
+
);
|
|
182
184
|
|
|
183
185
|
useEffect(() => {
|
|
184
186
|
if (donation.data && state.supporterLoaded === false) {
|
package/src/checkout/form.tsx
CHANGED
|
@@ -4,10 +4,10 @@ import noop from 'lodash/noop';
|
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { joinURL } from 'ufo';
|
|
6
6
|
|
|
7
|
-
import api from '../api';
|
|
7
|
+
import api from '../libs/api';
|
|
8
|
+
import { getPrefix, mergeExtraParams } from '../libs/util';
|
|
8
9
|
import Payment from '../payment';
|
|
9
10
|
import { CheckoutContext, CheckoutProps } from '../types';
|
|
10
|
-
import { getPrefix, mergeExtraParams } from '../util';
|
|
11
11
|
|
|
12
12
|
const promises: { [key: string]: Promise<any> } = {};
|
|
13
13
|
const startFromPaymentLink = (id: string, params?: Record<string, any>): Promise<CheckoutContext> => {
|
package/src/checkout/table.tsx
CHANGED
|
@@ -6,11 +6,11 @@ import { Box } from '@mui/system';
|
|
|
6
6
|
import { useRequest } from 'ahooks';
|
|
7
7
|
import { useState } from 'react';
|
|
8
8
|
|
|
9
|
-
import api from '../api';
|
|
10
9
|
import Livemode from '../components/livemode';
|
|
11
10
|
import PricingTable from '../components/pricing-table';
|
|
11
|
+
import api from '../libs/api';
|
|
12
|
+
import { mergeExtraParams } from '../libs/util';
|
|
12
13
|
import { CheckoutProps } from '../types';
|
|
13
|
-
import { mergeExtraParams } from '../util';
|
|
14
14
|
import CheckoutForm from './form';
|
|
15
15
|
|
|
16
16
|
const fetchData = async (id: string): Promise<TPricingTableExpanded> => {
|
|
@@ -4,7 +4,7 @@ import { Typography } from '@mui/material';
|
|
|
4
4
|
import { fromUnitToToken } from '@ocap/util';
|
|
5
5
|
|
|
6
6
|
import { usePaymentContext } from '../../contexts/payment';
|
|
7
|
-
import { getTxLink } from '../../util';
|
|
7
|
+
import { getTxLink } from '../../libs/util';
|
|
8
8
|
|
|
9
9
|
TxGas.defaultProps = {};
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
|
3
3
|
import { OpenInNewOutlined } from '@mui/icons-material';
|
|
4
4
|
import { Link, Stack, Typography } from '@mui/material';
|
|
5
5
|
|
|
6
|
-
import { getTxLink } from '../../util';
|
|
6
|
+
import { getTxLink } from '../../libs/util';
|
|
7
7
|
|
|
8
8
|
TxLink.defaultProps = {
|
|
9
9
|
mode: 'dashboard',
|
|
@@ -9,6 +9,7 @@ export default function ConfirmDialog({
|
|
|
9
9
|
title,
|
|
10
10
|
message,
|
|
11
11
|
confirm,
|
|
12
|
+
color,
|
|
12
13
|
cancel,
|
|
13
14
|
loading,
|
|
14
15
|
}: {
|
|
@@ -17,7 +18,8 @@ export default function ConfirmDialog({
|
|
|
17
18
|
title: string | React.ReactNode;
|
|
18
19
|
message: string | React.ReactNode;
|
|
19
20
|
confirm?: string | React.ReactNode;
|
|
20
|
-
|
|
21
|
+
color?: string;
|
|
22
|
+
cancel?: boolean | string | React.ReactNode;
|
|
21
23
|
loading?: boolean;
|
|
22
24
|
}) {
|
|
23
25
|
const { t } = useLocaleContext();
|
|
@@ -30,9 +32,10 @@ export default function ConfirmDialog({
|
|
|
30
32
|
onCancel={onCancel}
|
|
31
33
|
confirmButton={{
|
|
32
34
|
text: confirm || t('common.confirm'),
|
|
33
|
-
props: { color
|
|
35
|
+
props: { color, size: 'small', variant: 'contained', disabled: !!loading },
|
|
34
36
|
}}
|
|
35
|
-
cancelButton={{ text: cancel || t('common.cancel'), props: { color: 'inherit', size: 'small' } }}
|
|
37
|
+
cancelButton={{ text: cancel || t('common.cancel'), props: { color: 'inherit', size: 'small' } }}
|
|
38
|
+
showCancelButton={typeof cancel !== 'boolean' || !!cancel}>
|
|
36
39
|
<Typography>{message}</Typography>
|
|
37
40
|
</Confirm>
|
|
38
41
|
);
|
|
@@ -42,4 +45,5 @@ ConfirmDialog.defaultProps = {
|
|
|
42
45
|
loading: false,
|
|
43
46
|
confirm: '',
|
|
44
47
|
cancel: '',
|
|
48
|
+
color: 'error',
|
|
45
49
|
};
|
|
@@ -20,8 +20,8 @@ import { styled } from '@mui/system';
|
|
|
20
20
|
import { useSetState } from 'ahooks';
|
|
21
21
|
import { useEffect, useState } from 'react';
|
|
22
22
|
|
|
23
|
+
import { formatError, formatPriceAmount, formatRecurring } from '../libs/util';
|
|
23
24
|
import Amount from '../payment/amount';
|
|
24
|
-
import { formatError, formatPriceAmount, formatRecurring } from '../util';
|
|
25
25
|
|
|
26
26
|
const groupItemsByRecurring = (items: TPricingTableItem[]) => {
|
|
27
27
|
const grouped: { [key: string]: TPricingTableItem[] } = {};
|
package/src/contexts/payment.tsx
CHANGED
|
@@ -4,8 +4,8 @@ import { useLocalStorageState, useRequest } from 'ahooks';
|
|
|
4
4
|
import type { Axios } from 'axios';
|
|
5
5
|
import { createContext, useContext } from 'react';
|
|
6
6
|
|
|
7
|
-
import api from '../api';
|
|
8
|
-
import { getPrefix } from '../util';
|
|
7
|
+
import api from '../libs/api';
|
|
8
|
+
import { getPrefix } from '../libs/util';
|
|
9
9
|
|
|
10
10
|
const prefix = getPrefix();
|
|
11
11
|
|