@blocklet/payment-react 1.14.21 → 1.14.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/checkout/donate.d.ts +2 -1
- package/es/checkout/donate.js +9 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +23 -1
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +8 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +3 -1
- package/es/history/invoice/list.js +215 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +15 -2
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +22 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +21 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +1 -10
- package/es/payment/index.js +274 -219
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +7 -2
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +9 -0
- package/es/theme/index.js +243 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +11 -0
- package/lib/checkout/donate.d.ts +2 -1
- package/lib/checkout/donate.js +14 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +22 -1
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +14 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +3 -1
- package/lib/history/invoice/list.js +290 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +15 -2
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +22 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +21 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +1 -10
- package/lib/payment/index.js +291 -219
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +9 -2
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +9 -0
- package/lib/theme/index.js +259 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +11 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +16 -10
- package/src/checkout/form.tsx +23 -0
- package/src/checkout/table.tsx +13 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +254 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +18 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +17 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +294 -242
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +7 -3
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +250 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +12 -0
package/src/payment/index.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
+
import Header from '@blocklet/ui-react/lib/Header';
|
|
4
6
|
import type {
|
|
5
7
|
TCheckoutSessionExpanded,
|
|
6
8
|
TCustomer,
|
|
@@ -19,144 +21,26 @@ import type { LiteralUnion } from 'type-fest';
|
|
|
19
21
|
|
|
20
22
|
import { usePaymentContext } from '../contexts/payment';
|
|
21
23
|
import api from '../libs/api';
|
|
22
|
-
import {
|
|
23
|
-
findCurrency,
|
|
24
|
-
formatAmountPrecisionLimit,
|
|
25
|
-
formatError,
|
|
26
|
-
getStatementDescriptor,
|
|
27
|
-
isValidCountry,
|
|
28
|
-
} from '../libs/util';
|
|
24
|
+
import { findCurrency, formatError, getStatementDescriptor, isValidCountry } from '../libs/util';
|
|
29
25
|
import { CheckoutCallbacks, CheckoutContext, CheckoutFormData } from '../types';
|
|
30
26
|
import PaymentError from './error';
|
|
31
27
|
import CheckoutFooter from './footer';
|
|
32
28
|
import PaymentForm from './form';
|
|
33
|
-
import PaymentHeader from './header';
|
|
29
|
+
// import PaymentHeader from './header';
|
|
34
30
|
import OverviewSkeleton from './skeleton/overview';
|
|
35
31
|
import PaymentSkeleton from './skeleton/payment';
|
|
36
32
|
import PaymentSuccess from './success';
|
|
37
33
|
import PaymentSummary from './summary';
|
|
34
|
+
import { useMobile } from '../hooks/mobile';
|
|
38
35
|
|
|
36
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
39
37
|
type Props = CheckoutContext & CheckoutCallbacks & { completed?: boolean; error?: any };
|
|
40
38
|
|
|
41
|
-
Payment.defaultProps = {
|
|
42
|
-
completed: false,
|
|
43
|
-
error: null,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default function Payment({
|
|
47
|
-
checkoutSession,
|
|
48
|
-
paymentMethods,
|
|
49
|
-
paymentIntent,
|
|
50
|
-
paymentLink,
|
|
51
|
-
customer,
|
|
52
|
-
completed,
|
|
53
|
-
error,
|
|
54
|
-
mode,
|
|
55
|
-
onPaid,
|
|
56
|
-
onError,
|
|
57
|
-
onChange,
|
|
58
|
-
goBack,
|
|
59
|
-
action,
|
|
60
|
-
}: Props) {
|
|
61
|
-
const { t } = useLocaleContext();
|
|
62
|
-
const { refresh, livemode, setLivemode } = usePaymentContext();
|
|
63
|
-
const [delay, setDelay] = useState(false);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
setTimeout(() => {
|
|
67
|
-
// 骨架屏 delay
|
|
68
|
-
setDelay(true);
|
|
69
|
-
}, 500);
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (checkoutSession) {
|
|
74
|
-
if (livemode !== checkoutSession.livemode) {
|
|
75
|
-
setLivemode(checkoutSession.livemode);
|
|
76
|
-
setTimeout(() => {
|
|
77
|
-
refresh();
|
|
78
|
-
}, 10);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}, [checkoutSession, livemode, setLivemode, refresh]);
|
|
82
|
-
|
|
83
|
-
if (error) {
|
|
84
|
-
return <PaymentError mode={mode} title="Oops" description={formatError(error)} />;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!checkoutSession || !delay) {
|
|
88
|
-
return (
|
|
89
|
-
<Root mode={mode}>
|
|
90
|
-
<Stack className="cko-container" sx={{ gap: { sm: mode === 'standalone' ? 0 : 8 } }}>
|
|
91
|
-
<Stack className="cko-overview">
|
|
92
|
-
<OverviewSkeleton />
|
|
93
|
-
</Stack>
|
|
94
|
-
<Stack className="cko-payment">
|
|
95
|
-
<PaymentSkeleton />
|
|
96
|
-
</Stack>
|
|
97
|
-
{mode === 'standalone' && <CheckoutFooter className="cko-footer" />}
|
|
98
|
-
</Stack>
|
|
99
|
-
</Root>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// expired session
|
|
104
|
-
if (checkoutSession.expires_at <= Math.round(Date.now() / 1000)) {
|
|
105
|
-
return (
|
|
106
|
-
<PaymentError
|
|
107
|
-
mode={mode}
|
|
108
|
-
title={t('payment.checkout.expired.title')}
|
|
109
|
-
description={t('payment.checkout.expired.description')}
|
|
110
|
-
/>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// completed session
|
|
115
|
-
if (checkoutSession.status === 'complete') {
|
|
116
|
-
return (
|
|
117
|
-
<PaymentError
|
|
118
|
-
mode={mode}
|
|
119
|
-
title={t('payment.checkout.complete.title')}
|
|
120
|
-
description={t('payment.checkout.complete.description')}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (!checkoutSession.line_items.length) {
|
|
126
|
-
return (
|
|
127
|
-
<PaymentError
|
|
128
|
-
mode={mode}
|
|
129
|
-
title={t('payment.checkout.emptyItems.title')}
|
|
130
|
-
description={t('payment.checkout.emptyItems.description')}
|
|
131
|
-
/>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<PaymentInner
|
|
137
|
-
checkoutSession={checkoutSession}
|
|
138
|
-
paymentMethods={paymentMethods as TPaymentMethodExpanded[]}
|
|
139
|
-
paymentLink={paymentLink}
|
|
140
|
-
paymentIntent={paymentIntent}
|
|
141
|
-
completed={completed}
|
|
142
|
-
customer={customer as TCustomer}
|
|
143
|
-
onPaid={onPaid}
|
|
144
|
-
onError={onError}
|
|
145
|
-
onChange={onChange}
|
|
146
|
-
goBack={goBack}
|
|
147
|
-
mode={mode}
|
|
148
|
-
action={action}
|
|
149
|
-
/>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
type MainProps = CheckoutContext & CheckoutCallbacks & { completed?: boolean };
|
|
154
|
-
|
|
155
39
|
PaymentInner.defaultProps = {
|
|
156
40
|
completed: false,
|
|
157
41
|
};
|
|
158
42
|
|
|
159
|
-
|
|
43
|
+
function PaymentInner({
|
|
160
44
|
checkoutSession,
|
|
161
45
|
paymentMethods,
|
|
162
46
|
paymentLink,
|
|
@@ -167,11 +51,11 @@ export function PaymentInner({
|
|
|
167
51
|
onPaid,
|
|
168
52
|
onError,
|
|
169
53
|
onChange,
|
|
170
|
-
goBack,
|
|
171
54
|
action,
|
|
172
55
|
}: MainProps) {
|
|
173
|
-
const { t
|
|
56
|
+
const { t } = useLocaleContext();
|
|
174
57
|
const { settings, session } = usePaymentContext();
|
|
58
|
+
const { isMobile } = useMobile();
|
|
175
59
|
const [state, setState] = useSetState<{ checkoutSession: TCheckoutSessionExpanded }>({ checkoutSession });
|
|
176
60
|
|
|
177
61
|
const defaultCurrencyId = state.checkoutSession.currency_id || state.checkoutSession.line_items[0]?.price.currency_id;
|
|
@@ -251,19 +135,7 @@ export function PaymentInner({
|
|
|
251
135
|
}
|
|
252
136
|
};
|
|
253
137
|
|
|
254
|
-
const min = parseFloat(paymentLink?.donation_settings?.amount.minimum || '0');
|
|
255
|
-
const max = paymentLink?.donation_settings?.amount.maximum
|
|
256
|
-
? parseFloat(paymentLink?.donation_settings?.amount.maximum)
|
|
257
|
-
: Infinity;
|
|
258
|
-
|
|
259
138
|
const onChangeAmount = async ({ priceId, amount }: { priceId: string; amount: string }) => {
|
|
260
|
-
if (Number(amount) < min || Number(amount) > max) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (amount && formatAmountPrecisionLimit(String(amount), locale)) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
139
|
try {
|
|
268
140
|
const { data } = await api.put(`/api/checkout-sessions/${state.checkoutSession.id}/amount`, {
|
|
269
141
|
priceId,
|
|
@@ -280,10 +152,192 @@ export function PaymentInner({
|
|
|
280
152
|
setState({ checkoutSession: result.checkoutSession });
|
|
281
153
|
onPaid(result);
|
|
282
154
|
};
|
|
283
|
-
|
|
284
155
|
return (
|
|
285
156
|
<FormProvider {...methods}>
|
|
286
|
-
<
|
|
157
|
+
<Stack className="cko-container" sx={{ gap: { sm: mode === 'standalone' ? 0 : mode === 'inline' ? 4 : 8 } }}>
|
|
158
|
+
<Fade in>
|
|
159
|
+
<Stack className="cko-overview base-card" direction="column">
|
|
160
|
+
<PaymentSummary
|
|
161
|
+
items={state.checkoutSession.line_items}
|
|
162
|
+
trialInDays={state.checkoutSession.subscription_data?.trial_period_days || 0}
|
|
163
|
+
billingThreshold={Math.max(
|
|
164
|
+
state.checkoutSession.subscription_data?.billing_threshold_amount || 0,
|
|
165
|
+
// @ts-ignore
|
|
166
|
+
state.checkoutSession.subscription_data?.min_stake_amount || 0
|
|
167
|
+
)}
|
|
168
|
+
showStaking={method.type === 'arcblock'}
|
|
169
|
+
currency={currency}
|
|
170
|
+
onUpsell={onUpsell}
|
|
171
|
+
onDownsell={onDownsell}
|
|
172
|
+
onApplyCrossSell={onApplyCrossSell}
|
|
173
|
+
onCancelCrossSell={onCancelCrossSell}
|
|
174
|
+
onChangeAmount={onChangeAmount}
|
|
175
|
+
checkoutSessionId={state.checkoutSession.id}
|
|
176
|
+
crossSellBehavior={state.checkoutSession.cross_sell_behavior}
|
|
177
|
+
donationSettings={paymentLink?.donation_settings}
|
|
178
|
+
action={action}
|
|
179
|
+
/>
|
|
180
|
+
{mode === 'standalone' && !isMobile && (
|
|
181
|
+
<CheckoutFooter className="cko-footer" sx={{ color: 'var(--foregrounds-fg-muted, #98A3B1)' }} />
|
|
182
|
+
)}
|
|
183
|
+
</Stack>
|
|
184
|
+
</Fade>
|
|
185
|
+
<Stack className="cko-payment base-card" direction="column" spacing={{ xs: 2, sm: 3 }}>
|
|
186
|
+
{completed && (
|
|
187
|
+
<PaymentSuccess
|
|
188
|
+
mode={mode}
|
|
189
|
+
payee={getStatementDescriptor(state.checkoutSession.line_items)}
|
|
190
|
+
action={state.checkoutSession.mode}
|
|
191
|
+
invoiceId={state.checkoutSession.invoice_id}
|
|
192
|
+
subscriptionId={state.checkoutSession.subscription_id}
|
|
193
|
+
message={
|
|
194
|
+
paymentLink?.after_completion?.hosted_confirmation?.custom_message ||
|
|
195
|
+
t(
|
|
196
|
+
`payment.checkout.completed.${
|
|
197
|
+
state.checkoutSession.submit_type === 'donate' ? 'donate' : state.checkoutSession.mode
|
|
198
|
+
}`
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
/>
|
|
202
|
+
)}
|
|
203
|
+
{!completed && (
|
|
204
|
+
<PaymentForm
|
|
205
|
+
checkoutSession={state.checkoutSession}
|
|
206
|
+
paymentMethods={paymentMethods as TPaymentMethodExpanded[]}
|
|
207
|
+
paymentIntent={paymentIntent}
|
|
208
|
+
paymentLink={paymentLink}
|
|
209
|
+
customer={customer}
|
|
210
|
+
onPaid={handlePaid}
|
|
211
|
+
onError={onError}
|
|
212
|
+
mode={mode}
|
|
213
|
+
action={action}
|
|
214
|
+
/>
|
|
215
|
+
)}
|
|
216
|
+
</Stack>
|
|
217
|
+
{mode === 'standalone' && isMobile && (
|
|
218
|
+
<CheckoutFooter className="cko-footer" sx={{ color: 'var(--foregrounds-fg-muted, #98A3B1)' }} />
|
|
219
|
+
)}
|
|
220
|
+
</Stack>
|
|
221
|
+
</FormProvider>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Payment.defaultProps = {
|
|
226
|
+
completed: false,
|
|
227
|
+
error: null,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export default function Payment({
|
|
231
|
+
checkoutSession,
|
|
232
|
+
paymentMethods,
|
|
233
|
+
paymentIntent,
|
|
234
|
+
paymentLink,
|
|
235
|
+
customer,
|
|
236
|
+
completed,
|
|
237
|
+
// error,
|
|
238
|
+
mode,
|
|
239
|
+
onPaid,
|
|
240
|
+
onError,
|
|
241
|
+
onChange,
|
|
242
|
+
goBack,
|
|
243
|
+
action,
|
|
244
|
+
}: Props) {
|
|
245
|
+
const { t } = useLocaleContext();
|
|
246
|
+
const { refresh, livemode, setLivemode } = usePaymentContext();
|
|
247
|
+
const [delay, setDelay] = useState(false);
|
|
248
|
+
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
setTimeout(() => {
|
|
251
|
+
// 骨架屏 delay
|
|
252
|
+
setDelay(true);
|
|
253
|
+
}, 500);
|
|
254
|
+
}, []);
|
|
255
|
+
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (checkoutSession) {
|
|
258
|
+
if (livemode !== checkoutSession.livemode) {
|
|
259
|
+
setLivemode(checkoutSession.livemode);
|
|
260
|
+
setTimeout(() => {
|
|
261
|
+
refresh();
|
|
262
|
+
}, 10);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}, [checkoutSession, livemode, setLivemode, refresh]);
|
|
266
|
+
|
|
267
|
+
const renderContent = () => {
|
|
268
|
+
if (!checkoutSession || !delay) {
|
|
269
|
+
return (
|
|
270
|
+
<Stack className="cko-container" sx={{ gap: { sm: mode === 'standalone' ? 0 : mode === 'inline' ? 4 : 8 } }}>
|
|
271
|
+
<Stack className="cko-overview base-card">
|
|
272
|
+
<Box className="cko-product">
|
|
273
|
+
<OverviewSkeleton />
|
|
274
|
+
</Box>
|
|
275
|
+
{/* {mode === 'standalone' && !isMobile && (
|
|
276
|
+
<CheckoutFooter className="cko-footer" sx={{ color: 'var(--foregrounds-fg-muted, #98A3B1)' }} />
|
|
277
|
+
)} */}
|
|
278
|
+
</Stack>
|
|
279
|
+
<Stack className="cko-payment base-card">
|
|
280
|
+
<PaymentSkeleton />
|
|
281
|
+
</Stack>
|
|
282
|
+
{/* {mode === 'standalone' && isMobile && (
|
|
283
|
+
<CheckoutFooter className="cko-footer" sx={{ color: 'var(--foregrounds-fg-muted, #98A3B1)' }} />
|
|
284
|
+
)} */}
|
|
285
|
+
</Stack>
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
if (checkoutSession.expires_at <= Math.round(Date.now() / 1000)) {
|
|
289
|
+
return (
|
|
290
|
+
<PaymentError
|
|
291
|
+
mode={mode}
|
|
292
|
+
title={t('payment.checkout.expired.title')}
|
|
293
|
+
description={t('payment.checkout.expired.description')}
|
|
294
|
+
/>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
if (!checkoutSession.line_items.length) {
|
|
298
|
+
return (
|
|
299
|
+
<PaymentError
|
|
300
|
+
mode={mode}
|
|
301
|
+
title={t('payment.checkout.emptyItems.title')}
|
|
302
|
+
description={t('payment.checkout.emptyItems.description')}
|
|
303
|
+
/>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
return (
|
|
307
|
+
<PaymentInner
|
|
308
|
+
checkoutSession={checkoutSession}
|
|
309
|
+
paymentMethods={paymentMethods as TPaymentMethodExpanded[]}
|
|
310
|
+
paymentLink={paymentLink}
|
|
311
|
+
paymentIntent={paymentIntent}
|
|
312
|
+
completed={completed || checkoutSession.status === 'complete'}
|
|
313
|
+
customer={customer as TCustomer}
|
|
314
|
+
onPaid={onPaid}
|
|
315
|
+
onError={onError}
|
|
316
|
+
onChange={onChange}
|
|
317
|
+
goBack={goBack}
|
|
318
|
+
mode={mode}
|
|
319
|
+
action={action}
|
|
320
|
+
/>
|
|
321
|
+
);
|
|
322
|
+
};
|
|
323
|
+
return (
|
|
324
|
+
<Stack
|
|
325
|
+
display="flex"
|
|
326
|
+
flexDirection="column"
|
|
327
|
+
sx={{ height: mode === 'standalone' ? '100vh' : 'auto', overflow: 'hidden' }}>
|
|
328
|
+
{mode === 'standalone' ? (
|
|
329
|
+
<Header
|
|
330
|
+
meta={undefined}
|
|
331
|
+
addons={undefined}
|
|
332
|
+
sessionManagerProps={undefined}
|
|
333
|
+
homeLink={undefined}
|
|
334
|
+
theme={undefined}
|
|
335
|
+
hideNavMenu={undefined}
|
|
336
|
+
maxWidth={false}
|
|
337
|
+
sx={{ borderBottom: '1px solid var(--stroke-border-base, #EFF1F5)' }}
|
|
338
|
+
/>
|
|
339
|
+
) : null}
|
|
340
|
+
<Root mode={mode} sx={{ flex: 1 }}>
|
|
287
341
|
{goBack && (
|
|
288
342
|
<ArrowBackOutlined
|
|
289
343
|
sx={{ mr: 0.5, color: 'text.secondary', alignSelf: 'flex-start', margin: '16px 0', cursor: 'pointer' }}
|
|
@@ -292,110 +346,48 @@ export function PaymentInner({
|
|
|
292
346
|
/>
|
|
293
347
|
)}
|
|
294
348
|
<Stack className="cko-container" sx={{ gap: { sm: mode === 'standalone' ? 0 : mode === 'inline' ? 4 : 8 } }}>
|
|
295
|
-
|
|
296
|
-
<Stack className="cko-overview" direction="column">
|
|
297
|
-
{mode === 'standalone' ? <PaymentHeader checkoutSession={state.checkoutSession} /> : null}
|
|
298
|
-
<PaymentSummary
|
|
299
|
-
items={state.checkoutSession.line_items}
|
|
300
|
-
trialInDays={state.checkoutSession.subscription_data?.trial_period_days || 0}
|
|
301
|
-
billingThreshold={Math.max(
|
|
302
|
-
state.checkoutSession.subscription_data?.billing_threshold_amount || 0,
|
|
303
|
-
// @ts-ignore
|
|
304
|
-
state.checkoutSession.subscription_data?.min_stake_amount || 0
|
|
305
|
-
)}
|
|
306
|
-
showStaking={method.type === 'arcblock'}
|
|
307
|
-
currency={currency}
|
|
308
|
-
onUpsell={onUpsell}
|
|
309
|
-
onDownsell={onDownsell}
|
|
310
|
-
onApplyCrossSell={onApplyCrossSell}
|
|
311
|
-
onCancelCrossSell={onCancelCrossSell}
|
|
312
|
-
onChangeAmount={onChangeAmount}
|
|
313
|
-
checkoutSessionId={state.checkoutSession.id}
|
|
314
|
-
crossSellBehavior={state.checkoutSession.cross_sell_behavior}
|
|
315
|
-
donationSettings={paymentLink?.donation_settings}
|
|
316
|
-
action={action}
|
|
317
|
-
/>
|
|
318
|
-
</Stack>
|
|
319
|
-
</Fade>
|
|
320
|
-
<Stack className="cko-payment" direction="column" spacing={{ xs: 2, sm: 3 }}>
|
|
321
|
-
{completed && (
|
|
322
|
-
<PaymentSuccess
|
|
323
|
-
mode={mode}
|
|
324
|
-
payee={getStatementDescriptor(state.checkoutSession.line_items)}
|
|
325
|
-
action={state.checkoutSession.mode}
|
|
326
|
-
invoiceId={state.checkoutSession.invoice_id}
|
|
327
|
-
subscriptionId={state.checkoutSession.subscription_id}
|
|
328
|
-
message={
|
|
329
|
-
paymentLink?.after_completion?.hosted_confirmation?.custom_message ||
|
|
330
|
-
t(
|
|
331
|
-
`payment.checkout.completed.${
|
|
332
|
-
state.checkoutSession.submit_type === 'donate' ? 'donate' : state.checkoutSession.mode
|
|
333
|
-
}`
|
|
334
|
-
)
|
|
335
|
-
}
|
|
336
|
-
/>
|
|
337
|
-
)}
|
|
338
|
-
{!completed && (
|
|
339
|
-
<PaymentForm
|
|
340
|
-
checkoutSession={state.checkoutSession}
|
|
341
|
-
paymentMethods={paymentMethods as TPaymentMethodExpanded[]}
|
|
342
|
-
paymentIntent={paymentIntent}
|
|
343
|
-
paymentLink={paymentLink}
|
|
344
|
-
customer={customer}
|
|
345
|
-
onPaid={handlePaid}
|
|
346
|
-
onError={onError}
|
|
347
|
-
mode={mode}
|
|
348
|
-
action={action}
|
|
349
|
-
/>
|
|
350
|
-
)}
|
|
351
|
-
</Stack>
|
|
352
|
-
{mode === 'standalone' && <CheckoutFooter className="cko-footer" />}
|
|
349
|
+
{renderContent()}
|
|
353
350
|
</Stack>
|
|
354
351
|
</Root>
|
|
355
|
-
</
|
|
352
|
+
</Stack>
|
|
356
353
|
);
|
|
357
354
|
}
|
|
358
355
|
|
|
356
|
+
type MainProps = CheckoutContext & CheckoutCallbacks & { completed?: boolean };
|
|
357
|
+
|
|
359
358
|
export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | 'popup', string> }>`
|
|
360
359
|
box-sizing: border-box;
|
|
361
360
|
display: flex;
|
|
362
361
|
flex-direction: column;
|
|
363
|
-
justify-content: center;
|
|
362
|
+
// justify-content: center;
|
|
364
363
|
align-items: center;
|
|
365
|
-
|
|
364
|
+
overflow: hidden;
|
|
365
|
+
// min-height: ${(props) => (props.mode === 'standalone' ? '100vh' : 'auto')};
|
|
366
366
|
position: relative;
|
|
367
|
-
|
|
368
|
-
${(props) =>
|
|
369
|
-
props.mode === 'standalone'
|
|
370
|
-
? `&:before {
|
|
371
|
-
animation-fill-mode: both;
|
|
372
|
-
background: #ffffff;
|
|
373
|
-
content: '';
|
|
374
|
-
height: 100%;
|
|
375
|
-
position: fixed;
|
|
376
|
-
right: 0;
|
|
377
|
-
top: 0;
|
|
378
|
-
transform-origin: right;
|
|
379
|
-
width: 50%;
|
|
380
|
-
box-shadow: 15px 0 30px 0 rgba(0, 0, 0, 0.18);
|
|
381
|
-
}`
|
|
382
|
-
: ''}
|
|
383
|
-
|
|
384
367
|
.cko-container {
|
|
368
|
+
overflow: hidden;
|
|
385
369
|
width: 100%;
|
|
386
|
-
max-width: ${(props) => (props.mode.endsWith('-minimal') ? '400px' : '1000px')};
|
|
370
|
+
// max-width: ${(props) => (props.mode.endsWith('-minimal') ? '400px' : '1000px')};
|
|
387
371
|
display: flex;
|
|
388
372
|
flex-direction: row;
|
|
389
|
-
justify-content:
|
|
373
|
+
justify-content: center;
|
|
374
|
+
// gap: 4px;
|
|
390
375
|
position: relative;
|
|
391
|
-
|
|
376
|
+
flex: 1;
|
|
377
|
+
padding: 1px;
|
|
378
|
+
// padding: ${(props) => (props.mode === 'standalone' ? '0 16px' : '0')};
|
|
392
379
|
}
|
|
393
380
|
|
|
394
381
|
.cko-overview {
|
|
395
|
-
width: ${(props) => (props.mode.endsWith('-minimal') ? '100%' : '400px')};
|
|
396
|
-
min-height: ${(props) => (props.mode === 'standalone' ? '540px' : 'auto')};
|
|
382
|
+
// width: ${(props) => (props.mode.endsWith('-minimal') ? '100%' : '400px')};
|
|
383
|
+
// min-height: ${(props) => (props.mode === 'standalone' ? '540px' : 'auto')};
|
|
397
384
|
position: relative;
|
|
398
385
|
display: ${(props) => (props.mode.endsWith('-minimal') ? 'none' : 'block')};
|
|
386
|
+
background: var(--backgrounds-bg-base);
|
|
387
|
+
min-height: 'auto';
|
|
388
|
+
// width: 502px;
|
|
389
|
+
display: flex;
|
|
390
|
+
flex-direction: column;
|
|
399
391
|
}
|
|
400
392
|
.cko-header {
|
|
401
393
|
left: 0;
|
|
@@ -408,7 +400,8 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
|
|
|
408
400
|
box-shadow 0.15s ease-out;
|
|
409
401
|
}
|
|
410
402
|
.cko-product {
|
|
411
|
-
|
|
403
|
+
flex: 1;
|
|
404
|
+
overflow: hidden;
|
|
412
405
|
}
|
|
413
406
|
.cko-product-summary {
|
|
414
407
|
width: 100%;
|
|
@@ -420,30 +413,60 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
|
|
|
420
413
|
text-overflow: ellipsis;
|
|
421
414
|
}
|
|
422
415
|
|
|
416
|
+
.base-card {
|
|
417
|
+
border: none;
|
|
418
|
+
border-radius: 0;
|
|
419
|
+
padding: ${(props) => (props.mode === 'standalone' ? '100px 40px 20px' : '20px 0')};
|
|
420
|
+
box-shadow: none;
|
|
421
|
+
flex: 1;
|
|
422
|
+
max-width: 582px;
|
|
423
|
+
}
|
|
424
|
+
|
|
423
425
|
.cko-payment {
|
|
424
|
-
width:
|
|
425
|
-
.
|
|
426
|
-
|
|
426
|
+
width: 502px;
|
|
427
|
+
// width: ${(props) => (props.mode.endsWith('-minimal') ? '100%' : '400px')};
|
|
428
|
+
// box-shadow: -4px 0px 8px 0px rgba(2, 7, 19, 0.04);
|
|
429
|
+
padding-left: ${(props) => (props.mode === 'standalone' ? '40px' : '20px')};
|
|
430
|
+
position: relative;
|
|
431
|
+
&:before {
|
|
432
|
+
-webkit-animation-fill-mode: both;
|
|
433
|
+
content: '';
|
|
434
|
+
height: 100%;
|
|
435
|
+
position: absolute;
|
|
436
|
+
left: 0px;
|
|
437
|
+
top: 0px;
|
|
438
|
+
transform-origin: left center;
|
|
439
|
+
width: 8px;
|
|
440
|
+
box-shadow: -4px 0px 8px 0px rgba(2, 7, 19, 0.04);
|
|
427
441
|
}
|
|
428
442
|
}
|
|
443
|
+
.cko-payment-contact {
|
|
444
|
+
overflow: hidden;
|
|
445
|
+
}
|
|
446
|
+
.cko-footer {
|
|
447
|
+
display: ${(props) => (props.mode.endsWith('-minimal') ? 'none' : 'block')};
|
|
448
|
+
text-align: center;
|
|
449
|
+
margin-top: 20px;
|
|
450
|
+
}
|
|
429
451
|
|
|
430
452
|
.cko-payment-form {
|
|
431
|
-
.MuiInputAdornment-positionStart {
|
|
432
|
-
|
|
453
|
+
// .MuiInputAdornment-positionStart {
|
|
454
|
+
// width: 50px;
|
|
455
|
+
// }
|
|
456
|
+
|
|
457
|
+
.MuiFormLabel-root {
|
|
458
|
+
color: var(--foregrounds-fg-base, #010714);
|
|
459
|
+
font-weight: 500;
|
|
460
|
+
margin-top: 12px;
|
|
461
|
+
margin-bottom: 4px;
|
|
433
462
|
}
|
|
434
|
-
|
|
435
463
|
.MuiBox-root {
|
|
436
|
-
border: 1px solid #ccc;
|
|
437
464
|
margin: -1px 0 0 -1px;
|
|
438
465
|
}
|
|
439
466
|
|
|
440
467
|
.MuiFormHelperText-root {
|
|
441
468
|
margin-left: 14px;
|
|
442
469
|
}
|
|
443
|
-
|
|
444
|
-
.MuiOutlinedInput-notchedOutline {
|
|
445
|
-
border: none;
|
|
446
|
-
}
|
|
447
470
|
}
|
|
448
471
|
|
|
449
472
|
.cko-payment-methods {
|
|
@@ -451,9 +474,9 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
|
|
|
451
474
|
|
|
452
475
|
.cko-payment-submit {
|
|
453
476
|
.MuiButtonBase-root {
|
|
454
|
-
border-radius: 0;
|
|
455
477
|
font-size: 1.3rem;
|
|
456
478
|
position: relative;
|
|
479
|
+
padding: 4px 22px;
|
|
457
480
|
}
|
|
458
481
|
|
|
459
482
|
.cko-submit-progress {
|
|
@@ -468,15 +491,28 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
|
|
|
468
491
|
.cko-header {
|
|
469
492
|
}
|
|
470
493
|
|
|
471
|
-
.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
494
|
+
.product-item {
|
|
495
|
+
border-radius: var(--radius-l, 12px);
|
|
496
|
+
border: 1px solid var(--stroke-border-base, #eff1f5);
|
|
497
|
+
.product-item-content {
|
|
498
|
+
padding: 16px;
|
|
499
|
+
background: var(--backgrounds-bg-subtle, #f9fafb);
|
|
500
|
+
border-top-left-radius: var(--radius-l, 12px);
|
|
501
|
+
border-top-right-radius: var(--radius-l, 12px);
|
|
502
|
+
}
|
|
503
|
+
.product-item-upsell {
|
|
504
|
+
margin-top: 0;
|
|
505
|
+
padding: 16px;
|
|
506
|
+
background: var(--backgrounds-bg-component, #f1f3f5);
|
|
507
|
+
border-bottom-left-radius: var(--radius-l, 12px);
|
|
508
|
+
border-bottom-right-radius: var(--radius-l, 12px);
|
|
509
|
+
}
|
|
477
510
|
}
|
|
478
511
|
|
|
479
512
|
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
513
|
+
background: ${(props) => (props.mode === 'standalone' ? 'var(--backgrounds-bg-subtle, #F9FAFB)' : 'transparent')};
|
|
514
|
+
padding-top: 0;
|
|
515
|
+
overflow: auto;
|
|
480
516
|
&:before {
|
|
481
517
|
display: none;
|
|
482
518
|
}
|
|
@@ -486,18 +522,34 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
|
|
|
486
522
|
gap: 32px;
|
|
487
523
|
min-width: 350px;
|
|
488
524
|
max-width: 400px;
|
|
525
|
+
overflow: visible;
|
|
489
526
|
}
|
|
490
527
|
.cko-overview {
|
|
491
528
|
width: 100%;
|
|
492
529
|
min-height: auto;
|
|
530
|
+
flex: none;
|
|
493
531
|
}
|
|
494
532
|
.cko-payment {
|
|
495
533
|
width: 100%;
|
|
534
|
+
height: fit-content;
|
|
535
|
+
flex: none;
|
|
536
|
+
&:before {
|
|
537
|
+
display: none;
|
|
538
|
+
}
|
|
496
539
|
}
|
|
497
540
|
|
|
498
541
|
.cko-footer {
|
|
499
|
-
position:
|
|
542
|
+
position: relative;
|
|
543
|
+
margin-bottom: 4px;
|
|
500
544
|
margin-top: 0;
|
|
545
|
+
bottom: 0;
|
|
546
|
+
left: 0;
|
|
547
|
+
transform: translateX(0);
|
|
548
|
+
}
|
|
549
|
+
.base-card {
|
|
550
|
+
box-shadow: none;
|
|
551
|
+
border-radius: 0;
|
|
552
|
+
padding: 20px;
|
|
501
553
|
}
|
|
502
554
|
}
|
|
503
555
|
`;
|