@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.
@@ -34,10 +34,11 @@ import PaymentSummary from './summary';
34
34
  import { useMobile } from '../hooks/mobile';
35
35
 
36
36
  // eslint-disable-next-line react/no-unused-prop-types
37
- type Props = CheckoutContext & CheckoutCallbacks & { completed?: boolean; error?: any };
37
+ type Props = CheckoutContext & CheckoutCallbacks & { completed?: boolean; error?: any; showCheckoutSummary?: boolean };
38
38
 
39
39
  PaymentInner.defaultProps = {
40
40
  completed: false,
41
+ showCheckoutSummary: true,
41
42
  };
42
43
 
43
44
  function PaymentInner({
@@ -52,6 +53,7 @@ function PaymentInner({
52
53
  onError,
53
54
  onChange,
54
55
  action,
56
+ showCheckoutSummary = true,
55
57
  }: MainProps) {
56
58
  const { t } = useLocaleContext();
57
59
  const { settings, session } = usePaymentContext();
@@ -60,6 +62,7 @@ function PaymentInner({
60
62
 
61
63
  const defaultCurrencyId = state.checkoutSession.currency_id || state.checkoutSession.line_items[0]?.price.currency_id;
62
64
  const defaultMethodId = paymentMethods.find((m) => m.payment_currencies.some((c) => c.id === defaultCurrencyId))?.id;
65
+ const hideSummaryCard = mode.endsWith('-minimal') || !showCheckoutSummary;
63
66
 
64
67
  const methods = useForm<CheckoutFormData>({
65
68
  defaultValues: {
@@ -155,34 +158,42 @@ function PaymentInner({
155
158
  return (
156
159
  <FormProvider {...methods}>
157
160
  <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
161
+ {!hideSummaryCard && (
162
+ <Fade in>
163
+ <Stack className="base-card cko-overview" direction="column">
164
+ <PaymentSummary
165
+ items={state.checkoutSession.line_items}
166
+ trialInDays={state.checkoutSession.subscription_data?.trial_period_days || 0}
167
+ billingThreshold={Math.max(
168
+ state.checkoutSession.subscription_data?.billing_threshold_amount || 0,
169
+ // @ts-ignore
170
+ state.checkoutSession.subscription_data?.min_stake_amount || 0
171
+ )}
172
+ showStaking={method.type === 'arcblock'}
173
+ currency={currency}
174
+ onUpsell={onUpsell}
175
+ onDownsell={onDownsell}
176
+ onApplyCrossSell={onApplyCrossSell}
177
+ onCancelCrossSell={onCancelCrossSell}
178
+ onChangeAmount={onChangeAmount}
179
+ checkoutSessionId={state.checkoutSession.id}
180
+ crossSellBehavior={state.checkoutSession.cross_sell_behavior}
181
+ donationSettings={paymentLink?.donation_settings}
182
+ action={action}
183
+ />
184
+ {mode === 'standalone' && !isMobile && (
185
+ <CheckoutFooter className="cko-footer" sx={{ color: 'var(--foregrounds-fg-muted, #98A3B1)' }} />
167
186
  )}
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 }}>
187
+ </Stack>
188
+ </Fade>
189
+ )}
190
+ <Stack
191
+ className="base-card cko-payment"
192
+ direction="column"
193
+ spacing={{
194
+ xs: 2,
195
+ sm: 3,
196
+ }}>
186
197
  {completed && (
187
198
  <PaymentSuccess
188
199
  mode={mode}
@@ -225,6 +236,7 @@ function PaymentInner({
225
236
  Payment.defaultProps = {
226
237
  completed: false,
227
238
  error: null,
239
+ showCheckoutSummary: true,
228
240
  };
229
241
 
230
242
  export default function Payment({
@@ -241,10 +253,12 @@ export default function Payment({
241
253
  onChange,
242
254
  goBack,
243
255
  action,
256
+ showCheckoutSummary = true,
244
257
  }: Props) {
245
258
  const { t } = useLocaleContext();
246
259
  const { refresh, livemode, setLivemode } = usePaymentContext();
247
260
  const [delay, setDelay] = useState(false);
261
+ const hideSummaryCard = mode.endsWith('-minimal') || !showCheckoutSummary;
248
262
 
249
263
  useEffect(() => {
250
264
  setTimeout(() => {
@@ -268,15 +282,17 @@ export default function Payment({
268
282
  if (!checkoutSession || !delay) {
269
283
  return (
270
284
  <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 && (
285
+ {!hideSummaryCard && (
286
+ <Stack className="base-card cko-overview">
287
+ <Box className="cko-product">
288
+ <OverviewSkeleton />
289
+ </Box>
290
+ {/* {mode === 'standalone' && !isMobile && (
276
291
  <CheckoutFooter className="cko-footer" sx={{ color: 'var(--foregrounds-fg-muted, #98A3B1)' }} />
277
292
  )} */}
278
- </Stack>
279
- <Stack className="cko-payment base-card">
293
+ </Stack>
294
+ )}
295
+ <Stack className="base-card cko-payment">
280
296
  <PaymentSkeleton />
281
297
  </Stack>
282
298
  {/* {mode === 'standalone' && isMobile && (
@@ -317,6 +333,7 @@ export default function Payment({
317
333
  goBack={goBack}
318
334
  mode={mode}
319
335
  action={action}
336
+ showCheckoutSummary={showCheckoutSummary}
320
337
  />
321
338
  );
322
339
  };
@@ -353,7 +370,7 @@ export default function Payment({
353
370
  );
354
371
  }
355
372
 
356
- type MainProps = CheckoutContext & CheckoutCallbacks & { completed?: boolean };
373
+ type MainProps = CheckoutContext & CheckoutCallbacks & { completed?: boolean; showCheckoutSummary?: boolean };
357
374
 
358
375
  export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | 'popup', string> }>`
359
376
  box-sizing: border-box;
@@ -378,16 +395,24 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
378
395
  // padding: ${(props) => (props.mode === 'standalone' ? '0 16px' : '0')};
379
396
  }
380
397
 
398
+ .base-card {
399
+ border: none;
400
+ border-radius: 0;
401
+ padding: ${(props) => (props.mode === 'standalone' ? '100px 40px 20px' : '20px 0')};
402
+ box-shadow: none;
403
+ flex: 1;
404
+ max-width: 582px;
405
+ }
406
+
381
407
  .cko-overview {
382
408
  // width: ${(props) => (props.mode.endsWith('-minimal') ? '100%' : '400px')};
383
409
  // min-height: ${(props) => (props.mode === 'standalone' ? '540px' : 'auto')};
384
410
  position: relative;
385
- display: ${(props) => (props.mode.endsWith('-minimal') ? 'none' : 'block')};
411
+ flex-direction: column;
412
+ display: ${(props) => (props.mode.endsWith('-minimal') ? 'none' : 'flex')};
386
413
  background: var(--backgrounds-bg-base);
387
414
  min-height: 'auto';
388
415
  // width: 502px;
389
- display: flex;
390
- flex-direction: column;
391
416
  }
392
417
  .cko-header {
393
418
  left: 0;
@@ -413,15 +438,6 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
413
438
  text-overflow: ellipsis;
414
439
  }
415
440
 
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
-
425
441
  .cko-payment {
426
442
  width: 502px;
427
443
  // width: ${(props) => (props.mode.endsWith('-minimal') ? '100%' : '400px')};
@@ -461,7 +477,7 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
461
477
  margin-bottom: 4px;
462
478
  }
463
479
  .MuiBox-root {
464
- margin: -1px 0 0 -1px;
480
+ margin: 0;
465
481
  }
466
482
 
467
483
  .MuiFormHelperText-root {
@@ -520,9 +536,8 @@ export const Root = styled(Box)<{ mode: LiteralUnion<'standalone' | 'inline' | '
520
536
  flex-direction: column;
521
537
  align-items: center;
522
538
  gap: 32px;
523
- min-width: 350px;
524
- max-width: 400px;
525
539
  overflow: visible;
540
+ min-width: 200px;
526
541
  }
527
542
  .cko-overview {
528
543
  width: 100%;
@@ -71,7 +71,8 @@ export default function ProductDonation({
71
71
  if (event.target.checked) {
72
72
  setState({ custom: true, input: state.selected, error: '' });
73
73
  } else {
74
- setState({ custom: false, input: '', error: '' });
74
+ setPayable(true);
75
+ handleSelect(preset);
75
76
  }
76
77
  };
77
78