@blocklet/payment-react 1.14.22 → 1.14.23
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/README.md +77 -0
- package/es/checkout/donate.d.ts +3 -2
- package/es/checkout/donate.js +5 -1
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +31 -7
- package/es/checkout/table.js +4 -1
- package/es/components/input.d.ts +3 -3
- package/es/libs/util.d.ts +6 -6
- package/es/payment/index.d.ts +3 -1
- package/es/payment/index.js +67 -51
- package/es/payment/product-donation.js +2 -1
- package/es/theme/index.d.ts +8 -3
- package/es/theme/index.js +222 -209
- package/es/types/index.d.ts +6 -1
- package/lib/checkout/donate.d.ts +3 -2
- package/lib/checkout/donate.js +10 -1
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +41 -17
- package/lib/checkout/table.js +9 -1
- package/lib/components/input.d.ts +3 -3
- package/lib/libs/util.d.ts +6 -6
- package/lib/payment/index.d.ts +3 -1
- package/lib/payment/index.js +31 -26
- package/lib/payment/product-donation.js +2 -5
- package/lib/theme/index.d.ts +8 -3
- package/lib/theme/index.js +211 -197
- package/lib/types/index.d.ts +6 -1
- package/package.json +3 -3
- package/src/checkout/donate.tsx +11 -3
- package/src/checkout/form.tsx +43 -18
- package/src/checkout/table.tsx +8 -1
- package/src/payment/index.tsx +66 -51
- package/src/payment/product-donation.tsx +2 -1
- package/src/theme/index.tsx +224 -203
- package/src/types/index.ts +6 -1
package/README.md
CHANGED
|
@@ -68,3 +68,80 @@ import zh from './zh';
|
|
|
68
68
|
// eslint-disable-next-line import/prefer-default-export
|
|
69
69
|
export const translations = merge({ zh, en }, extraTranslations);
|
|
70
70
|
```
|
|
71
|
+
|
|
72
|
+
## Updates
|
|
73
|
+
|
|
74
|
+
#### theme
|
|
75
|
+
Since version 1.14.22, the component includes a built-in theme provider. If you need to modify the styles of internal components, you need to pass the `theme` property to override or inherit the external theme.
|
|
76
|
+
|
|
77
|
+
| option |description |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| default [default value] | wrapped with built-in PaymentThemeProvider |
|
|
80
|
+
| inherit | use the parent component's themeProvider |
|
|
81
|
+
| PaymentThemeOptions | override some styles of PaymentThemeProvider |
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
export type PaymentThemeOptions = ThemeOptions & {
|
|
85
|
+
sx?: SxProps;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
```js
|
|
90
|
+
// 1. use themeOptions
|
|
91
|
+
<CheckoutForm
|
|
92
|
+
id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
|
|
93
|
+
onChange={console.info}
|
|
94
|
+
theme={{
|
|
95
|
+
components: {
|
|
96
|
+
MuiButton: {
|
|
97
|
+
styleOverrides: {
|
|
98
|
+
containedPrimary: {
|
|
99
|
+
backgroundColor: '#1DC1C7',
|
|
100
|
+
color: '#fff',
|
|
101
|
+
'&:hover': {
|
|
102
|
+
backgroundColor: 'rgb(20, 135, 139)',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
|
|
111
|
+
// 2. use theme sx
|
|
112
|
+
<CheckoutForm
|
|
113
|
+
id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
|
|
114
|
+
mode="inline-minimal"
|
|
115
|
+
onChange={console.info}
|
|
116
|
+
theme={{
|
|
117
|
+
sx: {
|
|
118
|
+
'.cko-submit-button': {
|
|
119
|
+
backgroundColor: '#1DC1C7',
|
|
120
|
+
color: '#fff',
|
|
121
|
+
'&:hover': {
|
|
122
|
+
backgroundColor: 'rgb(20, 135, 139)',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### showCheckoutSummary
|
|
131
|
+
|
|
132
|
+
Since version 1.14.23, if you need to hide the product column, we recommend using `showCheckoutSummary=false` instead of `mode=inline-minimal`. We aim for better semantics.
|
|
133
|
+
```js
|
|
134
|
+
// bad
|
|
135
|
+
<CheckoutForm
|
|
136
|
+
id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
|
|
137
|
+
mode="inline-minimal"
|
|
138
|
+
onChange={console.info}
|
|
139
|
+
/>
|
|
140
|
+
|
|
141
|
+
// good
|
|
142
|
+
<CheckoutForm
|
|
143
|
+
id="plink_oB1I6FNeHKSkuq81fhJy0vIZ"
|
|
144
|
+
showCheckoutSummary={false}
|
|
145
|
+
onChange={console.info}
|
|
146
|
+
/>
|
|
147
|
+
```
|
package/es/checkout/donate.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DonationSettings, TCheckoutSessionExpanded, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
3
|
import { ButtonProps as MUIButtonProps } from '@mui/material';
|
|
4
|
-
import { CheckoutProps } from '../types';
|
|
4
|
+
import { CheckoutProps, PaymentThemeOptions } from '../types';
|
|
5
5
|
export type DonateHistory = {
|
|
6
6
|
supporters: TCheckoutSessionExpanded[];
|
|
7
7
|
currency: TPaymentCurrency;
|
|
@@ -20,11 +20,12 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
20
20
|
inlineOptions?: {
|
|
21
21
|
button?: ButtonType;
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
24
24
|
};
|
|
25
25
|
declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
|
|
26
26
|
declare namespace CheckoutDonate {
|
|
27
27
|
var defaultProps: {
|
|
28
|
+
theme: string;
|
|
28
29
|
livemode: boolean;
|
|
29
30
|
timeout: number;
|
|
30
31
|
mode: string;
|
package/es/checkout/donate.js
CHANGED
|
@@ -356,12 +356,16 @@ function CheckoutDonateInner({ settings, livemode, timeout, onPaid, onError, mod
|
|
|
356
356
|
] });
|
|
357
357
|
}
|
|
358
358
|
export default function CheckoutDonate(props) {
|
|
359
|
-
if (props.
|
|
359
|
+
if (props.theme === "inherit") {
|
|
360
360
|
return /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props });
|
|
361
361
|
}
|
|
362
|
+
if (props.theme && typeof props.theme === "object") {
|
|
363
|
+
return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme: props.theme, children: /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props }) });
|
|
364
|
+
}
|
|
362
365
|
return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props }) });
|
|
363
366
|
}
|
|
364
367
|
CheckoutDonate.defaultProps = {
|
|
368
|
+
theme: "default",
|
|
365
369
|
livemode: true,
|
|
366
370
|
timeout: 5e3,
|
|
367
371
|
mode: "default",
|
package/es/checkout/form.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutProps } from '../types';
|
|
3
|
-
declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action,
|
|
3
|
+
declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, theme, ...restProps }: CheckoutProps): import("react").JSX.Element;
|
|
4
4
|
declare namespace CheckoutForm {
|
|
5
5
|
var defaultProps: {
|
|
6
6
|
onPaid: any;
|
package/es/checkout/form.js
CHANGED
|
@@ -31,7 +31,8 @@ export default function CheckoutForm({
|
|
|
31
31
|
goBack,
|
|
32
32
|
extraParams,
|
|
33
33
|
action,
|
|
34
|
-
|
|
34
|
+
theme = "default",
|
|
35
|
+
...restProps
|
|
35
36
|
}) {
|
|
36
37
|
if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
|
|
37
38
|
throw new Error("Either a checkoutSession or a paymentLink id is required.");
|
|
@@ -59,8 +60,8 @@ export default function CheckoutForm({
|
|
|
59
60
|
setState({ appError: err });
|
|
60
61
|
onError?.(err);
|
|
61
62
|
};
|
|
62
|
-
if (
|
|
63
|
-
return /* @__PURE__ */ jsx(
|
|
63
|
+
if (theme === "inherit") {
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
64
65
|
Payment,
|
|
65
66
|
{
|
|
66
67
|
checkoutSession: data?.checkoutSession,
|
|
@@ -75,11 +76,33 @@ export default function CheckoutForm({
|
|
|
75
76
|
onChange,
|
|
76
77
|
goBack,
|
|
77
78
|
mode,
|
|
78
|
-
action
|
|
79
|
+
action,
|
|
80
|
+
...restProps
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
if (theme && typeof theme === "object") {
|
|
85
|
+
return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme, children: /* @__PURE__ */ jsx(
|
|
86
|
+
Payment,
|
|
87
|
+
{
|
|
88
|
+
checkoutSession: data?.checkoutSession,
|
|
89
|
+
paymentMethods: data?.paymentMethods,
|
|
90
|
+
paymentIntent: data?.paymentIntent,
|
|
91
|
+
paymentLink: data?.paymentLink,
|
|
92
|
+
customer: data?.customer,
|
|
93
|
+
completed: state.completed,
|
|
94
|
+
error: apiError || state.appError,
|
|
95
|
+
onPaid: handlePaid,
|
|
96
|
+
onError: handleError,
|
|
97
|
+
onChange,
|
|
98
|
+
goBack,
|
|
99
|
+
mode,
|
|
100
|
+
action,
|
|
101
|
+
...restProps
|
|
79
102
|
}
|
|
80
103
|
) });
|
|
81
104
|
}
|
|
82
|
-
return /* @__PURE__ */ jsx(
|
|
105
|
+
return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
83
106
|
Payment,
|
|
84
107
|
{
|
|
85
108
|
checkoutSession: data?.checkoutSession,
|
|
@@ -94,9 +117,10 @@ export default function CheckoutForm({
|
|
|
94
117
|
onChange,
|
|
95
118
|
goBack,
|
|
96
119
|
mode,
|
|
97
|
-
action
|
|
120
|
+
action,
|
|
121
|
+
...restProps
|
|
98
122
|
}
|
|
99
|
-
);
|
|
123
|
+
) });
|
|
100
124
|
}
|
|
101
125
|
CheckoutForm.defaultProps = {
|
|
102
126
|
onPaid: noop,
|
package/es/checkout/table.js
CHANGED
|
@@ -111,8 +111,11 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
|
|
|
111
111
|
) });
|
|
112
112
|
}
|
|
113
113
|
export default function CheckoutTable(props) {
|
|
114
|
-
if (props.
|
|
114
|
+
if (props.theme === "inherit") {
|
|
115
115
|
return /* @__PURE__ */ jsx(CheckoutTableInner, { ...props });
|
|
116
116
|
}
|
|
117
|
+
if (props.theme && typeof props.theme === "object") {
|
|
118
|
+
return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme: props.theme, children: /* @__PURE__ */ jsx(CheckoutTableInner, { ...props }) });
|
|
119
|
+
}
|
|
117
120
|
return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(CheckoutTableInner, { ...props }) });
|
|
118
121
|
}
|
package/es/components/input.d.ts
CHANGED
|
@@ -4,21 +4,21 @@ declare const FormInput: import("react").ForwardRefExoticComponent<(Omit<import(
|
|
|
4
4
|
name: string;
|
|
5
5
|
label?: string | undefined;
|
|
6
6
|
placeholder?: string | undefined;
|
|
7
|
-
errorPosition?: "
|
|
7
|
+
errorPosition?: "bottom" | "right" | undefined;
|
|
8
8
|
rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
|
|
9
9
|
wrapperStyle?: any;
|
|
10
10
|
}, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
|
|
11
11
|
name: string;
|
|
12
12
|
label?: string | undefined;
|
|
13
13
|
placeholder?: string | undefined;
|
|
14
|
-
errorPosition?: "
|
|
14
|
+
errorPosition?: "bottom" | "right" | undefined;
|
|
15
15
|
rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
|
|
16
16
|
wrapperStyle?: any;
|
|
17
17
|
}, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
|
|
18
18
|
name: string;
|
|
19
19
|
label?: string | undefined;
|
|
20
20
|
placeholder?: string | undefined;
|
|
21
|
-
errorPosition?: "
|
|
21
|
+
errorPosition?: "bottom" | "right" | undefined;
|
|
22
22
|
rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
|
|
23
23
|
wrapperStyle?: any;
|
|
24
24
|
}, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
|
package/es/libs/util.d.ts
CHANGED
|
@@ -24,12 +24,12 @@ export declare function formatLineItemPricing(item: TLineItemExpanded, currency:
|
|
|
24
24
|
secondary?: string;
|
|
25
25
|
quantity: string;
|
|
26
26
|
};
|
|
27
|
-
export declare function getSubscriptionStatusColor(status: string): "
|
|
28
|
-
export declare function getPaymentIntentStatusColor(status: string): "
|
|
29
|
-
export declare function getRefundStatusColor(status: string): "
|
|
30
|
-
export declare function getPayoutStatusColor(status: string): "
|
|
31
|
-
export declare function getInvoiceStatusColor(status: string): "
|
|
32
|
-
export declare function getWebhookStatusColor(status: string): "
|
|
27
|
+
export declare function getSubscriptionStatusColor(status: string): "default" | "success" | "primary" | "warning" | "error";
|
|
28
|
+
export declare function getPaymentIntentStatusColor(status: string): "default" | "success" | "warning";
|
|
29
|
+
export declare function getRefundStatusColor(status: string): "default" | "success" | "warning";
|
|
30
|
+
export declare function getPayoutStatusColor(status: string): "default" | "success" | "warning";
|
|
31
|
+
export declare function getInvoiceStatusColor(status: string): "default" | "success" | "warning" | "secondary";
|
|
32
|
+
export declare function getWebhookStatusColor(status: string): "default" | "success";
|
|
33
33
|
export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean): {
|
|
34
34
|
subtotal: any;
|
|
35
35
|
total: any;
|
package/es/payment/index.d.ts
CHANGED
|
@@ -4,12 +4,14 @@ import { CheckoutCallbacks, CheckoutContext } from '../types';
|
|
|
4
4
|
type Props = CheckoutContext & CheckoutCallbacks & {
|
|
5
5
|
completed?: boolean;
|
|
6
6
|
error?: any;
|
|
7
|
+
showCheckoutSummary?: boolean;
|
|
7
8
|
};
|
|
8
|
-
declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, mode, onPaid, onError, onChange, goBack, action, }: Props): import("react").JSX.Element;
|
|
9
|
+
declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, mode, onPaid, onError, onChange, goBack, action, showCheckoutSummary, }: Props): import("react").JSX.Element;
|
|
9
10
|
declare namespace Payment {
|
|
10
11
|
var defaultProps: {
|
|
11
12
|
completed: boolean;
|
|
12
13
|
error: null;
|
|
14
|
+
showCheckoutSummary: boolean;
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
export default Payment;
|
package/es/payment/index.js
CHANGED
|
@@ -21,7 +21,8 @@ import PaymentSuccess from "./success.js";
|
|
|
21
21
|
import PaymentSummary from "./summary.js";
|
|
22
22
|
import { useMobile } from "../hooks/mobile.js";
|
|
23
23
|
PaymentInner.defaultProps = {
|
|
24
|
-
completed: false
|
|
24
|
+
completed: false,
|
|
25
|
+
showCheckoutSummary: true
|
|
25
26
|
};
|
|
26
27
|
function PaymentInner({
|
|
27
28
|
checkoutSession,
|
|
@@ -34,7 +35,8 @@ function PaymentInner({
|
|
|
34
35
|
onPaid,
|
|
35
36
|
onError,
|
|
36
37
|
onChange,
|
|
37
|
-
action
|
|
38
|
+
action,
|
|
39
|
+
showCheckoutSummary = true
|
|
38
40
|
}) {
|
|
39
41
|
const { t } = useLocaleContext();
|
|
40
42
|
const { settings, session } = usePaymentContext();
|
|
@@ -42,6 +44,7 @@ function PaymentInner({
|
|
|
42
44
|
const [state, setState] = useSetState({ checkoutSession });
|
|
43
45
|
const defaultCurrencyId = state.checkoutSession.currency_id || state.checkoutSession.line_items[0]?.price.currency_id;
|
|
44
46
|
const defaultMethodId = paymentMethods.find((m) => m.payment_currencies.some((c) => c.id === defaultCurrencyId))?.id;
|
|
47
|
+
const hideSummaryCard = mode.endsWith("-minimal") || !showCheckoutSummary;
|
|
45
48
|
const methods = useForm({
|
|
46
49
|
defaultValues: {
|
|
47
50
|
customer_name: customer?.name || session?.user?.fullName || "",
|
|
@@ -124,7 +127,7 @@ function PaymentInner({
|
|
|
124
127
|
onPaid(result);
|
|
125
128
|
};
|
|
126
129
|
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-container", sx: { gap: { sm: mode === "standalone" ? 0 : mode === "inline" ? 4 : 8 } }, children: [
|
|
127
|
-
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-overview
|
|
130
|
+
!hideSummaryCard && /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "base-card cko-overview", direction: "column", children: [
|
|
128
131
|
/* @__PURE__ */ jsx(
|
|
129
132
|
PaymentSummary,
|
|
130
133
|
{
|
|
@@ -150,41 +153,53 @@ function PaymentInner({
|
|
|
150
153
|
),
|
|
151
154
|
mode === "standalone" && !isMobile && /* @__PURE__ */ jsx(CheckoutFooter, { className: "cko-footer", sx: { color: "var(--foregrounds-fg-muted, #98A3B1)" } })
|
|
152
155
|
] }) }),
|
|
153
|
-
/* @__PURE__ */ jsxs(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
/* @__PURE__ */ jsxs(
|
|
157
|
+
Stack,
|
|
158
|
+
{
|
|
159
|
+
className: "base-card cko-payment",
|
|
160
|
+
direction: "column",
|
|
161
|
+
spacing: {
|
|
162
|
+
xs: 2,
|
|
163
|
+
sm: 3
|
|
164
|
+
},
|
|
165
|
+
children: [
|
|
166
|
+
completed && /* @__PURE__ */ jsx(
|
|
167
|
+
PaymentSuccess,
|
|
168
|
+
{
|
|
169
|
+
mode,
|
|
170
|
+
payee: getStatementDescriptor(state.checkoutSession.line_items),
|
|
171
|
+
action: state.checkoutSession.mode,
|
|
172
|
+
invoiceId: state.checkoutSession.invoice_id,
|
|
173
|
+
subscriptionId: state.checkoutSession.subscription_id,
|
|
174
|
+
message: paymentLink?.after_completion?.hosted_confirmation?.custom_message || t(
|
|
175
|
+
`payment.checkout.completed.${state.checkoutSession.submit_type === "donate" ? "donate" : state.checkoutSession.mode}`
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
!completed && /* @__PURE__ */ jsx(
|
|
180
|
+
PaymentForm,
|
|
181
|
+
{
|
|
182
|
+
checkoutSession: state.checkoutSession,
|
|
183
|
+
paymentMethods,
|
|
184
|
+
paymentIntent,
|
|
185
|
+
paymentLink,
|
|
186
|
+
customer,
|
|
187
|
+
onPaid: handlePaid,
|
|
188
|
+
onError,
|
|
189
|
+
mode,
|
|
190
|
+
action
|
|
191
|
+
}
|
|
164
192
|
)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
PaymentForm,
|
|
169
|
-
{
|
|
170
|
-
checkoutSession: state.checkoutSession,
|
|
171
|
-
paymentMethods,
|
|
172
|
-
paymentIntent,
|
|
173
|
-
paymentLink,
|
|
174
|
-
customer,
|
|
175
|
-
onPaid: handlePaid,
|
|
176
|
-
onError,
|
|
177
|
-
mode,
|
|
178
|
-
action
|
|
179
|
-
}
|
|
180
|
-
)
|
|
181
|
-
] }),
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
),
|
|
182
196
|
mode === "standalone" && isMobile && /* @__PURE__ */ jsx(CheckoutFooter, { className: "cko-footer", sx: { color: "var(--foregrounds-fg-muted, #98A3B1)" } })
|
|
183
197
|
] }) });
|
|
184
198
|
}
|
|
185
199
|
Payment.defaultProps = {
|
|
186
200
|
completed: false,
|
|
187
|
-
error: null
|
|
201
|
+
error: null,
|
|
202
|
+
showCheckoutSummary: true
|
|
188
203
|
};
|
|
189
204
|
export default function Payment({
|
|
190
205
|
checkoutSession,
|
|
@@ -199,11 +214,13 @@ export default function Payment({
|
|
|
199
214
|
onError,
|
|
200
215
|
onChange,
|
|
201
216
|
goBack,
|
|
202
|
-
action
|
|
217
|
+
action,
|
|
218
|
+
showCheckoutSummary = true
|
|
203
219
|
}) {
|
|
204
220
|
const { t } = useLocaleContext();
|
|
205
221
|
const { refresh, livemode, setLivemode } = usePaymentContext();
|
|
206
222
|
const [delay, setDelay] = useState(false);
|
|
223
|
+
const hideSummaryCard = mode.endsWith("-minimal") || !showCheckoutSummary;
|
|
207
224
|
useEffect(() => {
|
|
208
225
|
setTimeout(() => {
|
|
209
226
|
setDelay(true);
|
|
@@ -222,8 +239,8 @@ export default function Payment({
|
|
|
222
239
|
const renderContent = () => {
|
|
223
240
|
if (!checkoutSession || !delay) {
|
|
224
241
|
return /* @__PURE__ */ jsxs(Stack, { className: "cko-container", sx: { gap: { sm: mode === "standalone" ? 0 : mode === "inline" ? 4 : 8 } }, children: [
|
|
225
|
-
/* @__PURE__ */ jsx(Stack, { className: "cko-overview
|
|
226
|
-
/* @__PURE__ */ jsx(Stack, { className: "cko-payment
|
|
242
|
+
!hideSummaryCard && /* @__PURE__ */ jsx(Stack, { className: "base-card cko-overview", children: /* @__PURE__ */ jsx(Box, { className: "cko-product", children: /* @__PURE__ */ jsx(OverviewSkeleton, {}) }) }),
|
|
243
|
+
/* @__PURE__ */ jsx(Stack, { className: "base-card cko-payment", children: /* @__PURE__ */ jsx(PaymentSkeleton, {}) })
|
|
227
244
|
] });
|
|
228
245
|
}
|
|
229
246
|
if (checkoutSession.expires_at <= Math.round(Date.now() / 1e3)) {
|
|
@@ -260,7 +277,8 @@ export default function Payment({
|
|
|
260
277
|
onChange,
|
|
261
278
|
goBack,
|
|
262
279
|
mode,
|
|
263
|
-
action
|
|
280
|
+
action,
|
|
281
|
+
showCheckoutSummary
|
|
264
282
|
}
|
|
265
283
|
);
|
|
266
284
|
};
|
|
@@ -322,16 +340,24 @@ export const Root = styled(Box)`
|
|
|
322
340
|
// padding: ${(props) => props.mode === "standalone" ? "0 16px" : "0"};
|
|
323
341
|
}
|
|
324
342
|
|
|
343
|
+
.base-card {
|
|
344
|
+
border: none;
|
|
345
|
+
border-radius: 0;
|
|
346
|
+
padding: ${(props) => props.mode === "standalone" ? "100px 40px 20px" : "20px 0"};
|
|
347
|
+
box-shadow: none;
|
|
348
|
+
flex: 1;
|
|
349
|
+
max-width: 582px;
|
|
350
|
+
}
|
|
351
|
+
|
|
325
352
|
.cko-overview {
|
|
326
353
|
// width: ${(props) => props.mode.endsWith("-minimal") ? "100%" : "400px"};
|
|
327
354
|
// min-height: ${(props) => props.mode === "standalone" ? "540px" : "auto"};
|
|
328
355
|
position: relative;
|
|
329
|
-
|
|
356
|
+
flex-direction: column;
|
|
357
|
+
display: ${(props) => props.mode.endsWith("-minimal") ? "none" : "flex"};
|
|
330
358
|
background: var(--backgrounds-bg-base);
|
|
331
359
|
min-height: 'auto';
|
|
332
360
|
// width: 502px;
|
|
333
|
-
display: flex;
|
|
334
|
-
flex-direction: column;
|
|
335
361
|
}
|
|
336
362
|
.cko-header {
|
|
337
363
|
left: 0;
|
|
@@ -357,15 +383,6 @@ export const Root = styled(Box)`
|
|
|
357
383
|
text-overflow: ellipsis;
|
|
358
384
|
}
|
|
359
385
|
|
|
360
|
-
.base-card {
|
|
361
|
-
border: none;
|
|
362
|
-
border-radius: 0;
|
|
363
|
-
padding: ${(props) => props.mode === "standalone" ? "100px 40px 20px" : "20px 0"};
|
|
364
|
-
box-shadow: none;
|
|
365
|
-
flex: 1;
|
|
366
|
-
max-width: 582px;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
386
|
.cko-payment {
|
|
370
387
|
width: 502px;
|
|
371
388
|
// width: ${(props) => props.mode.endsWith("-minimal") ? "100%" : "400px"};
|
|
@@ -405,7 +422,7 @@ export const Root = styled(Box)`
|
|
|
405
422
|
margin-bottom: 4px;
|
|
406
423
|
}
|
|
407
424
|
.MuiBox-root {
|
|
408
|
-
margin:
|
|
425
|
+
margin: 0;
|
|
409
426
|
}
|
|
410
427
|
|
|
411
428
|
.MuiFormHelperText-root {
|
|
@@ -464,9 +481,8 @@ export const Root = styled(Box)`
|
|
|
464
481
|
flex-direction: column;
|
|
465
482
|
align-items: center;
|
|
466
483
|
gap: 32px;
|
|
467
|
-
min-width: 350px;
|
|
468
|
-
max-width: 400px;
|
|
469
484
|
overflow: visible;
|
|
485
|
+
min-width: 200px;
|
|
470
486
|
}
|
|
471
487
|
.cko-overview {
|
|
472
488
|
width: 100%;
|
|
@@ -57,7 +57,8 @@ export default function ProductDonation({
|
|
|
57
57
|
if (event.target.checked) {
|
|
58
58
|
setState({ custom: true, input: state.selected, error: "" });
|
|
59
59
|
} else {
|
|
60
|
-
|
|
60
|
+
setPayable(true);
|
|
61
|
+
handleSelect(preset);
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 1.5, children: [
|
package/es/theme/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { type ThemeOptions } from '@mui/material/styles';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { typography } from './typography';
|
|
4
3
|
import './index.css';
|
|
4
|
+
import { PaymentThemeOptions } from '../types';
|
|
5
5
|
export { typography };
|
|
6
|
-
export declare
|
|
7
|
-
export declare function PaymentThemeProvider({ children }: {
|
|
6
|
+
export declare function PaymentThemeProvider({ children, theme: customTheme, }: {
|
|
8
7
|
children: React.ReactNode;
|
|
8
|
+
theme?: PaymentThemeOptions;
|
|
9
9
|
}): JSX.Element;
|
|
10
|
+
export declare namespace PaymentThemeProvider {
|
|
11
|
+
var defaultProps: {
|
|
12
|
+
theme: {};
|
|
13
|
+
};
|
|
14
|
+
}
|