@blocklet/payment-react 1.13.160 → 1.13.162
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/input.d.ts +3 -1
- package/es/components/input.js +12 -3
- package/es/history/invoice/list.js +1 -1
- package/es/history/payment/list.js +1 -1
- package/es/index.d.ts +5 -1
- package/es/index.js +8 -0
- package/es/locales/en.js +14 -3
- package/es/locales/zh.js +14 -3
- package/es/payment/form/address.js +2 -1
- package/es/payment/form/currency.d.ts +9 -0
- package/es/payment/form/currency.js +81 -0
- package/es/payment/form/index.js +10 -44
- package/es/payment/index.js +11 -49
- package/es/payment/product-item.d.ts +4 -3
- package/es/payment/product-item.js +13 -4
- package/es/payment/success.d.ts +8 -2
- package/es/payment/success.js +5 -2
- package/es/payment/summary.d.ts +21 -8
- package/es/payment/summary.js +28 -12
- package/es/util.d.ts +6 -3
- package/es/util.js +19 -8
- package/lib/components/input.d.ts +3 -1
- package/lib/components/input.js +4 -2
- package/lib/history/invoice/list.js +1 -1
- package/lib/history/payment/list.js +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +32 -0
- package/lib/locales/en.js +14 -3
- package/lib/locales/zh.js +14 -3
- package/lib/payment/form/address.js +4 -1
- package/lib/payment/form/currency.d.ts +9 -0
- package/lib/payment/form/currency.js +106 -0
- package/lib/payment/form/index.js +8 -60
- package/lib/payment/index.js +13 -49
- package/lib/payment/product-item.d.ts +4 -3
- package/lib/payment/product-item.js +5 -4
- package/lib/payment/success.d.ts +8 -2
- package/lib/payment/success.js +6 -2
- package/lib/payment/summary.d.ts +21 -8
- package/lib/payment/summary.js +26 -11
- package/lib/util.d.ts +6 -3
- package/lib/util.js +22 -9
- package/package.json +10 -10
- package/src/components/input.tsx +12 -2
- package/src/history/invoice/list.tsx +1 -1
- package/src/history/payment/list.tsx +1 -1
- package/src/index.ts +8 -0
- package/src/locales/en.tsx +15 -1
- package/src/locales/zh.tsx +13 -1
- package/src/payment/form/address.tsx +1 -0
- package/src/payment/form/currency.tsx +91 -0
- package/src/payment/form/index.tsx +12 -53
- package/src/payment/index.tsx +18 -50
- package/src/payment/product-item.tsx +16 -11
- package/src/payment/success.tsx +9 -2
- package/src/payment/summary.tsx +41 -21
- package/src/util.ts +24 -10
package/es/payment/summary.js
CHANGED
|
@@ -38,18 +38,32 @@ async function fetchCrossSell(id) {
|
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
PaymentSummary.defaultProps = {
|
|
42
|
+
onUpsell: noop,
|
|
43
|
+
onDownsell: noop,
|
|
44
|
+
onApplyCrossSell: noop,
|
|
45
|
+
onCancelCrossSell: noop,
|
|
46
|
+
checkoutSessionId: "",
|
|
47
|
+
crossSellBehavior: ""
|
|
48
|
+
};
|
|
41
49
|
export default function PaymentSummary({
|
|
42
|
-
|
|
50
|
+
items,
|
|
43
51
|
currency,
|
|
52
|
+
trialInDays,
|
|
44
53
|
onUpsell,
|
|
45
54
|
onDownsell,
|
|
46
55
|
onApplyCrossSell,
|
|
47
|
-
onCancelCrossSell
|
|
56
|
+
onCancelCrossSell,
|
|
57
|
+
checkoutSessionId,
|
|
58
|
+
crossSellBehavior,
|
|
59
|
+
...rest
|
|
48
60
|
}) {
|
|
49
61
|
const { t, locale } = useLocaleContext();
|
|
50
62
|
const [state, setState] = useSetState({ loading: false, shake: false });
|
|
51
|
-
const { data, runAsync } = useRequest(
|
|
52
|
-
|
|
63
|
+
const { data, runAsync } = useRequest(
|
|
64
|
+
() => checkoutSessionId ? fetchCrossSell(checkoutSessionId) : Promise.resolve(null)
|
|
65
|
+
);
|
|
66
|
+
const headlines = formatCheckoutHeadlines(items, currency, trialInDays, locale);
|
|
53
67
|
useBus(
|
|
54
68
|
"error.REQUIRE_CROSS_SELL",
|
|
55
69
|
() => {
|
|
@@ -90,17 +104,18 @@ export default function PaymentSummary({
|
|
|
90
104
|
setState({ loading: false });
|
|
91
105
|
}
|
|
92
106
|
};
|
|
93
|
-
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-product", direction: "column", children: [
|
|
107
|
+
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-product", direction: "column", ...rest, children: [
|
|
94
108
|
/* @__PURE__ */ jsxs(Stack, { className: "cko-product-summary", direction: "column", alignItems: "flex-start", sx: { mb: 4 }, children: [
|
|
95
109
|
/* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 500, fontSize: "1.15rem", color: "text.secondary" }, children: headlines.action }),
|
|
96
110
|
/* @__PURE__ */ jsx(PaymentAmount, { amount: headlines.amount }),
|
|
97
111
|
headlines.then && /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "0.9rem", color: "text.secondary" }, children: headlines.then })
|
|
98
112
|
] }),
|
|
99
|
-
/* @__PURE__ */ jsx(Stack, { spacing: 2, children:
|
|
113
|
+
/* @__PURE__ */ jsx(Stack, { spacing: 2, children: items.map((x) => /* @__PURE__ */ jsx(
|
|
100
114
|
ProductItem,
|
|
101
115
|
{
|
|
102
116
|
item: x,
|
|
103
|
-
|
|
117
|
+
items,
|
|
118
|
+
trialInDays,
|
|
104
119
|
currency,
|
|
105
120
|
onUpsell: handleUpsell,
|
|
106
121
|
onDownsell: handleDownsell,
|
|
@@ -119,7 +134,7 @@ export default function PaymentSummary({
|
|
|
119
134
|
},
|
|
120
135
|
x.price_id
|
|
121
136
|
)) }),
|
|
122
|
-
data &&
|
|
137
|
+
data && items.some((x) => x.price_id === data.id) === false && /* @__PURE__ */ jsx(Grow, { in: true, children: /* @__PURE__ */ jsxs(
|
|
123
138
|
Stack,
|
|
124
139
|
{
|
|
125
140
|
direction: "column",
|
|
@@ -140,21 +155,22 @@ export default function PaymentSummary({
|
|
|
140
155
|
ProductItem,
|
|
141
156
|
{
|
|
142
157
|
item: { quantity: 1, price: data, price_id: data.id, cross_sell: true },
|
|
143
|
-
|
|
158
|
+
items,
|
|
159
|
+
trialInDays,
|
|
144
160
|
currency,
|
|
145
161
|
onUpsell: noop,
|
|
146
162
|
onDownsell: noop
|
|
147
163
|
}
|
|
148
164
|
),
|
|
149
165
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", sx: { width: 1 }, children: [
|
|
150
|
-
/* @__PURE__ */ jsx(Typography, { children:
|
|
166
|
+
/* @__PURE__ */ jsx(Typography, { children: crossSellBehavior === "required" && /* @__PURE__ */ jsx(Status, { label: t("payment.checkout.required"), color: "info", variant: "outlined", sx: { mr: 1 } }) }),
|
|
151
167
|
/* @__PURE__ */ jsx(
|
|
152
168
|
LoadingButton,
|
|
153
169
|
{
|
|
154
170
|
size: "small",
|
|
155
171
|
loadingPosition: "end",
|
|
156
|
-
color:
|
|
157
|
-
variant:
|
|
172
|
+
color: crossSellBehavior === "required" ? "info" : "info",
|
|
173
|
+
variant: crossSellBehavior === "required" ? "text" : "text",
|
|
158
174
|
loading: state.loading,
|
|
159
175
|
onClick: handleApplyCrossSell,
|
|
160
176
|
children: t("payment.checkout.cross_sell.add")
|
package/es/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { PriceCurrency, PriceRecurring,
|
|
2
|
+
import type { PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
3
3
|
export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
4
4
|
export declare const getPrefix: () => any;
|
|
5
5
|
export declare function formatToDate(date: Date | string | number, locale?: string): any;
|
|
@@ -34,8 +34,8 @@ export declare function getCheckoutAmount(items: TLineItemExpanded[], currency:
|
|
|
34
34
|
tax: string;
|
|
35
35
|
};
|
|
36
36
|
export declare function getRecurringPeriod(recurring: PriceRecurring): number;
|
|
37
|
-
export declare function formatUpsellSaving(
|
|
38
|
-
export declare function formatCheckoutHeadlines(
|
|
37
|
+
export declare function formatUpsellSaving(items: TLineItemExpanded[], currency: TPaymentCurrency): string;
|
|
38
|
+
export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], currency: TPaymentCurrency, trialInDays: number, locale?: string): {
|
|
39
39
|
action: string;
|
|
40
40
|
amount: string;
|
|
41
41
|
then?: string;
|
|
@@ -57,3 +57,6 @@ export declare const getSubscriptionAction: (subscription: TSubscriptionExpanded
|
|
|
57
57
|
canRenew: boolean;
|
|
58
58
|
} | null;
|
|
59
59
|
export declare const mergeExtraParams: (extra?: Record<string, any>) => string;
|
|
60
|
+
export declare const flattenPaymentMethods: (methods?: TPaymentMethodExpanded[]) => import("sequelize").InferAttributes<import("@blocklet/payment-types").PaymentCurrency, {
|
|
61
|
+
omit: never;
|
|
62
|
+
}>[];
|
package/es/util.js
CHANGED
|
@@ -275,8 +275,7 @@ export function getRecurringPeriod(recurring) {
|
|
|
275
275
|
throw new Error(`Unsupported recurring interval: ${interval}`);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
export function formatUpsellSaving(
|
|
279
|
-
const items = session.line_items;
|
|
278
|
+
export function formatUpsellSaving(items, currency) {
|
|
280
279
|
if (items[0]?.upsell_price_id) {
|
|
281
280
|
return "0";
|
|
282
281
|
}
|
|
@@ -304,9 +303,8 @@ export function formatUpsellSaving(session, currency) {
|
|
|
304
303
|
const after = new BN(to.total);
|
|
305
304
|
return Number(before.sub(after).mul(new BN(100)).div(before).toString()).toFixed(0);
|
|
306
305
|
}
|
|
307
|
-
export function formatCheckoutHeadlines(
|
|
308
|
-
const
|
|
309
|
-
const trial = session.subscription_data?.trial_period_days || 0;
|
|
306
|
+
export function formatCheckoutHeadlines(items, currency, trialInDays, locale = "en") {
|
|
307
|
+
const trial = trialInDays || 0;
|
|
310
308
|
const brand = getStatementDescriptor(items);
|
|
311
309
|
const { total } = getCheckoutAmount(items, currency, !!trial);
|
|
312
310
|
const amount = `${fromUnitToToken(total, currency.decimal)} ${currency.symbol}`;
|
|
@@ -440,15 +438,15 @@ export const getSubscriptionTimeSummary = (subscription) => {
|
|
|
440
438
|
};
|
|
441
439
|
export const getSubscriptionAction = (subscription) => {
|
|
442
440
|
if (subscription.status === "active" || subscription.status === "trialing") {
|
|
443
|
-
if (subscription.cancel_at) {
|
|
444
|
-
return null;
|
|
445
|
-
}
|
|
446
441
|
if (subscription.cancel_at_period_end) {
|
|
447
442
|
if (subscription.cancelation_details?.reason === "payment_failed") {
|
|
448
443
|
return null;
|
|
449
444
|
}
|
|
450
445
|
return { action: "recover", variant: "contained", color: "primary", canRenew: false };
|
|
451
446
|
}
|
|
447
|
+
if (subscription.cancel_at && subscription.cancel_at !== subscription.current_period_end) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
452
450
|
return { action: "cancel", variant: "outlined", color: "inherit", canRenew: false };
|
|
453
451
|
}
|
|
454
452
|
if (subscription.status === "past_due") {
|
|
@@ -467,3 +465,16 @@ export const mergeExtraParams = (extra = {}) => {
|
|
|
467
465
|
});
|
|
468
466
|
return params.toString();
|
|
469
467
|
};
|
|
468
|
+
export const flattenPaymentMethods = (methods = []) => {
|
|
469
|
+
const out = [];
|
|
470
|
+
methods.forEach((method) => {
|
|
471
|
+
const currencies = method.paymentCurrencies || method.payment_currencies || [];
|
|
472
|
+
currencies.forEach((currency) => {
|
|
473
|
+
out.push({
|
|
474
|
+
...currency,
|
|
475
|
+
method
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
return out;
|
|
480
|
+
};
|
|
@@ -7,17 +7,19 @@ type InputProps = TextFieldProps & {
|
|
|
7
7
|
placeholder?: string;
|
|
8
8
|
errorPosition?: 'right' | 'bottom';
|
|
9
9
|
rules?: RegisterOptions;
|
|
10
|
+
wrapperStyle?: React.CSSProperties;
|
|
10
11
|
};
|
|
11
12
|
export declare function FormInputError({ error }: {
|
|
12
13
|
error: string;
|
|
13
14
|
}): import("react").JSX.Element;
|
|
14
|
-
declare function FormInput({ name, label, placeholder, rules, errorPosition, ...rest }: InputProps): import("react").JSX.Element;
|
|
15
|
+
declare function FormInput({ name, label, placeholder, rules, errorPosition, wrapperStyle, ...rest }: InputProps): import("react").JSX.Element;
|
|
15
16
|
declare namespace FormInput {
|
|
16
17
|
var defaultProps: {
|
|
17
18
|
label: string;
|
|
18
19
|
placeholder: string;
|
|
19
20
|
errorPosition: string;
|
|
20
21
|
rules: {};
|
|
22
|
+
wrapperStyle: {};
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
export default FormInput;
|
package/lib/components/input.js
CHANGED
|
@@ -14,7 +14,8 @@ FormInput.defaultProps = {
|
|
|
14
14
|
label: "",
|
|
15
15
|
placeholder: "",
|
|
16
16
|
errorPosition: "bottom",
|
|
17
|
-
rules: {}
|
|
17
|
+
rules: {},
|
|
18
|
+
wrapperStyle: {}
|
|
18
19
|
};
|
|
19
20
|
function FormInputError({
|
|
20
21
|
error
|
|
@@ -34,6 +35,7 @@ function FormInput({
|
|
|
34
35
|
placeholder,
|
|
35
36
|
rules,
|
|
36
37
|
errorPosition,
|
|
38
|
+
wrapperStyle,
|
|
37
39
|
...rest
|
|
38
40
|
}) {
|
|
39
41
|
const {
|
|
@@ -50,7 +52,7 @@ function FormInput({
|
|
|
50
52
|
}) => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
51
53
|
sx: {
|
|
52
54
|
width: "100%",
|
|
53
|
-
|
|
55
|
+
...wrapperStyle
|
|
54
56
|
},
|
|
55
57
|
children: [!!label && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.FormLabel, {
|
|
56
58
|
children: label
|
|
@@ -103,7 +103,7 @@ function CustomerPaymentList({
|
|
|
103
103
|
flex: 2,
|
|
104
104
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
105
105
|
textAlign: "right",
|
|
106
|
-
children: [(0, _util.fromUnitToToken)(item.
|
|
106
|
+
children: [(0, _util.fromUnitToToken)(item.amount_received, item.paymentCurrency.decimal), "\xA0", item.paymentCurrency.symbol]
|
|
107
107
|
})
|
|
108
108
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
109
109
|
flex: 3,
|
package/lib/index.d.ts
CHANGED
|
@@ -13,10 +13,14 @@ import CustomerInvoiceList from './history/invoice/list';
|
|
|
13
13
|
import MiniInvoiceList from './history/mini-invoice/list';
|
|
14
14
|
import CustomerPaymentList from './history/payment/list';
|
|
15
15
|
import Amount from './payment/amount';
|
|
16
|
+
import AddressForm from './payment/form/address';
|
|
17
|
+
import CurrencySelector from './payment/form/currency';
|
|
16
18
|
import PhoneInput from './payment/form/phone';
|
|
19
|
+
import StripeForm from './payment/form/stripe';
|
|
17
20
|
import Payment from './payment/index';
|
|
18
21
|
import ProductSkeleton from './payment/product-skeleton';
|
|
22
|
+
import PaymentSummary from './payment/summary';
|
|
19
23
|
export * from './util';
|
|
20
24
|
export * from './contexts/payment';
|
|
21
25
|
export { translations, createTranslator } from './locales';
|
|
22
|
-
export { api, dayjs, FormInput, PhoneInput, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, Payment, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
|
|
26
|
+
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, MiniInvoiceList, TxLink, };
|
package/lib/index.js
CHANGED
|
@@ -19,12 +19,22 @@ var _exportNames = {
|
|
|
19
19
|
MiniInvoiceList: true,
|
|
20
20
|
CustomerPaymentList: true,
|
|
21
21
|
Amount: true,
|
|
22
|
+
AddressForm: true,
|
|
23
|
+
CurrencySelector: true,
|
|
22
24
|
PhoneInput: true,
|
|
25
|
+
StripeForm: true,
|
|
23
26
|
Payment: true,
|
|
24
27
|
ProductSkeleton: true,
|
|
28
|
+
PaymentSummary: true,
|
|
25
29
|
translations: true,
|
|
26
30
|
createTranslator: true
|
|
27
31
|
};
|
|
32
|
+
Object.defineProperty(exports, "AddressForm", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _address.default;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
28
38
|
Object.defineProperty(exports, "Amount", {
|
|
29
39
|
enumerable: true,
|
|
30
40
|
get: function () {
|
|
@@ -49,6 +59,12 @@ Object.defineProperty(exports, "ConfirmDialog", {
|
|
|
49
59
|
return _confirm.default;
|
|
50
60
|
}
|
|
51
61
|
});
|
|
62
|
+
Object.defineProperty(exports, "CurrencySelector", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () {
|
|
65
|
+
return _currency.default;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
52
68
|
Object.defineProperty(exports, "CustomerInvoiceList", {
|
|
53
69
|
enumerable: true,
|
|
54
70
|
get: function () {
|
|
@@ -85,6 +101,12 @@ Object.defineProperty(exports, "Payment", {
|
|
|
85
101
|
return _index.default;
|
|
86
102
|
}
|
|
87
103
|
});
|
|
104
|
+
Object.defineProperty(exports, "PaymentSummary", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () {
|
|
107
|
+
return _summary.default;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
88
110
|
Object.defineProperty(exports, "PhoneInput", {
|
|
89
111
|
enumerable: true,
|
|
90
112
|
get: function () {
|
|
@@ -109,6 +131,12 @@ Object.defineProperty(exports, "Status", {
|
|
|
109
131
|
return _status.default;
|
|
110
132
|
}
|
|
111
133
|
});
|
|
134
|
+
Object.defineProperty(exports, "StripeForm", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function () {
|
|
137
|
+
return _stripe.default;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
112
140
|
Object.defineProperty(exports, "Switch", {
|
|
113
141
|
enumerable: true,
|
|
114
142
|
get: function () {
|
|
@@ -160,9 +188,13 @@ var _list = _interopRequireDefault(require("./history/invoice/list"));
|
|
|
160
188
|
var _list2 = _interopRequireDefault(require("./history/mini-invoice/list"));
|
|
161
189
|
var _list3 = _interopRequireDefault(require("./history/payment/list"));
|
|
162
190
|
var _amount = _interopRequireDefault(require("./payment/amount"));
|
|
191
|
+
var _address = _interopRequireDefault(require("./payment/form/address"));
|
|
192
|
+
var _currency = _interopRequireDefault(require("./payment/form/currency"));
|
|
163
193
|
var _phone = _interopRequireDefault(require("./payment/form/phone"));
|
|
194
|
+
var _stripe = _interopRequireDefault(require("./payment/form/stripe"));
|
|
164
195
|
var _index = _interopRequireDefault(require("./payment/index"));
|
|
165
196
|
var _productSkeleton = _interopRequireDefault(require("./payment/product-skeleton"));
|
|
197
|
+
var _summary = _interopRequireDefault(require("./payment/summary"));
|
|
166
198
|
var _util = require("./util");
|
|
167
199
|
Object.keys(_util).forEach(function (key) {
|
|
168
200
|
if (key === "default" || key === "__esModule") return;
|
package/lib/locales/en.js
CHANGED
|
@@ -47,6 +47,7 @@ module.exports = (0, _flat.default)({
|
|
|
47
47
|
did: "DID",
|
|
48
48
|
txHash: "Transaction",
|
|
49
49
|
customer: "Customer",
|
|
50
|
+
currency: "Currency",
|
|
50
51
|
custom: "Custom",
|
|
51
52
|
description: "Description",
|
|
52
53
|
statementDescriptor: "Statement descriptor",
|
|
@@ -190,7 +191,7 @@ module.exports = (0, _flat.default)({
|
|
|
190
191
|
title: "Renew your subscription",
|
|
191
192
|
description: "Your subscription will no longer be canceled, it will renew on {date}"
|
|
192
193
|
},
|
|
193
|
-
|
|
194
|
+
changePlan: {
|
|
194
195
|
button: "Update",
|
|
195
196
|
current: "Current",
|
|
196
197
|
pay: "Payment Required",
|
|
@@ -203,7 +204,16 @@ module.exports = (0, _flat.default)({
|
|
|
203
204
|
total: "Total (metered items excluded)",
|
|
204
205
|
appliedCredit: "Credit applied",
|
|
205
206
|
newCredit: "Credit issued",
|
|
206
|
-
remaining: "Amount due today"
|
|
207
|
+
remaining: "Amount due today",
|
|
208
|
+
tableNotFound: "Plan updates are not available"
|
|
209
|
+
},
|
|
210
|
+
changePayment: {
|
|
211
|
+
limit: "Your changes to payment method will not affect existing open or past-due invoices, all future payments will use the new payment method unless you change it again.",
|
|
212
|
+
review: "Review subscription items",
|
|
213
|
+
select: "Select payment method",
|
|
214
|
+
submit: "Confirm change",
|
|
215
|
+
confirm: "By confirming this change, you allow {payee} to charge {symbol} from your account for future payments in accordance with their terms. You can always change your payment method.",
|
|
216
|
+
completed: "Your payment method has been successfully updated, all future payments will use the new payment method unless you change it again."
|
|
207
217
|
},
|
|
208
218
|
invoice: {
|
|
209
219
|
summary: "Summary",
|
|
@@ -233,7 +243,8 @@ module.exports = (0, _flat.default)({
|
|
|
233
243
|
nextInvoice: "Next Invoice",
|
|
234
244
|
title: "Manage subscriptions",
|
|
235
245
|
current: "Current subscription",
|
|
236
|
-
empty: "There are no subscriptions here"
|
|
246
|
+
empty: "There are no subscriptions here",
|
|
247
|
+
changePayment: "Change payment method"
|
|
237
248
|
}
|
|
238
249
|
}
|
|
239
250
|
}
|
package/lib/locales/zh.js
CHANGED
|
@@ -47,6 +47,7 @@ module.exports = (0, _flat.default)({
|
|
|
47
47
|
did: "DID",
|
|
48
48
|
txHash: "\u4EA4\u6613\u54C8\u5E0C",
|
|
49
49
|
customer: "\u5BA2\u6237",
|
|
50
|
+
currency: "\u5E01\u79CD",
|
|
50
51
|
custom: "\u81EA\u5B9A\u4E49",
|
|
51
52
|
description: "\u63CF\u8FF0",
|
|
52
53
|
statementDescriptor: "\u58F0\u660E\u63CF\u8FF0",
|
|
@@ -190,7 +191,7 @@ module.exports = (0, _flat.default)({
|
|
|
190
191
|
title: "\u7EED\u8BA2\u60A8\u7684\u8BA2\u9605",
|
|
191
192
|
description: "\u60A8\u7684\u8BA2\u9605\u5C06\u4E0D\u518D\u88AB\u53D6\u6D88\uFF0C\u5C06\u5728{date}\u7EED\u8BA2"
|
|
192
193
|
},
|
|
193
|
-
|
|
194
|
+
changePlan: {
|
|
194
195
|
button: "\u66F4\u65B0",
|
|
195
196
|
current: "\u5F53\u524D\u8BA2\u9605",
|
|
196
197
|
pay: "\u9700\u8981\u652F\u4ED8",
|
|
@@ -203,7 +204,16 @@ module.exports = (0, _flat.default)({
|
|
|
203
204
|
total: "\u5957\u9910\u5B9A\u4EF7\uFF08\u4E0D\u542B\u6309\u91CF\u90E8\u5206\uFF09",
|
|
204
205
|
appliedCredit: "\u4FE1\u7528\u6263\u9664",
|
|
205
206
|
newCredit: "\u4FE1\u7528\u589E\u52A0",
|
|
206
|
-
remaining: "\u8FD8\u9700\u652F\u4ED8"
|
|
207
|
+
remaining: "\u8FD8\u9700\u652F\u4ED8",
|
|
208
|
+
tableNotFound: "\u5957\u9910\u53D8\u66F4\u4E0D\u53EF\u7528"
|
|
209
|
+
},
|
|
210
|
+
changePayment: {
|
|
211
|
+
limit: "\u4F60\u5BF9\u652F\u4ED8\u65B9\u5F0F\u7684\u53D8\u66F4\u4E0D\u4F1A\u5F71\u54CD\u5DF2\u7ECF\u751F\u6210\u6216\u8005\u6B20\u8D39\u7684\u8D26\u5355\uFF0C\u53EA\u4F1A\u5F71\u54CD\u672A\u6765\u7684\u8D26\u5355\u3002\u4F60\u53EF\u4EE5\u5728\u4E0B\u4E00\u5F20\u8D26\u5355\u751F\u6210\u4E4B\u524D\u53D8\u66F4\u652F\u4ED8\u65B9\u5F0F\u3002",
|
|
212
|
+
review: "\u67E5\u770B\u8BA2\u9605\u8BE6\u60C5",
|
|
213
|
+
select: "\u9009\u62E9\u652F\u4ED8\u65B9\u5F0F",
|
|
214
|
+
submit: "\u786E\u8BA4\u53D8\u66F4",
|
|
215
|
+
confirm: "\u786E\u8BA4\u53D8\u66F4\u65B9\u5F0F\u610F\u5473\u7740\u4F60\u5141\u8BB8{payee}\u4F7F\u7528\u65B0\u7684\u652F\u4ED8\u65B9\u5F0F\u652F\u4ED8\u4F60\u7684\u672A\u6765\u8D26\u5355\u3002\u4F60\u53EF\u4EE5\u968F\u65F6\u518D\u6B21\u53D8\u66F4\u652F\u4ED8\u65B9\u5F0F\u3002",
|
|
216
|
+
completed: "\u4F60\u7684\u652F\u4ED8\u65B9\u5F0F \u5DF2\u7ECF\u66F4\u65B0\u6210\u529F\u3002\u4F60\u53EF\u4EE5\u5728\u4F60\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u652F\u4ED8\u65B9\u5F0F\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002"
|
|
207
217
|
},
|
|
208
218
|
invoice: {
|
|
209
219
|
summary: "\u6458\u8981",
|
|
@@ -233,7 +243,8 @@ module.exports = (0, _flat.default)({
|
|
|
233
243
|
nextInvoice: "\u4E0B\u4E00\u5F20\u53D1\u7968",
|
|
234
244
|
title: "\u8BA2\u9605\u7BA1\u7406",
|
|
235
245
|
current: "\u5F53\u524D\u8BA2\u9605",
|
|
236
|
-
empty: "\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605"
|
|
246
|
+
empty: "\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605",
|
|
247
|
+
changePayment: "\u5207\u6362\u652F\u4ED8\u65B9\u5F0F"
|
|
237
248
|
}
|
|
238
249
|
}
|
|
239
250
|
}
|
|
@@ -141,7 +141,10 @@ function AddressForm({
|
|
|
141
141
|
},
|
|
142
142
|
errorPosition: "right",
|
|
143
143
|
variant: "outlined",
|
|
144
|
-
placeholder: t("payment.checkout.billing.postal_code")
|
|
144
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
145
|
+
wrapperStyle: {
|
|
146
|
+
height: "40px"
|
|
147
|
+
}
|
|
145
148
|
})]
|
|
146
149
|
})
|
|
147
150
|
})]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TPaymentCurrency } from '@blocklet/payment-types';
|
|
3
|
+
type Props = {
|
|
4
|
+
value: number;
|
|
5
|
+
currencies: TPaymentCurrency[];
|
|
6
|
+
onChange: Function;
|
|
7
|
+
};
|
|
8
|
+
export default function CurrencySelector({ value, currencies, onChange }: Props): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = CurrencySelector;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _system = require("@mui/system");
|
|
10
|
+
function CurrencySelector({
|
|
11
|
+
value,
|
|
12
|
+
currencies,
|
|
13
|
+
onChange
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Root, {
|
|
16
|
+
style: {
|
|
17
|
+
display: currencies.length > 1 ? "grid" : "block",
|
|
18
|
+
gridTemplateColumns: "50% 50%",
|
|
19
|
+
width: "100%"
|
|
20
|
+
},
|
|
21
|
+
children: currencies.map((x, i) => {
|
|
22
|
+
const selected = i === value;
|
|
23
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Card, {
|
|
24
|
+
variant: "outlined",
|
|
25
|
+
onClick: () => onChange(i),
|
|
26
|
+
className: selected ? "cko-payment-card" : "cko-payment-card-unselect",
|
|
27
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
28
|
+
direction: "row",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
31
|
+
src: x.logo,
|
|
32
|
+
alt: x.name,
|
|
33
|
+
sx: {
|
|
34
|
+
width: 30,
|
|
35
|
+
height: 30,
|
|
36
|
+
marginRight: "10px"
|
|
37
|
+
}
|
|
38
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)("div", {
|
|
39
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
40
|
+
variant: "h5",
|
|
41
|
+
component: "div",
|
|
42
|
+
sx: {
|
|
43
|
+
fontSize: "18px"
|
|
44
|
+
},
|
|
45
|
+
children: x.symbol
|
|
46
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
47
|
+
sx: {
|
|
48
|
+
fontSize: 14
|
|
49
|
+
},
|
|
50
|
+
color: "text.secondary",
|
|
51
|
+
gutterBottom: true,
|
|
52
|
+
children: x.method.name
|
|
53
|
+
})]
|
|
54
|
+
})]
|
|
55
|
+
})
|
|
56
|
+
}, x.id);
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const Root = (0, _system.styled)("section")`
|
|
61
|
+
.cko-payment-card {
|
|
62
|
+
position: relative;
|
|
63
|
+
border: 2px solid ${props => props.theme.palette.primary.main};
|
|
64
|
+
padding: 5px 10px;
|
|
65
|
+
margin: 5px 0;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.cko-payment-card::before {
|
|
70
|
+
content: '';
|
|
71
|
+
position: absolute;
|
|
72
|
+
right: 0;
|
|
73
|
+
bottom: 0;
|
|
74
|
+
border: 12px solid ${props => props.theme.palette.primary.main};
|
|
75
|
+
border-top-color: transparent;
|
|
76
|
+
border-left-color: transparent;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.cko-payment-card-unselect {
|
|
80
|
+
border: 2px solid #ddd;
|
|
81
|
+
padding: 5px 10px;
|
|
82
|
+
margin: 5px 0;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.cko-payment-card:nth-child(odd) {
|
|
87
|
+
margin-right: 8px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.cko-payment-card-unselect:nth-child(odd) {
|
|
91
|
+
margin-right: 8px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.cko-payment-card::after {
|
|
95
|
+
content: '';
|
|
96
|
+
width: 6px;
|
|
97
|
+
height: 10px;
|
|
98
|
+
position: absolute;
|
|
99
|
+
right: 3px;
|
|
100
|
+
bottom: 3px;
|
|
101
|
+
border: 2px solid #fff;
|
|
102
|
+
border-top-color: transparent;
|
|
103
|
+
border-left-color: transparent;
|
|
104
|
+
transform: rotate(35deg);
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
@@ -26,6 +26,7 @@ var _payment = require("../../contexts/payment");
|
|
|
26
26
|
var _util = require("../../util");
|
|
27
27
|
var _addon = _interopRequireDefault(require("./addon"));
|
|
28
28
|
var _address = _interopRequireDefault(require("./address"));
|
|
29
|
+
var _currency = _interopRequireDefault(require("./currency"));
|
|
29
30
|
var _phone = _interopRequireDefault(require("./phone"));
|
|
30
31
|
var _stripe = _interopRequireDefault(require("./stripe"));
|
|
31
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -47,19 +48,6 @@ const waitForCheckoutComplete = async sessionId => {
|
|
|
47
48
|
});
|
|
48
49
|
return result;
|
|
49
50
|
};
|
|
50
|
-
const flatPaymentMethods = (methods = []) => {
|
|
51
|
-
const out = [];
|
|
52
|
-
methods.forEach(method => {
|
|
53
|
-
const currencies = method.paymentCurrencies || method.payment_currencies || [];
|
|
54
|
-
currencies.forEach(currency => {
|
|
55
|
-
out.push({
|
|
56
|
-
...currency,
|
|
57
|
-
method
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
return out;
|
|
62
|
-
};
|
|
63
51
|
PaymentForm.defaultProps = {};
|
|
64
52
|
function PaymentForm({
|
|
65
53
|
checkoutSession,
|
|
@@ -94,7 +82,7 @@ function PaymentForm({
|
|
|
94
82
|
customerLimited: false,
|
|
95
83
|
stripePaying: false
|
|
96
84
|
});
|
|
97
|
-
const currencies =
|
|
85
|
+
const currencies = (0, _util.flattenPaymentMethods)(paymentMethods);
|
|
98
86
|
const [paymentCurrencyIndex, setPaymentCurrencyIndex] = (0, _react.useState)(0);
|
|
99
87
|
(0, _react.useEffect)(() => {
|
|
100
88
|
if (session?.user) {
|
|
@@ -132,9 +120,6 @@ function PaymentForm({
|
|
|
132
120
|
action: t(`payment.checkout.${checkoutSession.mode}`)
|
|
133
121
|
});
|
|
134
122
|
const method = paymentMethods.find(x => x.id === paymentMethod);
|
|
135
|
-
const handleCurrencyChange = index => {
|
|
136
|
-
setPaymentCurrencyIndex(index);
|
|
137
|
-
};
|
|
138
123
|
const handleConnected = async () => {
|
|
139
124
|
try {
|
|
140
125
|
const result = await waitForCheckoutComplete(checkoutSession.id);
|
|
@@ -224,6 +209,7 @@ function PaymentForm({
|
|
|
224
209
|
});
|
|
225
210
|
},
|
|
226
211
|
onError: err => {
|
|
212
|
+
console.error(err);
|
|
227
213
|
setState({
|
|
228
214
|
submitting: false,
|
|
229
215
|
paying: false
|
|
@@ -245,6 +231,7 @@ function PaymentForm({
|
|
|
245
231
|
}
|
|
246
232
|
}
|
|
247
233
|
} catch (err) {
|
|
234
|
+
console.error(err);
|
|
248
235
|
let shouldToast = true;
|
|
249
236
|
if (err.response?.data?.code) {
|
|
250
237
|
(0, _useBus.dispatch)(`error.${err.response?.data?.code}`);
|
|
@@ -380,49 +367,10 @@ function PaymentForm({
|
|
|
380
367
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.Controller, {
|
|
381
368
|
name: "payment_currency",
|
|
382
369
|
control,
|
|
383
|
-
render: () => /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
width: "100%"
|
|
388
|
-
},
|
|
389
|
-
children: currencies.map((x, i) => {
|
|
390
|
-
const selected = i === paymentCurrencyIndex;
|
|
391
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Card, {
|
|
392
|
-
variant: "outlined",
|
|
393
|
-
onClick: () => handleCurrencyChange(i),
|
|
394
|
-
className: selected ? "cko-payment-card" : "cko-payment-card-unselect",
|
|
395
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
396
|
-
direction: "row",
|
|
397
|
-
alignItems: "center",
|
|
398
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
399
|
-
src: x.logo,
|
|
400
|
-
alt: x.name,
|
|
401
|
-
sx: {
|
|
402
|
-
width: 30,
|
|
403
|
-
height: 30,
|
|
404
|
-
marginRight: "10px"
|
|
405
|
-
}
|
|
406
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)("div", {
|
|
407
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
408
|
-
variant: "h5",
|
|
409
|
-
component: "div",
|
|
410
|
-
sx: {
|
|
411
|
-
fontSize: "18px"
|
|
412
|
-
},
|
|
413
|
-
children: x.symbol
|
|
414
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
415
|
-
sx: {
|
|
416
|
-
fontSize: 14
|
|
417
|
-
},
|
|
418
|
-
color: "text.secondary",
|
|
419
|
-
gutterBottom: true,
|
|
420
|
-
children: x.method.name
|
|
421
|
-
})]
|
|
422
|
-
})]
|
|
423
|
-
})
|
|
424
|
-
}, x.id);
|
|
425
|
-
})
|
|
370
|
+
render: () => /* @__PURE__ */(0, _jsxRuntime.jsx)(_currency.default, {
|
|
371
|
+
value: paymentCurrencyIndex,
|
|
372
|
+
currencies,
|
|
373
|
+
onChange: setPaymentCurrencyIndex
|
|
426
374
|
})
|
|
427
375
|
})
|
|
428
376
|
}), state.stripePaying && state.stripeContext && /* @__PURE__ */(0, _jsxRuntime.jsx)(_stripe.default, {
|