@blocklet/payment-react 1.13.129 → 1.13.131
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/blockchain/tx.d.ts +13 -0
- package/es/components/blockchain/tx.js +52 -0
- package/es/history/invoice/list.d.ts +13 -0
- package/es/{histroy → history}/invoice/list.js +12 -5
- package/es/history/mini-invoice/list.d.ts +2 -0
- package/es/{histroy → history}/mini-invoice/list.js +42 -35
- package/es/{histroy → history}/payment/list.js +10 -1
- package/es/index.d.ts +5 -4
- package/es/index.js +6 -4
- package/es/locales/en.js +4 -4
- package/es/locales/zh.js +3 -3
- package/es/util.js +5 -2
- package/lib/components/blockchain/tx.d.ts +13 -0
- package/lib/components/blockchain/tx.js +82 -0
- package/lib/history/invoice/list.d.ts +13 -0
- package/lib/{histroy → history}/invoice/list.js +14 -5
- package/lib/history/mini-invoice/list.d.ts +2 -0
- package/lib/{histroy → history}/mini-invoice/list.js +70 -59
- package/lib/{histroy → history}/payment/list.js +12 -1
- package/lib/index.d.ts +5 -4
- package/lib/index.js +11 -3
- package/lib/locales/en.js +4 -4
- package/lib/locales/zh.js +3 -3
- package/lib/util.js +5 -2
- package/package.json +3 -3
- package/src/components/blockchain/tx.tsx +77 -0
- package/src/{histroy → history}/invoice/list.tsx +15 -6
- package/src/{histroy → history}/mini-invoice/list.tsx +52 -49
- package/src/{histroy → history}/payment/list.tsx +11 -1
- package/src/index.ts +5 -3
- package/src/locales/en.tsx +4 -4
- package/src/locales/zh.tsx +3 -3
- package/src/util.ts +5 -2
- package/es/histroy/invoice/list.d.ts +0 -6
- package/es/histroy/mini-invoice/list.d.ts +0 -7
- package/lib/histroy/invoice/list.d.ts +0 -6
- package/lib/histroy/mini-invoice/list.d.ts +0 -7
- /package/es/{histroy → history}/payment/list.d.ts +0 -0
- /package/lib/{histroy → history}/payment/list.d.ts +0 -0
|
@@ -9,51 +9,43 @@ var _context = require("@arcblock/ux/lib/Locale/context");
|
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _util = require("@ocap/util");
|
|
11
11
|
var _ahooks = require("ahooks");
|
|
12
|
+
var _ufo = require("ufo");
|
|
12
13
|
var _api = _interopRequireDefault(require("../../api"));
|
|
13
14
|
var _status = _interopRequireDefault(require("../../components/status"));
|
|
14
15
|
var _util2 = require("../../util");
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
const
|
|
17
|
+
const fetchInvoiceData = (params = {}) => {
|
|
17
18
|
const search = new URLSearchParams();
|
|
18
19
|
Object.keys(params).forEach(key => {
|
|
19
20
|
search.set(key, String(params[key]));
|
|
20
21
|
});
|
|
21
22
|
return _api.default.get(`/api/invoices?${search.toString()}`).then(res => res.data);
|
|
22
23
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const fetchSubscriptionData = id => {
|
|
25
|
+
return _api.default.get(`/api/subscriptions/${id}`).then(res => res.data);
|
|
26
|
+
};
|
|
27
|
+
function MiniInvoiceList() {
|
|
27
28
|
const {
|
|
28
29
|
t
|
|
29
30
|
} = (0, _context.useLocaleContext)();
|
|
31
|
+
const subscriptionId = new URL(window.location.href).searchParams.get("id");
|
|
30
32
|
const {
|
|
31
|
-
data
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
reloadDeps: [subscription.id]
|
|
43
|
-
});
|
|
44
|
-
if (loading || !data) {
|
|
33
|
+
data: subscription
|
|
34
|
+
} = (0, _ahooks.useRequest)(() => fetchSubscriptionData(subscriptionId));
|
|
35
|
+
const {
|
|
36
|
+
data
|
|
37
|
+
} = (0, _ahooks.useRequest)(() => fetchInvoiceData({
|
|
38
|
+
page: 1,
|
|
39
|
+
pageSize: 10,
|
|
40
|
+
status: "open,paid,uncollectible",
|
|
41
|
+
subscription_id: subscriptionId
|
|
42
|
+
}));
|
|
43
|
+
if (!subscription || !data) {
|
|
45
44
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Position, {
|
|
46
45
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Position, {
|
|
51
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
52
|
-
color: "text.secondary",
|
|
53
|
-
children: t("payment.customer.invoice.empty")
|
|
54
|
-
})
|
|
55
|
-
});
|
|
56
|
-
}
|
|
48
|
+
const invoices = data.list || [];
|
|
57
49
|
const infoList = [{
|
|
58
50
|
name: t("payment.customer.subscriptions.plan"),
|
|
59
51
|
value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
@@ -64,25 +56,30 @@ function MiniInvoiceList({
|
|
|
64
56
|
children: (0, _util2.formatSubscriptionProduct)(subscription.items)
|
|
65
57
|
})
|
|
66
58
|
}, {
|
|
67
|
-
name: t("
|
|
59
|
+
name: t("common.status"),
|
|
68
60
|
value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
69
61
|
label: subscription.status,
|
|
70
62
|
color: (0, _util2.getSubscriptionStatusColor)(subscription.status)
|
|
71
63
|
})
|
|
72
|
-
}, {
|
|
73
|
-
name: t("payment.customer.subscriptions.nextInvoice"),
|
|
74
|
-
value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
75
|
-
sx: {
|
|
76
|
-
color: "#34BE74",
|
|
77
|
-
fontWeight: "bold"
|
|
78
|
-
},
|
|
79
|
-
children: (0, _util2.formatTime)(subscription.current_period_end * 1e3)
|
|
80
|
-
})
|
|
81
64
|
}];
|
|
65
|
+
if (subscription.status === "active" || subscription.status === "trailing") {
|
|
66
|
+
infoList.push({
|
|
67
|
+
name: t("payment.customer.subscriptions.nextInvoice"),
|
|
68
|
+
value: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
69
|
+
sx: {
|
|
70
|
+
color: "#34BE74",
|
|
71
|
+
fontWeight: "bold",
|
|
72
|
+
marginRight: "10px"
|
|
73
|
+
},
|
|
74
|
+
children: (0, _util2.formatTime)(subscription.current_period_end * 1e3)
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
}
|
|
82
78
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(Position, {
|
|
83
79
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
84
80
|
title: t("payment.checkout.subscription")
|
|
85
81
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
82
|
+
className: "mini-invoice-wrap",
|
|
86
83
|
sx: {
|
|
87
84
|
display: "flex",
|
|
88
85
|
flexDirection: "column",
|
|
@@ -127,17 +124,14 @@ function MiniInvoiceList({
|
|
|
127
124
|
})
|
|
128
125
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
129
126
|
sx: {
|
|
130
|
-
marginTop: "12px"
|
|
127
|
+
marginTop: "12px",
|
|
128
|
+
flex: 1
|
|
131
129
|
},
|
|
132
130
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.List, {
|
|
133
131
|
sx: {
|
|
134
|
-
overflow: "auto"
|
|
135
|
-
maxHeight: {
|
|
136
|
-
xs: "240px",
|
|
137
|
-
md: "360px",
|
|
138
|
-
padding: 0
|
|
139
|
-
}
|
|
132
|
+
overflow: "auto"
|
|
140
133
|
},
|
|
134
|
+
className: "mini-invoice-list",
|
|
141
135
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ListSubheader, {
|
|
142
136
|
disableGutters: true,
|
|
143
137
|
sx: {
|
|
@@ -149,7 +143,10 @@ function MiniInvoiceList({
|
|
|
149
143
|
fontSize: "16px",
|
|
150
144
|
children: t("payment.customer.invoices")
|
|
151
145
|
})
|
|
152
|
-
}),
|
|
146
|
+
}), invoices.length === 0 ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
147
|
+
color: "text.secondary",
|
|
148
|
+
children: t("payment.customer.invoice.empty")
|
|
149
|
+
}) : invoices.map(item => {
|
|
153
150
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.ListItem, {
|
|
154
151
|
disableGutters: true,
|
|
155
152
|
sx: {
|
|
@@ -158,25 +155,43 @@ function MiniInvoiceList({
|
|
|
158
155
|
},
|
|
159
156
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
160
157
|
component: "span",
|
|
158
|
+
sx: {
|
|
159
|
+
flex: 3
|
|
160
|
+
},
|
|
161
161
|
children: (0, _util2.formatToDate)(item.created_at)
|
|
162
162
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
163
163
|
component: "span",
|
|
164
|
+
sx: {
|
|
165
|
+
flex: 1,
|
|
166
|
+
textAlign: "right"
|
|
167
|
+
},
|
|
164
168
|
children: [(0, _util.fromUnitToToken)(item.total, item.paymentCurrency.decimal), "\xA0", item.paymentCurrency.symbol]
|
|
165
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
170
|
+
component: "span",
|
|
171
|
+
sx: {
|
|
172
|
+
flex: 2,
|
|
173
|
+
textAlign: "right"
|
|
174
|
+
},
|
|
175
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
176
|
+
label: item.status,
|
|
177
|
+
color: (0, _util2.getInvoiceStatusColor)(item.status),
|
|
178
|
+
sx: {
|
|
179
|
+
flex: 2
|
|
180
|
+
}
|
|
181
|
+
})
|
|
168
182
|
})]
|
|
169
183
|
}, item.id);
|
|
170
184
|
})]
|
|
171
185
|
})
|
|
172
186
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
173
|
-
target: "
|
|
187
|
+
target: "_blank",
|
|
174
188
|
variant: "contained",
|
|
175
189
|
sx: {
|
|
176
|
-
marginTop: "
|
|
177
|
-
width: "100%"
|
|
190
|
+
marginTop: "10px 0",
|
|
191
|
+
width: "100%",
|
|
192
|
+
color: "#fff!important"
|
|
178
193
|
},
|
|
179
|
-
href:
|
|
194
|
+
href: (0, _ufo.joinURL)(window.location.origin, (0, _util2.getPrefix)(), `/customer/subscription/${subscription.id}`),
|
|
180
195
|
children: t("payment.customer.subscriptions.title")
|
|
181
196
|
})]
|
|
182
197
|
})]
|
|
@@ -188,15 +203,11 @@ function Position({
|
|
|
188
203
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
189
204
|
className: "mini-invoice-box",
|
|
190
205
|
sx: {
|
|
191
|
-
position: "absolute",
|
|
192
|
-
right: 0,
|
|
193
|
-
top: "30px",
|
|
194
|
-
justifyContent: "center",
|
|
195
206
|
padding: "8px",
|
|
196
|
-
|
|
207
|
+
width: "100%",
|
|
208
|
+
maxWidth: "500px",
|
|
197
209
|
background: "#fff",
|
|
198
|
-
|
|
199
|
-
boxShadow: "0 4px 8px rgba(0, 0, 0, 20%)"
|
|
210
|
+
margin: "0 auto"
|
|
200
211
|
},
|
|
201
212
|
children
|
|
202
213
|
});
|
|
@@ -10,6 +10,7 @@ var _material = require("@mui/material");
|
|
|
10
10
|
var _util = require("@ocap/util");
|
|
11
11
|
var _ahooks = require("ahooks");
|
|
12
12
|
var _api = _interopRequireDefault(require("../../api"));
|
|
13
|
+
var _tx = _interopRequireDefault(require("../../components/blockchain/tx"));
|
|
13
14
|
var _status = _interopRequireDefault(require("../../components/status"));
|
|
14
15
|
var _util2 = require("../../util");
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -111,10 +112,20 @@ function CustomerPaymentList({
|
|
|
111
112
|
color: (0, _util2.getPaymentIntentStatusColor)(item.status)
|
|
112
113
|
})
|
|
113
114
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
114
|
-
flex:
|
|
115
|
+
flex: 3,
|
|
115
116
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
116
117
|
children: item.description || item.id
|
|
117
118
|
})
|
|
119
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
120
|
+
flex: 3,
|
|
121
|
+
sx: {
|
|
122
|
+
minWidth: "220px"
|
|
123
|
+
},
|
|
124
|
+
children: item.payment_details?.arcblock?.tx_hash && /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
|
|
125
|
+
details: item.payment_details,
|
|
126
|
+
method: item.paymentMethod,
|
|
127
|
+
mode: "customer"
|
|
128
|
+
})
|
|
118
129
|
})]
|
|
119
130
|
}, item.id))]
|
|
120
131
|
}, date)), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import api from './api';
|
|
2
2
|
import CheckoutForm from './checkout/form';
|
|
3
3
|
import CheckoutTable from './checkout/table';
|
|
4
|
+
import TxLink from './components/blockchain/tx';
|
|
4
5
|
import ConfirmDialog from './components/confirm';
|
|
5
6
|
import FormInput from './components/input';
|
|
6
7
|
import Livemode from './components/livemode';
|
|
@@ -8,9 +9,9 @@ import PricingTable from './components/pricing-table';
|
|
|
8
9
|
import Status from './components/status';
|
|
9
10
|
import Switch from './components/switch-button';
|
|
10
11
|
import dayjs from './dayjs';
|
|
11
|
-
import CustomerInvoiceList from './
|
|
12
|
-
import MiniInvoiceList from './
|
|
13
|
-
import CustomerPaymentList from './
|
|
12
|
+
import CustomerInvoiceList from './history/invoice/list';
|
|
13
|
+
import MiniInvoiceList from './history/mini-invoice/list';
|
|
14
|
+
import CustomerPaymentList from './history/payment/list';
|
|
14
15
|
import Amount from './payment/amount';
|
|
15
16
|
import PhoneInput from './payment/form/phone';
|
|
16
17
|
import Payment from './payment/index';
|
|
@@ -18,4 +19,4 @@ import ProductSkeleton from './payment/product-skeleton';
|
|
|
18
19
|
export * from './util';
|
|
19
20
|
export * from './contexts/payment';
|
|
20
21
|
export { translations, createTranslator } from './locales';
|
|
21
|
-
export { api, dayjs, FormInput, PhoneInput, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, Payment, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, };
|
|
22
|
+
export { api, dayjs, FormInput, PhoneInput, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, Payment, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var _exportNames = {
|
|
|
7
7
|
api: true,
|
|
8
8
|
CheckoutForm: true,
|
|
9
9
|
CheckoutTable: true,
|
|
10
|
+
TxLink: true,
|
|
10
11
|
ConfirmDialog: true,
|
|
11
12
|
FormInput: true,
|
|
12
13
|
Livemode: true,
|
|
@@ -114,6 +115,12 @@ Object.defineProperty(exports, "Switch", {
|
|
|
114
115
|
return _switchButton.default;
|
|
115
116
|
}
|
|
116
117
|
});
|
|
118
|
+
Object.defineProperty(exports, "TxLink", {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return _tx.default;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
117
124
|
Object.defineProperty(exports, "api", {
|
|
118
125
|
enumerable: true,
|
|
119
126
|
get: function () {
|
|
@@ -141,6 +148,7 @@ Object.defineProperty(exports, "translations", {
|
|
|
141
148
|
var _api = _interopRequireDefault(require("./api"));
|
|
142
149
|
var _form = _interopRequireDefault(require("./checkout/form"));
|
|
143
150
|
var _table = _interopRequireDefault(require("./checkout/table"));
|
|
151
|
+
var _tx = _interopRequireDefault(require("./components/blockchain/tx"));
|
|
144
152
|
var _confirm = _interopRequireDefault(require("./components/confirm"));
|
|
145
153
|
var _input = _interopRequireDefault(require("./components/input"));
|
|
146
154
|
var _livemode = _interopRequireDefault(require("./components/livemode"));
|
|
@@ -148,9 +156,9 @@ var _pricingTable = _interopRequireDefault(require("./components/pricing-table")
|
|
|
148
156
|
var _status = _interopRequireDefault(require("./components/status"));
|
|
149
157
|
var _switchButton = _interopRequireDefault(require("./components/switch-button"));
|
|
150
158
|
var _dayjs = _interopRequireDefault(require("./dayjs"));
|
|
151
|
-
var _list = _interopRequireDefault(require("./
|
|
152
|
-
var _list2 = _interopRequireDefault(require("./
|
|
153
|
-
var _list3 = _interopRequireDefault(require("./
|
|
159
|
+
var _list = _interopRequireDefault(require("./history/invoice/list"));
|
|
160
|
+
var _list2 = _interopRequireDefault(require("./history/mini-invoice/list"));
|
|
161
|
+
var _list3 = _interopRequireDefault(require("./history/payment/list"));
|
|
154
162
|
var _amount = _interopRequireDefault(require("./payment/amount"));
|
|
155
163
|
var _phone = _interopRequireDefault(require("./payment/form/phone"));
|
|
156
164
|
var _index = _interopRequireDefault(require("./payment/index"));
|
package/lib/locales/en.js
CHANGED
|
@@ -209,17 +209,17 @@ module.exports = (0, _flat.default)({
|
|
|
209
209
|
pay: "Pay this invoice",
|
|
210
210
|
paySuccess: "You have successfully paid the invoice",
|
|
211
211
|
payError: "Failed to paid the invoice",
|
|
212
|
-
empty: "
|
|
212
|
+
empty: "There are no invoices here"
|
|
213
213
|
},
|
|
214
214
|
payment: {
|
|
215
|
-
empty: "
|
|
215
|
+
empty: "There are no payments here"
|
|
216
216
|
},
|
|
217
217
|
subscriptions: {
|
|
218
218
|
plan: "Plan",
|
|
219
219
|
nextInvoice: "Next Invoice",
|
|
220
220
|
title: "Manage subscriptions",
|
|
221
|
-
current: "Current
|
|
222
|
-
empty: "
|
|
221
|
+
current: "Current subscription",
|
|
222
|
+
empty: "There are no subscriptions here"
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
}
|
package/lib/locales/zh.js
CHANGED
|
@@ -209,17 +209,17 @@ module.exports = (0, _flat.default)({
|
|
|
209
209
|
pay: "\u652F\u4ED8\u6B64\u53D1\u7968",
|
|
210
210
|
paySuccess: "\u652F\u4ED8\u6210\u529F",
|
|
211
211
|
payError: "\u652F\u4ED8\u5931\u8D25",
|
|
212
|
-
empty: "\
|
|
212
|
+
empty: "\u6CA1\u6709\u4EFB\u4F55\u53D1\u7968"
|
|
213
213
|
},
|
|
214
214
|
payment: {
|
|
215
|
-
empty: "\
|
|
215
|
+
empty: "\u6CA1\u6709\u4EFB\u4F55\u652F\u4ED8"
|
|
216
216
|
},
|
|
217
217
|
subscriptions: {
|
|
218
218
|
plan: "\u8BA2\u9605",
|
|
219
219
|
nextInvoice: "\u4E0B\u4E00\u5F20\u53D1\u7968",
|
|
220
220
|
title: "\u8BA2\u9605\u7BA1\u7406",
|
|
221
221
|
current: "\u5F53\u524D\u8BA2\u9605",
|
|
222
|
-
empty: "\
|
|
222
|
+
empty: "\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605"
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
}
|
package/lib/util.js
CHANGED
|
@@ -282,9 +282,12 @@ function getWebhookStatusColor(status) {
|
|
|
282
282
|
}
|
|
283
283
|
function getCheckoutAmount(items, currency, includeFreeTrial = false, upsell = true) {
|
|
284
284
|
let renew = new _util.BN(0);
|
|
285
|
-
const total = items.
|
|
285
|
+
const total = items.filter(x => {
|
|
286
286
|
const price = upsell ? x.upsell_price || x.price : x.price;
|
|
287
|
-
|
|
287
|
+
return price != null;
|
|
288
|
+
}).reduce((acc, x) => {
|
|
289
|
+
const price = upsell ? x.upsell_price || x.price : x.price;
|
|
290
|
+
if (price?.type === "recurring") {
|
|
288
291
|
renew = renew.add(new _util.BN(getPriceUintAmountByCurrency(price, currency)).mul(new _util.BN(x.quantity)));
|
|
289
292
|
if (includeFreeTrial) {
|
|
290
293
|
return acc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.131",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@babel/core": "^7.19.3",
|
|
90
90
|
"@babel/preset-env": "^7.19.3",
|
|
91
91
|
"@babel/preset-react": "^7.18.6",
|
|
92
|
-
"@blocklet/payment-types": "1.13.
|
|
92
|
+
"@blocklet/payment-types": "1.13.131",
|
|
93
93
|
"@storybook/addon-essentials": "^7.6.10",
|
|
94
94
|
"@storybook/addon-interactions": "^7.6.10",
|
|
95
95
|
"@storybook/addon-links": "^7.6.10",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"vite-plugin-babel": "^1.2.0",
|
|
119
119
|
"vite-plugin-node-polyfills": "^0.19.0"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "a1a5072b1a0c564cce5ba4aee5fc4801cfef4a46"
|
|
122
122
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { PaymentDetails, TPaymentMethod } from '@blocklet/payment-types';
|
|
2
|
+
import { OpenInNewOutlined } from '@mui/icons-material';
|
|
3
|
+
import { Link, Stack, Typography } from '@mui/material';
|
|
4
|
+
import { joinURL } from 'ufo';
|
|
5
|
+
|
|
6
|
+
const getTxLink = (method: TPaymentMethod, details: PaymentDetails) => {
|
|
7
|
+
if (method.type === 'arcblock' && details.arcblock?.tx_hash) {
|
|
8
|
+
return {
|
|
9
|
+
link: joinURL(method.settings.arcblock?.explorer_host as string, '/txs', details.arcblock?.tx_hash as string),
|
|
10
|
+
text: details.arcblock?.tx_hash as string,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (method.type === 'bitcoin' && details.bitcoin?.tx_hash) {
|
|
14
|
+
return {
|
|
15
|
+
link: joinURL(method.settings.bitcoin?.explorer_host as string, '/tx', details.bitcoin?.tx_hash as string),
|
|
16
|
+
text: details.bitcoin?.tx_hash as string,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (method.type === 'ethereum' && details.ethereum?.tx_hash) {
|
|
20
|
+
return {
|
|
21
|
+
link: joinURL(method.settings.ethereum?.explorer_host as string, '/tx', details.ethereum?.tx_hash as string),
|
|
22
|
+
text: details.ethereum?.tx_hash as string,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (method.type === 'stripe') {
|
|
26
|
+
const dashboard = method.livemode ? 'https://dashboard.stripe.com' : 'https://dashboard.stripe.com/test';
|
|
27
|
+
return {
|
|
28
|
+
link: joinURL(
|
|
29
|
+
method.settings.stripe?.dashboard || dashboard,
|
|
30
|
+
'payments',
|
|
31
|
+
details.stripe?.payment_intent_id as string
|
|
32
|
+
),
|
|
33
|
+
text: details.stripe?.payment_intent_id as string,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { text: 'N/A', link: '' };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
TxLink.defaultProps = {
|
|
41
|
+
mode: 'dashboard',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default function TxLink(props: {
|
|
45
|
+
details: PaymentDetails;
|
|
46
|
+
method: TPaymentMethod;
|
|
47
|
+
mode?: 'customer' | 'dashboard';
|
|
48
|
+
}) {
|
|
49
|
+
if (!props.details || (props.mode === 'customer' && props.method.type === 'stripe')) {
|
|
50
|
+
return (
|
|
51
|
+
<Typography component="small" color="text.secondary">
|
|
52
|
+
None
|
|
53
|
+
</Typography>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const { text, link } = getTxLink(props.method, props.details);
|
|
58
|
+
|
|
59
|
+
if (link) {
|
|
60
|
+
return (
|
|
61
|
+
<Link href={link} target="_blank" rel="noopener noreferrer">
|
|
62
|
+
<Stack component="span" direction="row" alignItems="center" spacing={1}>
|
|
63
|
+
<Typography component="span" color="primary">
|
|
64
|
+
{text.length > 40 ? [text.slice(0, 8), text.slice(-8)].join('...') : text}
|
|
65
|
+
</Typography>
|
|
66
|
+
<OpenInNewOutlined fontSize="small" />
|
|
67
|
+
</Stack>
|
|
68
|
+
</Link>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Typography component="small" color="text.secondary">
|
|
74
|
+
None
|
|
75
|
+
</Typography>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -4,10 +4,11 @@ import type { Paginated, TInvoiceExpanded } from '@blocklet/payment-types';
|
|
|
4
4
|
import { Box, Button, CircularProgress, Stack, Typography } from '@mui/material';
|
|
5
5
|
import { fromUnitToToken } from '@ocap/util';
|
|
6
6
|
import { useInfiniteScroll } from 'ahooks';
|
|
7
|
+
import { joinURL } from 'ufo';
|
|
7
8
|
|
|
8
9
|
import api from '../../api';
|
|
9
10
|
import Status from '../../components/status';
|
|
10
|
-
import { formatToDate, getInvoiceStatusColor } from '../../util';
|
|
11
|
+
import { formatToDate, getInvoiceStatusColor, getPrefix } from '../../util';
|
|
11
12
|
|
|
12
13
|
const groupByDate = (items: TInvoiceExpanded[]) => {
|
|
13
14
|
const grouped: { [key: string]: TInvoiceExpanded[] } = {};
|
|
@@ -24,24 +25,27 @@ const groupByDate = (items: TInvoiceExpanded[]) => {
|
|
|
24
25
|
const fetchData = (params: Record<string, any> = {}): Promise<Paginated<TInvoiceExpanded>> => {
|
|
25
26
|
const search = new URLSearchParams();
|
|
26
27
|
Object.keys(params).forEach((key) => {
|
|
27
|
-
|
|
28
|
+
if (params[key]) {
|
|
29
|
+
search.set(key, String(params[key]));
|
|
30
|
+
}
|
|
28
31
|
});
|
|
29
32
|
return api.get(`/api/invoices?${search.toString()}`).then((res: any) => res.data);
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
type Props = {
|
|
33
|
-
customer_id
|
|
36
|
+
customer_id?: string;
|
|
37
|
+
subscription_id?: string;
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
const pageSize = 10;
|
|
37
41
|
|
|
38
|
-
export default function CustomerInvoiceList({ customer_id }: Props) {
|
|
42
|
+
export default function CustomerInvoiceList({ customer_id, subscription_id }: Props) {
|
|
39
43
|
const { t } = useLocaleContext();
|
|
40
44
|
|
|
41
45
|
const { data, loadMore, loadingMore, loading } = useInfiniteScroll<Paginated<TInvoiceExpanded>>(
|
|
42
46
|
(d) => {
|
|
43
47
|
const page = d ? Math.ceil(d.list.length / pageSize) + 1 : 1;
|
|
44
|
-
return fetchData({ page, pageSize, status: 'open,paid,uncollectible', customer_id });
|
|
48
|
+
return fetchData({ page, pageSize, status: 'open,paid,uncollectible', customer_id, subscription_id });
|
|
45
49
|
},
|
|
46
50
|
{
|
|
47
51
|
reloadDeps: [customer_id],
|
|
@@ -80,7 +84,7 @@ export default function CustomerInvoiceList({ customer_id }: Props) {
|
|
|
80
84
|
}}
|
|
81
85
|
flexWrap="nowrap">
|
|
82
86
|
<Box flex={3}>
|
|
83
|
-
<a href={`/customer/invoice/${invoice.id}`}>
|
|
87
|
+
<a href={joinURL(window.location.origin, getPrefix(), `/customer/invoice/${invoice.id}`)}>
|
|
84
88
|
<Typography component="span">{invoice.number}</Typography>
|
|
85
89
|
</a>
|
|
86
90
|
</Box>
|
|
@@ -120,3 +124,8 @@ export default function CustomerInvoiceList({ customer_id }: Props) {
|
|
|
120
124
|
</Stack>
|
|
121
125
|
);
|
|
122
126
|
}
|
|
127
|
+
|
|
128
|
+
CustomerInvoiceList.defaultProps = {
|
|
129
|
+
customer_id: '',
|
|
130
|
+
subscription_id: '',
|
|
131
|
+
};
|