@blocklet/payment-react 1.19.0 → 1.19.2
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 +1 -1
- package/es/components/blockchain/tx.js +9 -11
- package/es/components/country-select.d.ts +1 -1
- package/es/components/date-range-picker.d.ts +13 -0
- package/es/components/date-range-picker.js +279 -0
- package/es/components/input.d.ts +5 -2
- package/es/components/input.js +6 -2
- package/es/components/label.d.ts +7 -0
- package/es/components/label.js +50 -0
- package/es/components/loading-button.d.ts +1 -1
- package/es/history/credit/grants-list.d.ts +14 -0
- package/es/history/credit/grants-list.js +215 -0
- package/es/history/credit/transactions-list.d.ts +13 -0
- package/es/history/credit/transactions-list.js +254 -0
- package/es/history/invoice/list.js +21 -1
- package/es/index.d.ts +5 -1
- package/es/index.js +10 -1
- package/es/libs/util.d.ts +2 -0
- package/es/libs/util.js +12 -0
- package/es/locales/en.js +20 -2
- package/es/locales/zh.js +20 -2
- package/es/payment/form/address.js +2 -1
- package/es/payment/form/index.js +46 -7
- package/es/payment/index.js +18 -3
- package/es/payment/product-item.d.ts +8 -1
- package/es/payment/product-item.js +137 -5
- package/es/payment/summary.d.ts +3 -1
- package/es/payment/summary.js +9 -0
- package/lib/components/blockchain/tx.d.ts +1 -1
- package/lib/components/blockchain/tx.js +9 -8
- package/lib/components/country-select.d.ts +1 -1
- package/lib/components/date-range-picker.d.ts +13 -0
- package/lib/components/date-range-picker.js +329 -0
- package/lib/components/input.d.ts +5 -2
- package/lib/components/input.js +8 -4
- package/lib/components/label.d.ts +7 -0
- package/lib/components/label.js +62 -0
- package/lib/components/loading-button.d.ts +1 -1
- package/lib/history/credit/grants-list.d.ts +14 -0
- package/lib/history/credit/grants-list.js +277 -0
- package/lib/history/credit/transactions-list.d.ts +13 -0
- package/lib/history/credit/transactions-list.js +300 -0
- package/lib/history/invoice/list.js +24 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +39 -0
- package/lib/libs/util.d.ts +2 -0
- package/lib/libs/util.js +14 -0
- package/lib/locales/en.js +20 -2
- package/lib/locales/zh.js +20 -2
- package/lib/payment/form/address.js +6 -5
- package/lib/payment/form/index.js +49 -9
- package/lib/payment/index.js +20 -2
- package/lib/payment/product-item.d.ts +8 -1
- package/lib/payment/product-item.js +144 -4
- package/lib/payment/summary.d.ts +3 -1
- package/lib/payment/summary.js +9 -0
- package/package.json +3 -3
- package/src/components/blockchain/tx.tsx +9 -15
- package/src/components/country-select.tsx +2 -2
- package/src/components/date-range-picker.tsx +310 -0
- package/src/components/input.tsx +14 -3
- package/src/components/label.tsx +59 -0
- package/src/components/loading-button.tsx +1 -1
- package/src/history/credit/grants-list.tsx +276 -0
- package/src/history/credit/transactions-list.tsx +316 -0
- package/src/history/invoice/list.tsx +18 -1
- package/src/index.ts +9 -0
- package/src/libs/util.ts +14 -0
- package/src/locales/en.tsx +20 -0
- package/src/locales/zh.tsx +19 -0
- package/src/payment/form/address.tsx +4 -3
- package/src/payment/form/index.tsx +112 -53
- package/src/payment/index.tsx +17 -1
- package/src/payment/product-item.tsx +152 -4
- package/src/payment/summary.tsx +13 -2
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var _exportNames = {
|
|
|
12
12
|
TxLink: true,
|
|
13
13
|
ConfirmDialog: true,
|
|
14
14
|
FormInput: true,
|
|
15
|
+
FormLabel: true,
|
|
15
16
|
Livemode: true,
|
|
16
17
|
PricingTable: true,
|
|
17
18
|
Table: true,
|
|
@@ -20,6 +21,9 @@ var _exportNames = {
|
|
|
20
21
|
Switch: true,
|
|
21
22
|
CustomerInvoiceList: true,
|
|
22
23
|
CustomerPaymentList: true,
|
|
24
|
+
CreditGrantsList: true,
|
|
25
|
+
CreditStatusChip: true,
|
|
26
|
+
CreditTransactionsList: true,
|
|
23
27
|
api: true,
|
|
24
28
|
dayjs: true,
|
|
25
29
|
Amount: true,
|
|
@@ -39,6 +43,7 @@ var _exportNames = {
|
|
|
39
43
|
PaymentBeneficiaries: true,
|
|
40
44
|
LoadingButton: true,
|
|
41
45
|
ResumeSubscription: true,
|
|
46
|
+
DateRangePicker: true,
|
|
42
47
|
PaymentThemeProvider: true,
|
|
43
48
|
translations: true,
|
|
44
49
|
createTranslator: true
|
|
@@ -85,6 +90,24 @@ Object.defineProperty(exports, "CountrySelect", {
|
|
|
85
90
|
return _countrySelect.default;
|
|
86
91
|
}
|
|
87
92
|
});
|
|
93
|
+
Object.defineProperty(exports, "CreditGrantsList", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return _grantsList.default;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "CreditStatusChip", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () {
|
|
102
|
+
return _grantsList.StatusChip;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "CreditTransactionsList", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () {
|
|
108
|
+
return _transactionsList.default;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
88
111
|
Object.defineProperty(exports, "CurrencySelector", {
|
|
89
112
|
enumerable: true,
|
|
90
113
|
get: function () {
|
|
@@ -103,6 +126,12 @@ Object.defineProperty(exports, "CustomerPaymentList", {
|
|
|
103
126
|
return _list2.default;
|
|
104
127
|
}
|
|
105
128
|
});
|
|
129
|
+
Object.defineProperty(exports, "DateRangePicker", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () {
|
|
132
|
+
return _dateRangePicker.default;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
106
135
|
Object.defineProperty(exports, "DonateDetails", {
|
|
107
136
|
enumerable: true,
|
|
108
137
|
get: function () {
|
|
@@ -115,6 +144,12 @@ Object.defineProperty(exports, "FormInput", {
|
|
|
115
144
|
return _input.default;
|
|
116
145
|
}
|
|
117
146
|
});
|
|
147
|
+
Object.defineProperty(exports, "FormLabel", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: function () {
|
|
150
|
+
return _label.default;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
118
153
|
Object.defineProperty(exports, "Link", {
|
|
119
154
|
enumerable: true,
|
|
120
155
|
get: function () {
|
|
@@ -278,6 +313,7 @@ var _gas = _interopRequireDefault(require("./components/blockchain/gas"));
|
|
|
278
313
|
var _tx = _interopRequireDefault(require("./components/blockchain/tx"));
|
|
279
314
|
var _confirm = _interopRequireDefault(require("./components/confirm"));
|
|
280
315
|
var _input = _interopRequireDefault(require("./components/input"));
|
|
316
|
+
var _label = _interopRequireDefault(require("./components/label"));
|
|
281
317
|
var _livemode = _interopRequireDefault(require("./components/livemode"));
|
|
282
318
|
var _pricingTable = _interopRequireDefault(require("./components/pricing-table"));
|
|
283
319
|
var _table2 = _interopRequireDefault(require("./components/table"));
|
|
@@ -286,6 +322,8 @@ var _status = _interopRequireDefault(require("./components/status"));
|
|
|
286
322
|
var _switchButton = _interopRequireDefault(require("./components/switch-button"));
|
|
287
323
|
var _list = _interopRequireDefault(require("./history/invoice/list"));
|
|
288
324
|
var _list2 = _interopRequireDefault(require("./history/payment/list"));
|
|
325
|
+
var _grantsList = _interopRequireWildcard(require("./history/credit/grants-list"));
|
|
326
|
+
var _transactionsList = _interopRequireDefault(require("./history/credit/transactions-list"));
|
|
289
327
|
var _api = _interopRequireDefault(require("./libs/api"));
|
|
290
328
|
var _dayjs = _interopRequireDefault(require("./libs/dayjs"));
|
|
291
329
|
var _amount = _interopRequireDefault(require("./payment/amount"));
|
|
@@ -305,6 +343,7 @@ var _overDueInvoicePayment = _interopRequireDefault(require("./components/over-d
|
|
|
305
343
|
var _paymentBeneficiaries = _interopRequireDefault(require("./components/payment-beneficiaries"));
|
|
306
344
|
var _loadingButton = _interopRequireDefault(require("./components/loading-button"));
|
|
307
345
|
var _resumeSubscription = _interopRequireDefault(require("./components/resume-subscription"));
|
|
346
|
+
var _dateRangePicker = _interopRequireDefault(require("./components/date-range-picker"));
|
|
308
347
|
var _theme = require("./theme");
|
|
309
348
|
var _util = require("./libs/util");
|
|
310
349
|
Object.keys(_util).forEach(function (key) {
|
package/lib/libs/util.d.ts
CHANGED
|
@@ -129,3 +129,5 @@ export declare function parseMarkedText(text: string): Array<{
|
|
|
129
129
|
content: string;
|
|
130
130
|
}>;
|
|
131
131
|
export declare function getTokenBalanceLink(method: TPaymentMethod, address: string): string;
|
|
132
|
+
export declare function isCreditMetered(price: TPrice): boolean;
|
|
133
|
+
export declare function showStaking(method: TPaymentMethod, currency: TPaymentCurrency, noStake: boolean): boolean;
|
package/lib/libs/util.js
CHANGED
|
@@ -53,6 +53,7 @@ exports.getWebhookStatusColor = getWebhookStatusColor;
|
|
|
53
53
|
exports.getWordBreakStyle = getWordBreakStyle;
|
|
54
54
|
exports.hasDelegateTxHash = hasDelegateTxHash;
|
|
55
55
|
exports.hasMultipleRecurringIntervals = hasMultipleRecurringIntervals;
|
|
56
|
+
exports.isCreditMetered = isCreditMetered;
|
|
56
57
|
exports.isCrossOrigin = isCrossOrigin;
|
|
57
58
|
exports.isMobileSafari = isMobileSafari;
|
|
58
59
|
exports.isPaymentKitMounted = void 0;
|
|
@@ -61,6 +62,7 @@ exports.lazyLoad = lazyLoad;
|
|
|
61
62
|
exports.mergeExtraParams = void 0;
|
|
62
63
|
exports.openDonationSettings = openDonationSettings;
|
|
63
64
|
exports.parseMarkedText = parseMarkedText;
|
|
65
|
+
exports.showStaking = showStaking;
|
|
64
66
|
exports.sleep = sleep;
|
|
65
67
|
exports.stopEvent = stopEvent;
|
|
66
68
|
exports.truncateText = truncateText;
|
|
@@ -1232,4 +1234,16 @@ function getTokenBalanceLink(method, address) {
|
|
|
1232
1234
|
return (0, _ufo.joinURL)(explorerHost, "address", address);
|
|
1233
1235
|
}
|
|
1234
1236
|
return "";
|
|
1237
|
+
}
|
|
1238
|
+
function isCreditMetered(price) {
|
|
1239
|
+
return !!(price.type === "recurring" && price.recurring?.usage_type === "metered" && price.recurring?.meter_id);
|
|
1240
|
+
}
|
|
1241
|
+
function showStaking(method, currency, noStake) {
|
|
1242
|
+
if (noStake) {
|
|
1243
|
+
return false;
|
|
1244
|
+
}
|
|
1245
|
+
if (method.type === "arcblock") {
|
|
1246
|
+
return currency.type !== "credit";
|
|
1247
|
+
}
|
|
1248
|
+
return true;
|
|
1235
1249
|
}
|
package/lib/locales/en.js
CHANGED
|
@@ -35,6 +35,10 @@ module.exports = (0, _flat.default)({
|
|
|
35
35
|
remove: "Remove",
|
|
36
36
|
removed: "Resource removed",
|
|
37
37
|
confirm: "Confirm",
|
|
38
|
+
clear: "Clear",
|
|
39
|
+
selectTimeRange: "Select time range",
|
|
40
|
+
startDate: "Start date",
|
|
41
|
+
endDate: "End date",
|
|
38
42
|
upload: "Upload",
|
|
39
43
|
change: "Change",
|
|
40
44
|
cancel: "Cancel",
|
|
@@ -107,7 +111,8 @@ module.exports = (0, _flat.default)({
|
|
|
107
111
|
scan: "Use following methods to complete this {action}",
|
|
108
112
|
confirm: "Confirm",
|
|
109
113
|
cancel: "Cancel"
|
|
110
|
-
}
|
|
114
|
+
},
|
|
115
|
+
paymentMethod: "Payment Method"
|
|
111
116
|
},
|
|
112
117
|
payment: {
|
|
113
118
|
checkout: {
|
|
@@ -211,6 +216,11 @@ module.exports = (0, _flat.default)({
|
|
|
211
216
|
add: "Add to order",
|
|
212
217
|
remove: "Remove from order"
|
|
213
218
|
},
|
|
219
|
+
credit: {
|
|
220
|
+
oneTimeInfo: "You will receive {amount} {symbol} credits after payment",
|
|
221
|
+
recurringInfo: "You will receive {amount} {symbol} credits {period}",
|
|
222
|
+
expiresIn: "credits have a validity period of {duration} {unit}"
|
|
223
|
+
},
|
|
214
224
|
expired: {
|
|
215
225
|
title: "Expired Link",
|
|
216
226
|
description: "This link has expired. This means that your payment has already been processed or your session has expired."
|
|
@@ -239,7 +249,15 @@ module.exports = (0, _flat.default)({
|
|
|
239
249
|
payer: "Account",
|
|
240
250
|
amount: "Amount",
|
|
241
251
|
failed: "Account changed, please pay manually.",
|
|
242
|
-
balanceLink: "View Balance"
|
|
252
|
+
balanceLink: "View Balance",
|
|
253
|
+
credit: {
|
|
254
|
+
title: "Confirm Credit Payment",
|
|
255
|
+
availableAmount: "Available Credit: {amount}",
|
|
256
|
+
confirmMessage: "You will use {amount} credits to subscribe to this service.",
|
|
257
|
+
meteringSubscriptionMessage: "This subscription service will deduct credits in real-time based on actual usage. You currently have {available} credits available. Confirm to continue?",
|
|
258
|
+
insufficientTitle: "Insufficient Credit",
|
|
259
|
+
insufficientMessage: "This subscription service will deduct credits in real-time based on actual usage. You currently have insufficient credits. Please top up your credits first."
|
|
260
|
+
}
|
|
243
261
|
}
|
|
244
262
|
},
|
|
245
263
|
customer: {
|
package/lib/locales/zh.js
CHANGED
|
@@ -38,6 +38,10 @@ module.exports = (0, _flat.default)({
|
|
|
38
38
|
change: "\u66F4\u6362",
|
|
39
39
|
confirm: "\u786E\u8BA4",
|
|
40
40
|
cancel: "\u53D6\u6D88",
|
|
41
|
+
clear: "\u6E05\u7A7A",
|
|
42
|
+
selectTimeRange: "\u9009\u62E9\u65F6\u95F4\u8303\u56F4",
|
|
43
|
+
startDate: "\u5F00\u59CB\u65E5\u671F",
|
|
44
|
+
endDate: "\u7ED3\u675F\u65E5\u671F",
|
|
41
45
|
close: "\u5173\u95ED",
|
|
42
46
|
back: "\u8FD4\u56DE",
|
|
43
47
|
every: "\u6BCF",
|
|
@@ -107,7 +111,8 @@ module.exports = (0, _flat.default)({
|
|
|
107
111
|
scan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21{action}",
|
|
108
112
|
confirm: "\u786E\u8BA4",
|
|
109
113
|
cancel: "\u53D6\u6D88"
|
|
110
|
-
}
|
|
114
|
+
},
|
|
115
|
+
paymentMethod: "\u652F\u4ED8\u65B9\u5F0F"
|
|
111
116
|
},
|
|
112
117
|
payment: {
|
|
113
118
|
checkout: {
|
|
@@ -219,6 +224,11 @@ module.exports = (0, _flat.default)({
|
|
|
219
224
|
add: "\u6DFB\u52A0\u5230\u8BA2\u5355",
|
|
220
225
|
remove: "\u4ECE\u8BA2\u5355\u79FB\u9664"
|
|
221
226
|
},
|
|
227
|
+
credit: {
|
|
228
|
+
oneTimeInfo: "\u4ED8\u6B3E\u5B8C\u6210\u540E\u60A8\u5C06\u83B7\u5F97 {amount} {symbol} \u989D\u5EA6",
|
|
229
|
+
recurringInfo: "\u60A8\u5C06{period}\u83B7\u5F97 {amount} {symbol} \u989D\u5EA6",
|
|
230
|
+
expiresIn: "\u989D\u5EA6\u6709\u6548\u671F\u4E3A {duration} {unit}"
|
|
231
|
+
},
|
|
222
232
|
emptyItems: {
|
|
223
233
|
title: "\u6CA1\u6709\u4EFB\u4F55\u8D2D\u4E70\u9879\u76EE",
|
|
224
234
|
description: "\u53EF\u80FD\u8FD9\u4E2A\u4ED8\u6B3E\u94FE\u63A5\u6CA1\u6709\u6B63\u786E\u914D\u7F6E"
|
|
@@ -239,7 +249,15 @@ module.exports = (0, _flat.default)({
|
|
|
239
249
|
payer: "\u8D26\u6237\u5730\u5740",
|
|
240
250
|
amount: "\u652F\u4ED8\u91D1\u989D",
|
|
241
251
|
failed: "\u8D26\u6237\u53D1\u751F\u53D8\u5316\uFF0C\u65E0\u6CD5\u81EA\u52A8\u5B8C\u6210\u652F\u4ED8\uFF0C\u8BF7\u624B\u52A8\u652F\u4ED8\u3002",
|
|
242
|
-
balanceLink: "\u67E5\u770B\u4F59\u989D"
|
|
252
|
+
balanceLink: "\u67E5\u770B\u4F59\u989D",
|
|
253
|
+
credit: {
|
|
254
|
+
title: "\u786E\u8BA4\u989D\u5EA6\u652F\u4ED8",
|
|
255
|
+
availableAmount: "\u53EF\u7528\u989D\u5EA6\uFF1A{amount}",
|
|
256
|
+
confirmMessage: "\u60A8\u5C06\u4F7F\u7528 {amount} \u989D\u5EA6\u6765\u8BA2\u9605\u6B64\u670D\u52A1\u3002",
|
|
257
|
+
meteringSubscriptionMessage: "\u6B64\u8BA2\u9605\u670D\u52A1\u5C06\u6839\u636E\u5B9E\u9645\u4F7F\u7528\u60C5\u51B5\u5B9E\u65F6\u6263\u9664\u989D\u5EA6\u3002\u60A8\u5F53\u524D\u53EF\u7528\u989D\u5EA6\u4E3A {available}\uFF0C\u786E\u8BA4\u662F\u5426\u7EE7\u7EED\uFF1F",
|
|
258
|
+
insufficientTitle: "\u989D\u5EA6\u4E0D\u8DB3",
|
|
259
|
+
insufficientMessage: "\u6B64\u8BA2\u9605\u670D\u52A1\u5C06\u6839\u636E\u5B9E\u9645\u4F7F\u7528\u60C5\u51B5\u5B9E\u65F6\u6263\u9664\u989D\u5EA6\u3002\u60A8\u5F53\u524D\u53EF\u7528\u989D\u5EA6\u4E0D\u8DB3\uFF0C\u8BF7\u5148\u5145\u503C\u989D\u5EA6\u3002"
|
|
260
|
+
}
|
|
243
261
|
}
|
|
244
262
|
},
|
|
245
263
|
customer: {
|
|
@@ -9,6 +9,7 @@ var _context = require("@arcblock/ux/lib/Locale/context");
|
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _reactHookForm = require("react-hook-form");
|
|
11
11
|
var _input = _interopRequireDefault(require("../../components/input"));
|
|
12
|
+
var _label = _interopRequireDefault(require("../../components/label"));
|
|
12
13
|
var _countrySelect = _interopRequireDefault(require("../../components/country-select"));
|
|
13
14
|
var _validator = require("../../libs/validator");
|
|
14
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -40,7 +41,7 @@ function AddressForm({
|
|
|
40
41
|
direction: "column",
|
|
41
42
|
className: "cko-payment-form",
|
|
42
43
|
spacing: 0,
|
|
43
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
44
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
44
45
|
className: "base-label",
|
|
45
46
|
children: t("payment.checkout.billing.line1")
|
|
46
47
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
@@ -52,7 +53,7 @@ function AddressForm({
|
|
|
52
53
|
errorPosition,
|
|
53
54
|
variant: "outlined",
|
|
54
55
|
placeholder: t("payment.checkout.billing.line1")
|
|
55
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
56
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
56
57
|
className: "base-label",
|
|
57
58
|
children: t("payment.checkout.billing.city")
|
|
58
59
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
@@ -64,7 +65,7 @@ function AddressForm({
|
|
|
64
65
|
errorPosition,
|
|
65
66
|
variant: "outlined",
|
|
66
67
|
placeholder: t("payment.checkout.billing.city")
|
|
67
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
68
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
68
69
|
className: "base-label",
|
|
69
70
|
children: t("payment.checkout.billing.state")
|
|
70
71
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
@@ -76,7 +77,7 @@ function AddressForm({
|
|
|
76
77
|
errorPosition,
|
|
77
78
|
variant: "outlined",
|
|
78
79
|
placeholder: t("payment.checkout.billing.state")
|
|
79
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
80
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
80
81
|
className: "base-label",
|
|
81
82
|
children: t("payment.checkout.billing.postal_code")
|
|
82
83
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
@@ -131,7 +132,7 @@ function AddressForm({
|
|
|
131
132
|
direction: "column",
|
|
132
133
|
className: "cko-payment-form",
|
|
133
134
|
spacing: 0,
|
|
134
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
135
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
135
136
|
className: "base-label",
|
|
136
137
|
children: t("payment.checkout.billing.postal_code")
|
|
137
138
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
@@ -22,6 +22,7 @@ var _DID = _interopRequireDefault(require("@arcblock/ux/lib/DID"));
|
|
|
22
22
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
23
23
|
var _iconsMaterial = require("@mui/icons-material");
|
|
24
24
|
var _input = _interopRequireDefault(require("../../components/input"));
|
|
25
|
+
var _label = _interopRequireDefault(require("../../components/label"));
|
|
25
26
|
var _payment = require("../../contexts/payment");
|
|
26
27
|
var _subscription = require("../../hooks/subscription");
|
|
27
28
|
var _api = _interopRequireDefault(require("../../libs/api"));
|
|
@@ -154,7 +155,8 @@ function PaymentForm({
|
|
|
154
155
|
customer,
|
|
155
156
|
customerLimited: false,
|
|
156
157
|
stripePaying: false,
|
|
157
|
-
fastCheckoutInfo: null
|
|
158
|
+
fastCheckoutInfo: null,
|
|
159
|
+
creditInsufficientInfo: null
|
|
158
160
|
});
|
|
159
161
|
const currencies = (0, _util2.flattenPaymentMethods)(paymentMethods);
|
|
160
162
|
const onCheckoutComplete = (0, _ahooks.useMemoizedFn)(async ({
|
|
@@ -346,6 +348,11 @@ function PaymentForm({
|
|
|
346
348
|
fastCheckoutInfo: null
|
|
347
349
|
});
|
|
348
350
|
};
|
|
351
|
+
const handleCreditInsufficientClose = () => {
|
|
352
|
+
setState({
|
|
353
|
+
creditInsufficientInfo: null
|
|
354
|
+
});
|
|
355
|
+
};
|
|
349
356
|
const openConnect = () => {
|
|
350
357
|
try {
|
|
351
358
|
if (!["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
@@ -416,7 +423,27 @@ function PaymentForm({
|
|
|
416
423
|
customerLimited: false
|
|
417
424
|
});
|
|
418
425
|
if (["arcblock", "ethereum", "base"].includes(method.type)) {
|
|
419
|
-
if (
|
|
426
|
+
if (paymentCurrency?.type === "credit") {
|
|
427
|
+
if (result.data.creditSufficient === true) {
|
|
428
|
+
setState({
|
|
429
|
+
fastCheckoutInfo: {
|
|
430
|
+
open: true,
|
|
431
|
+
loading: false,
|
|
432
|
+
sourceType: "credit",
|
|
433
|
+
amount: result.data.fastPayInfo?.amount || "0",
|
|
434
|
+
payer: result.data.fastPayInfo?.payer,
|
|
435
|
+
availableCredit: result.data.fastPayInfo?.amount || "0",
|
|
436
|
+
balance: result.data.fastPayInfo?.token?.balance || "0"
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
} else {
|
|
440
|
+
setState({
|
|
441
|
+
creditInsufficientInfo: {
|
|
442
|
+
open: true
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
} else if ((result.data.balance?.sufficient || result.data.delegation?.sufficient) && !isDonationMode && result.data.fastPayInfo) {
|
|
420
447
|
setState({
|
|
421
448
|
fastCheckoutInfo: {
|
|
422
449
|
open: true,
|
|
@@ -525,8 +552,12 @@ function PaymentForm({
|
|
|
525
552
|
const FastCheckoutConfirmDialog = state.fastCheckoutInfo && /* @__PURE__ */(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
526
553
|
onConfirm: handleFastCheckoutConfirm,
|
|
527
554
|
onCancel: handleFastCheckoutCancel,
|
|
528
|
-
title: t("payment.checkout.fastPay.title"),
|
|
529
|
-
message: /* @__PURE__ */(0, _jsxRuntime.
|
|
555
|
+
title: state.fastCheckoutInfo.sourceType === "credit" ? t("payment.checkout.fastPay.credit.title") : t("payment.checkout.fastPay.title"),
|
|
556
|
+
message: state.fastCheckoutInfo.sourceType === "credit" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
557
|
+
children: t("payment.checkout.fastPay.credit.meteringSubscriptionMessage", {
|
|
558
|
+
available: `${(0, _util.fromUnitToToken)(state.fastCheckoutInfo?.balance || "0", paymentCurrency?.decimal || 18).toString()} ${paymentCurrency?.symbol}`
|
|
559
|
+
})
|
|
560
|
+
}) : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
530
561
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
531
562
|
children: t("payment.checkout.fastPay.autoPaymentReason")
|
|
532
563
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
|
|
@@ -596,6 +627,15 @@ function PaymentForm({
|
|
|
596
627
|
loading: state.fastCheckoutInfo.loading,
|
|
597
628
|
color: "primary"
|
|
598
629
|
});
|
|
630
|
+
const CreditInsufficientDialog = state.creditInsufficientInfo && /* @__PURE__ */(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
631
|
+
onConfirm: handleCreditInsufficientClose,
|
|
632
|
+
onCancel: handleCreditInsufficientClose,
|
|
633
|
+
title: t("payment.checkout.fastPay.credit.insufficientTitle"),
|
|
634
|
+
message: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
635
|
+
children: t("payment.checkout.fastPay.credit.insufficientMessage")
|
|
636
|
+
}),
|
|
637
|
+
confirm: t("common.confirm")
|
|
638
|
+
});
|
|
599
639
|
if (onlyShowBtn) {
|
|
600
640
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
601
641
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -646,7 +686,7 @@ function PaymentForm({
|
|
|
646
686
|
}),
|
|
647
687
|
title: t("payment.customer.pastDue.alert.title")
|
|
648
688
|
}
|
|
649
|
-
}), FastCheckoutConfirmDialog]
|
|
689
|
+
}), FastCheckoutConfirmDialog, CreditInsufficientDialog]
|
|
650
690
|
});
|
|
651
691
|
}
|
|
652
692
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
@@ -717,7 +757,7 @@ function PaymentForm({
|
|
|
717
757
|
overflow: "auto",
|
|
718
758
|
py: 1
|
|
719
759
|
},
|
|
720
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
760
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
721
761
|
className: "base-label",
|
|
722
762
|
children: t("payment.checkout.customer.name")
|
|
723
763
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
@@ -728,7 +768,7 @@ function PaymentForm({
|
|
|
728
768
|
required: t("payment.checkout.required"),
|
|
729
769
|
...(0, _validator.getFieldValidation)("customer_name", checkoutSession.metadata?.page_info?.field_validation, locale)
|
|
730
770
|
}
|
|
731
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
771
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
732
772
|
className: "base-label",
|
|
733
773
|
children: t("payment.checkout.customer.email")
|
|
734
774
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_input.default, {
|
|
@@ -741,7 +781,7 @@ function PaymentForm({
|
|
|
741
781
|
...(0, _validator.getFieldValidation)("customer_email", checkoutSession.metadata?.page_info?.field_validation, locale)
|
|
742
782
|
}
|
|
743
783
|
}), checkoutSession.phone_number_collection?.enabled && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
744
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
784
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_label.default, {
|
|
745
785
|
className: "base-label",
|
|
746
786
|
children: t("payment.checkout.customer.phone")
|
|
747
787
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_phone.default, {
|
|
@@ -852,6 +892,6 @@ function PaymentForm({
|
|
|
852
892
|
}),
|
|
853
893
|
title: t("payment.customer.pastDue.alert.title")
|
|
854
894
|
}
|
|
855
|
-
}), FastCheckoutConfirmDialog]
|
|
895
|
+
}), FastCheckoutConfirmDialog, CreditInsufficientDialog]
|
|
856
896
|
});
|
|
857
897
|
}
|
package/lib/payment/index.js
CHANGED
|
@@ -196,6 +196,22 @@ function PaymentInner({
|
|
|
196
196
|
_Toast.default.error((0, _util2.formatError)(err));
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
|
+
const onQuantityChange = async (itemId, quantity) => {
|
|
200
|
+
try {
|
|
201
|
+
const {
|
|
202
|
+
data
|
|
203
|
+
} = await _api.default.put(`/api/checkout-sessions/${state.checkoutSession.id}/adjust-quantity`, {
|
|
204
|
+
itemId,
|
|
205
|
+
quantity
|
|
206
|
+
});
|
|
207
|
+
setState({
|
|
208
|
+
checkoutSession: data
|
|
209
|
+
});
|
|
210
|
+
} catch (err) {
|
|
211
|
+
console.error(err);
|
|
212
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
213
|
+
}
|
|
214
|
+
};
|
|
199
215
|
const onCancelCrossSell = async () => {
|
|
200
216
|
try {
|
|
201
217
|
const {
|
|
@@ -262,17 +278,19 @@ function PaymentInner({
|
|
|
262
278
|
billingThreshold: Math.max(state.checkoutSession.subscription_data?.billing_threshold_amount || 0,
|
|
263
279
|
// @ts-ignore
|
|
264
280
|
state.checkoutSession.subscription_data?.min_stake_amount || 0),
|
|
265
|
-
showStaking: method
|
|
281
|
+
showStaking: (0, _util2.showStaking)(method, currency, !!state.checkoutSession.subscription_data?.no_stake),
|
|
266
282
|
currency,
|
|
267
283
|
onUpsell,
|
|
268
284
|
onDownsell,
|
|
285
|
+
onQuantityChange,
|
|
269
286
|
onApplyCrossSell,
|
|
270
287
|
onCancelCrossSell,
|
|
271
288
|
onChangeAmount,
|
|
272
289
|
checkoutSessionId: state.checkoutSession.id,
|
|
273
290
|
crossSellBehavior: state.checkoutSession.cross_sell_behavior,
|
|
274
291
|
donationSettings: paymentLink?.donation_settings,
|
|
275
|
-
action
|
|
292
|
+
action,
|
|
293
|
+
completed
|
|
276
294
|
}), mode === "standalone" && !isMobile && /* @__PURE__ */(0, _jsxRuntime.jsx)(_footer.default, {
|
|
277
295
|
className: "cko-footer",
|
|
278
296
|
sx: {
|
|
@@ -10,6 +10,13 @@ type Props = {
|
|
|
10
10
|
onDownsell: Function;
|
|
11
11
|
mode?: 'normal' | 'cross-sell';
|
|
12
12
|
children?: React.ReactNode;
|
|
13
|
+
adjustableQuantity?: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
minimum?: number;
|
|
16
|
+
maximum?: number;
|
|
17
|
+
};
|
|
18
|
+
onQuantityChange?: (itemId: string, quantity: number) => void;
|
|
19
|
+
completed?: boolean;
|
|
13
20
|
};
|
|
14
|
-
export default function ProductItem({ item, items, trialInDays, trialEnd, currency, mode, children, onUpsell, onDownsell, }: Props): JSX.Element;
|
|
21
|
+
export default function ProductItem({ item, items, trialInDays, trialEnd, currency, mode, children, onUpsell, onDownsell, completed, adjustableQuantity, onQuantityChange, }: Props): JSX.Element;
|
|
15
22
|
export {};
|