@asteby/storefront-react 0.8.0 → 0.10.0
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 +60 -1
- package/dist/cart.js +2 -1
- package/dist/cart.js.map +1 -1
- package/dist/checkout.cjs +440 -0
- package/dist/checkout.cjs.map +1 -0
- package/dist/checkout.css +100 -0
- package/dist/checkout.d.cts +197 -0
- package/dist/checkout.d.ts +197 -0
- package/dist/checkout.js +243 -0
- package/dist/checkout.js.map +1 -0
- package/dist/choices-DEPE9KRq.d.cts +130 -0
- package/dist/choices-DEPE9KRq.d.ts +130 -0
- package/dist/chunk-DSZVJ2PW.js +180 -0
- package/dist/chunk-DSZVJ2PW.js.map +1 -0
- package/dist/chunk-ISEOCKIR.js +160 -0
- package/dist/chunk-ISEOCKIR.js.map +1 -0
- package/dist/chunk-T52H5HL3.js +11 -0
- package/dist/chunk-T52H5HL3.js.map +1 -0
- package/dist/{chunk-2WZIWIBW.js → chunk-ZBH7JYU4.js} +4 -10
- package/dist/chunk-ZBH7JYU4.js.map +1 -0
- package/dist/payments-server.cjs +369 -0
- package/dist/payments-server.cjs.map +1 -0
- package/dist/payments-server.d.cts +145 -0
- package/dist/payments-server.d.ts +145 -0
- package/dist/payments-server.js +191 -0
- package/dist/payments-server.js.map +1 -0
- package/dist/payments.cjs +639 -2
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.css +57 -0
- package/dist/payments.d.cts +137 -21
- package/dist/payments.d.ts +137 -21
- package/dist/payments.js +332 -37
- package/dist/payments.js.map +1 -1
- package/dist/promotions.js +2 -1
- package/dist/promotions.js.map +1 -1
- package/package.json +24 -2
- package/dist/chunk-2WZIWIBW.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Default sheet for <PaymentMethodSection> (`@asteby/storefront-react/payments.css`). Optional: it only does what the
|
|
3
|
+
* section cannot do without JavaScript (show the panel of the checked row) plus neutral spacing. Colors, borders and
|
|
4
|
+
* radius stay with the shop (pass `classNames`).
|
|
5
|
+
*/
|
|
6
|
+
[data-sf-pay-method] [data-sf-pay-choice]:not(:has(input[name='payment_choice']:checked)) [data-sf-pay-panel] {
|
|
7
|
+
display: none;
|
|
8
|
+
}
|
|
9
|
+
[data-sf-pay-method] [data-sf-pay-panel][hidden] {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
[data-sf-pay-method] [data-sf-pay-points] {
|
|
13
|
+
display: grid;
|
|
14
|
+
gap: 0.5rem;
|
|
15
|
+
}
|
|
16
|
+
@media (min-width: 40rem) {
|
|
17
|
+
[data-sf-pay-method] [data-sf-pay-points] {
|
|
18
|
+
grid-template-columns: 1fr 1fr;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
[data-sf-pay-method] [data-sf-pay-point] {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 0.75rem;
|
|
25
|
+
min-height: 44px;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
[data-sf-pay-method] [data-sf-pay-method-submit] {
|
|
29
|
+
min-height: 44px;
|
|
30
|
+
}
|
|
31
|
+
/* Brand marks (`brandMarks`): trailing marks of a row (card networks, first cash points) and the mark of each point. */
|
|
32
|
+
[data-sf-pay-method] [data-sf-pay-brands] {
|
|
33
|
+
display: inline-flex;
|
|
34
|
+
flex: none;
|
|
35
|
+
flex-wrap: wrap;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
gap: 0.25rem;
|
|
38
|
+
margin-inline-start: auto;
|
|
39
|
+
}
|
|
40
|
+
[data-sf-pay-method] [data-sf-pay-glyph] {
|
|
41
|
+
display: block;
|
|
42
|
+
opacity: 0.8;
|
|
43
|
+
}
|
|
44
|
+
[data-sf-pay-method] [data-sf-brand-mark] {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
vertical-align: middle;
|
|
47
|
+
}
|
|
48
|
+
/* The open cash row already lists every point with its mark: the preview would repeat them. */
|
|
49
|
+
[data-sf-pay-method] [data-sf-pay-choice]:has(input[name='payment_choice']:checked) [data-sf-pay-brands='cash'] {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
@media (max-width: 24rem) {
|
|
53
|
+
/* Narrow phones: the row text wins over the preview marks. */
|
|
54
|
+
[data-sf-pay-method] [data-sf-pay-choice] [data-sf-pay-brands] [data-sf-brand-mark]:nth-child(n + 3) {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/payments.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import { Money, PaymentAttemptResult, PaymentClient, PaymentOutcomeKind, PaymentOutcome, PaymentErrorView, PaymentMessages, PaymentErrorKind } from '@asteby/storefront';
|
|
2
|
+
import { ReactNode, CSSProperties, RefObject } from 'react';
|
|
3
|
+
import { Money, PaymentAttemptResult, PaymentClient, PaymentOutcomeKind, PaymentOutcome, PaymentErrorView, PaymentMessages, PaymentErrorKind, PaymentOptionKey } from '@asteby/storefront';
|
|
4
|
+
import { a as PayChoices } from './choices-DEPE9KRq.cjs';
|
|
5
|
+
export { B as BuildPayChoicesOptions, P as PayChoice, b as PayErrorBody, c as PaymentCspMode, d as PaymentCspOptions, V as VoucherRowLabels, e as buildPayChoices, f as cashProviderData, g as checkoutToAttempt, h as choiceValue, p as parseChoice, i as payErrorResponse, j as paymentCsp, k as paymentCspHeaderName, l as paymentCspHeaders, m as paymentCspMode, n as paymentNonce, o as paymentNonceFromHeaders, v as voucherRows } from './choices-DEPE9KRq.cjs';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Replaceable ports of the embedded payment. The shop (or another provider)
|
|
@@ -317,30 +319,144 @@ declare function loadPaymentSdk(url: string, options: LoadScriptOptions): Promis
|
|
|
317
319
|
/** Test helper: forgets the loaded-script cache. */
|
|
318
320
|
declare function resetPaymentSdkCache(): void;
|
|
319
321
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
+
/** Texts of the "Payment method" section. Override any of them with the `messages` prop. */
|
|
323
|
+
type PaymentMethodMessages = {
|
|
324
|
+
legend: string;
|
|
325
|
+
/** Button label before the total: "Pagar $1,200.00". */
|
|
326
|
+
pay: string;
|
|
327
|
+
/** Button label for card and cash, before the total. */
|
|
328
|
+
placeOrder: string;
|
|
329
|
+
/** Button label when the buyer leaves for the provider's page. */
|
|
330
|
+
payRedirect: string;
|
|
331
|
+
/** Button label for the first step (address) of a two-step checkout. */
|
|
332
|
+
continue: string;
|
|
333
|
+
/** Button label when the address must be saved again. */
|
|
334
|
+
retryAddress: string;
|
|
335
|
+
processing: string;
|
|
336
|
+
redirectNote: string;
|
|
337
|
+
cashPoints: string;
|
|
338
|
+
cashMore: string;
|
|
339
|
+
cashNote: string;
|
|
340
|
+
secureCard: string;
|
|
341
|
+
pickDeliveryFirst: string;
|
|
342
|
+
updatingTotal: string;
|
|
343
|
+
syncFailed: string;
|
|
344
|
+
/** The shipping quote expired or changed: fresh rates are loading. */
|
|
345
|
+
quoteChanged: string;
|
|
346
|
+
rebuildCart: string;
|
|
347
|
+
noPaymentTitle: string;
|
|
348
|
+
noPayment: string;
|
|
349
|
+
paymentNote: string;
|
|
350
|
+
/** Fallback names for the provider options when the server sends no `label`. */
|
|
351
|
+
options: Record<PaymentOptionKey, string>;
|
|
352
|
+
};
|
|
353
|
+
/** Messages for a locale (`es*` default, `en*`), with optional overrides. */
|
|
354
|
+
declare function paymentMethodMessages(locale?: string | null, overrides?: Partial<Omit<PaymentMethodMessages, 'options'>> & {
|
|
355
|
+
options?: Partial<PaymentMethodMessages['options']>;
|
|
356
|
+
} | null): PaymentMethodMessages;
|
|
357
|
+
|
|
358
|
+
/** Name of the radio group that carries the chosen row (`method` or `method|option`). */
|
|
359
|
+
declare const PAYMENT_CHOICE_FIELD = "payment_choice";
|
|
360
|
+
/** Name of the radio group that carries the chosen cash point. */
|
|
361
|
+
declare const CASH_POINT_FIELD = "cash_point";
|
|
362
|
+
/** Fields of the page form (contact, delivery, address, method) for the JSON POST of the embedded payment. */
|
|
363
|
+
declare function formFields(form: HTMLFormElement | null | undefined): Record<string, string>;
|
|
364
|
+
type PaymentMethodClassNames = Partial<Record<'root' | 'legend' | 'choice' | 'radioLabel' | 'radio' | 'labelText' | 'hint' | 'icon' | 'brands' | 'panel' | 'cashPoint' | 'cashPointInput' | 'cashMore' | 'note' | 'alert' | 'status' | 'brickWrap' | 'brick' | 'submit' | 'rebuild', string>>;
|
|
365
|
+
type PaymentMethodTestIds = Partial<Record<'method' | 'submit' | 'cash' | 'redirectNote' | 'card' | 'syncing' | 'syncFailed' | 'rebuild' | 'noPayment', string>>;
|
|
366
|
+
type PaymentMethodSectionProps = {
|
|
367
|
+
/** From `buildPayChoices(payment.methods)`. */
|
|
368
|
+
choices: PayChoices;
|
|
369
|
+
/** The server total (`cart.cost.total`). Shown on the button and passed to the card form. Never computed here. */
|
|
370
|
+
amount: Money;
|
|
371
|
+
/** Cart (or checkout) id: scopes the stored attempt id so a reload reuses it. */
|
|
372
|
+
scope?: string;
|
|
373
|
+
/** The page `<form>`: its fields travel with the card payment and it is validated before charging. */
|
|
374
|
+
formRef: RefObject<HTMLFormElement | null>;
|
|
375
|
+
/** POST endpoint that charges the card (`handlers.pay` on the server). */
|
|
376
|
+
payUrl: string;
|
|
377
|
+
/** POST endpoint that re-reads the payment (`handlers.status`). Enables the 3DS / review polling. */
|
|
378
|
+
statusUrl?: string;
|
|
379
|
+
/** Row preselected. Default: `choices.defaultValue`. */
|
|
380
|
+
defaultChoice?: string | null;
|
|
381
|
+
/** Value of the delivery group; the card form waits until it is `deliveryReady` and `syncDelivery` has settled. */
|
|
382
|
+
delivery?: string;
|
|
383
|
+
/** `false` while the buyer has not chosen a delivery that fixes the total (e.g. address pending). Default true. */
|
|
384
|
+
deliveryReady?: boolean;
|
|
385
|
+
/**
|
|
386
|
+
* Saves the chosen delivery on the server cart so the server total includes it. Resolve `true` once the new total
|
|
387
|
+
* has been read back (the `amount` prop is then up to date). Called once per delivery, whatever the payment row (so
|
|
388
|
+
* the total on the button and in the shop's summary always holds the chosen delivery). Without it nothing waits.
|
|
389
|
+
*
|
|
390
|
+
* Resolve `'requote'` when the server refused the rate because the quote expired or changed and the shop is loading
|
|
391
|
+
* fresh rates: the section then says so (`quoteChanged`, a status, not an error), keeps the card in the page and
|
|
392
|
+
* tries again with the next delivery value. `false` is a real failure (the card degrades to the redirect).
|
|
393
|
+
*/
|
|
394
|
+
syncDelivery?: (delivery: string) => Promise<boolean | 'requote'>;
|
|
395
|
+
/** A two-step checkout still collecting the address: the button reads "continue" and no card form shows. */
|
|
396
|
+
addressFirst?: boolean;
|
|
397
|
+
/** The address must be saved again before paying. */
|
|
398
|
+
retryAddress?: boolean;
|
|
399
|
+
/** Disables the button (the shop is not ready to take payment). */
|
|
400
|
+
blocked?: boolean;
|
|
401
|
+
/** The page form is submitting. */
|
|
402
|
+
busy?: boolean;
|
|
403
|
+
/** Names of fields with a server error (`payment_method`, `cash_point`). */
|
|
404
|
+
invalid?: ReadonlySet<string>;
|
|
322
405
|
nonce?: string;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
form?: string[];
|
|
406
|
+
locale?: string;
|
|
407
|
+
messages?: Parameters<typeof paymentMethodMessages>[1];
|
|
408
|
+
/** Name for a plain method (`PaymentMethod` without options). Default: the key as it comes. */
|
|
409
|
+
methodLabel?: (methodKey: string) => {
|
|
410
|
+
label: string;
|
|
411
|
+
hint?: string;
|
|
330
412
|
};
|
|
331
|
-
/**
|
|
332
|
-
|
|
413
|
+
/** Per-row icon by option (`card`, `cash`, `wallet`, `credits`) or `plain`. Replaces the default marks of that row. */
|
|
414
|
+
icons?: Partial<Record<PaymentOptionKey | 'plain', ReactNode>>;
|
|
415
|
+
/**
|
|
416
|
+
* Brand marks (`BrandMark`): the provider's mark on its account / no-card rows and on a plain method, the cash point
|
|
417
|
+
* marks on the cash row and next to each point, and `cardBrands` on the card row. Default true; `false` keeps the
|
|
418
|
+
* rows text-only.
|
|
419
|
+
*/
|
|
420
|
+
brandMarks?: boolean;
|
|
421
|
+
/** Card networks drawn on the card row (`visa`, `mastercard`, `amex`, `carnet`…), as the shop's provider accepts them. */
|
|
422
|
+
cardBrands?: readonly string[];
|
|
423
|
+
/** How to print the total on the button. Default `formatMoney`. */
|
|
424
|
+
renderAmount?: (amount: Money) => ReactNode;
|
|
425
|
+
/** Anchor to the cart for the "rebuild" action when the cart expired. Default: plain `<a href>`. */
|
|
426
|
+
rebuildHref?: string;
|
|
427
|
+
renderLink?: (props: {
|
|
428
|
+
href: string;
|
|
429
|
+
className?: string;
|
|
430
|
+
children: ReactNode;
|
|
431
|
+
testId?: string;
|
|
432
|
+
}) => ReactNode;
|
|
433
|
+
/** Called once the order is closed in the page (approved, under review or voucher). Navigate to the thank-you page. */
|
|
434
|
+
onDone: (outcome: PaymentOutcome) => void;
|
|
435
|
+
/** The server total changed under the buyer: re-read the cart (the card form remounts with the new amount). */
|
|
436
|
+
onAmountChanged?: () => void;
|
|
437
|
+
onEvent?: (event: PaymentEvent) => void;
|
|
438
|
+
classNames?: PaymentMethodClassNames;
|
|
439
|
+
testIds?: PaymentMethodTestIds;
|
|
440
|
+
/** Hide the section button (drive the form some other way). Card payments then need `PaymentMethodHandle`-less flows. */
|
|
441
|
+
hideSubmit?: boolean;
|
|
442
|
+
/** Replaces the transport built from `payUrl` / `statusUrl`. */
|
|
443
|
+
transport?: PaymentTransport;
|
|
444
|
+
/** Extra props for the card form (`adapter`, `adapters`, `messages`, `minHeight`, `storage`, timeouts...). */
|
|
445
|
+
brickProps?: Partial<Omit<PaymentBrickProps, 'client' | 'amount' | 'transport' | 'onResult' | 'onEvent' | 'onFallback'>>;
|
|
333
446
|
};
|
|
334
447
|
/**
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
448
|
+
* "Payment method", hybrid. Card: the provider's secure form INSIDE the page (`PaymentBrick`) with the shop's own
|
|
449
|
+
* button. Cash: payment points and a voucher on order. Provider account and no-card payments redirect. Without
|
|
450
|
+
* JavaScript, or if the card form does not load, everything falls back to the plain redirect flow (the page form's
|
|
451
|
+
* normal submit); the cash point radios and the notes work without JavaScript with the `payments.css` sheet.
|
|
452
|
+
*
|
|
453
|
+
* Money: the form amount is the server total passed in `amount` (already holding the chosen delivery); nothing is added
|
|
454
|
+
* or recalculated here.
|
|
338
455
|
*
|
|
339
|
-
*
|
|
456
|
+
* Accessibility: one labelled `fieldset` with native radios; notes in `role="status"`, problems in `role="alert"`; the
|
|
457
|
+
* button explains its busy state and is never silently disabled while the card form is loading.
|
|
340
458
|
*/
|
|
341
|
-
declare function
|
|
342
|
-
/** `Content-Security-Policy` or, during the rollout week, `Content-Security-Policy-Report-Only`. */
|
|
343
|
-
declare function paymentCspHeaderName(reportOnly: boolean): string;
|
|
459
|
+
declare function PaymentMethodSection(props: PaymentMethodSectionProps): react.JSX.Element;
|
|
344
460
|
|
|
345
461
|
/** CSS custom properties (set by the shop in its stylesheet) -> provider widget variables. */
|
|
346
462
|
declare const PAYMENT_THEME_TOKENS: {
|
|
@@ -361,4 +477,4 @@ declare const PAYMENT_THEME_TOKENS: {
|
|
|
361
477
|
*/
|
|
362
478
|
declare function readPaymentTheme(el: Element | null | undefined, tokens?: Record<string, string>): Record<string, string>;
|
|
363
479
|
|
|
364
|
-
export { type EmbeddedPaymentState, type EmbeddedPaymentStatus, type FetchTransportOptions, type LoadScriptOptions, MERCADOPAGO_BRICKS_KIND, type MercadoPagoAdapterOptions, type MercadoPagoCtor, type MountedPaymentForm, PAYMENT_THEME_TOKENS, PaymentBrick, type PaymentBrickHandle, type PaymentBrickProps, PaymentChallenge, type PaymentChallengeProps, type
|
|
480
|
+
export { CASH_POINT_FIELD, type EmbeddedPaymentState, type EmbeddedPaymentStatus, type FetchTransportOptions, type LoadScriptOptions, MERCADOPAGO_BRICKS_KIND, type MercadoPagoAdapterOptions, type MercadoPagoCtor, type MountedPaymentForm, PAYMENT_CHOICE_FIELD, PAYMENT_THEME_TOKENS, PayChoices, PaymentBrick, type PaymentBrickHandle, type PaymentBrickProps, PaymentChallenge, type PaymentChallengeProps, type PaymentEvent, type PaymentFallbackReason, type PaymentFormAdapter, type PaymentFormData, type PaymentFormError, type PaymentFormMountOptions, PaymentHttpError, type PaymentMethodClassNames, type PaymentMethodMessages, PaymentMethodSection, type PaymentMethodSectionProps, type PaymentMethodTestIds, type PaymentSubmitRequest, type PaymentTransport, type UseEmbeddedPaymentOptions, VoucherCard, type VoucherCardProps, createFetchTransport, formFields, loadPaymentSdk, mercadoPagoBricksAdapter, paymentMethodMessages, readPaymentTheme, resetPaymentSdkCache, sanitizeMercadoPagoFormData, useEmbeddedPayment };
|
package/dist/payments.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import { Money, PaymentAttemptResult, PaymentClient, PaymentOutcomeKind, PaymentOutcome, PaymentErrorView, PaymentMessages, PaymentErrorKind } from '@asteby/storefront';
|
|
2
|
+
import { ReactNode, CSSProperties, RefObject } from 'react';
|
|
3
|
+
import { Money, PaymentAttemptResult, PaymentClient, PaymentOutcomeKind, PaymentOutcome, PaymentErrorView, PaymentMessages, PaymentErrorKind, PaymentOptionKey } from '@asteby/storefront';
|
|
4
|
+
import { a as PayChoices } from './choices-DEPE9KRq.js';
|
|
5
|
+
export { B as BuildPayChoicesOptions, P as PayChoice, b as PayErrorBody, c as PaymentCspMode, d as PaymentCspOptions, V as VoucherRowLabels, e as buildPayChoices, f as cashProviderData, g as checkoutToAttempt, h as choiceValue, p as parseChoice, i as payErrorResponse, j as paymentCsp, k as paymentCspHeaderName, l as paymentCspHeaders, m as paymentCspMode, n as paymentNonce, o as paymentNonceFromHeaders, v as voucherRows } from './choices-DEPE9KRq.js';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Replaceable ports of the embedded payment. The shop (or another provider)
|
|
@@ -317,30 +319,144 @@ declare function loadPaymentSdk(url: string, options: LoadScriptOptions): Promis
|
|
|
317
319
|
/** Test helper: forgets the loaded-script cache. */
|
|
318
320
|
declare function resetPaymentSdkCache(): void;
|
|
319
321
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
+
/** Texts of the "Payment method" section. Override any of them with the `messages` prop. */
|
|
323
|
+
type PaymentMethodMessages = {
|
|
324
|
+
legend: string;
|
|
325
|
+
/** Button label before the total: "Pagar $1,200.00". */
|
|
326
|
+
pay: string;
|
|
327
|
+
/** Button label for card and cash, before the total. */
|
|
328
|
+
placeOrder: string;
|
|
329
|
+
/** Button label when the buyer leaves for the provider's page. */
|
|
330
|
+
payRedirect: string;
|
|
331
|
+
/** Button label for the first step (address) of a two-step checkout. */
|
|
332
|
+
continue: string;
|
|
333
|
+
/** Button label when the address must be saved again. */
|
|
334
|
+
retryAddress: string;
|
|
335
|
+
processing: string;
|
|
336
|
+
redirectNote: string;
|
|
337
|
+
cashPoints: string;
|
|
338
|
+
cashMore: string;
|
|
339
|
+
cashNote: string;
|
|
340
|
+
secureCard: string;
|
|
341
|
+
pickDeliveryFirst: string;
|
|
342
|
+
updatingTotal: string;
|
|
343
|
+
syncFailed: string;
|
|
344
|
+
/** The shipping quote expired or changed: fresh rates are loading. */
|
|
345
|
+
quoteChanged: string;
|
|
346
|
+
rebuildCart: string;
|
|
347
|
+
noPaymentTitle: string;
|
|
348
|
+
noPayment: string;
|
|
349
|
+
paymentNote: string;
|
|
350
|
+
/** Fallback names for the provider options when the server sends no `label`. */
|
|
351
|
+
options: Record<PaymentOptionKey, string>;
|
|
352
|
+
};
|
|
353
|
+
/** Messages for a locale (`es*` default, `en*`), with optional overrides. */
|
|
354
|
+
declare function paymentMethodMessages(locale?: string | null, overrides?: Partial<Omit<PaymentMethodMessages, 'options'>> & {
|
|
355
|
+
options?: Partial<PaymentMethodMessages['options']>;
|
|
356
|
+
} | null): PaymentMethodMessages;
|
|
357
|
+
|
|
358
|
+
/** Name of the radio group that carries the chosen row (`method` or `method|option`). */
|
|
359
|
+
declare const PAYMENT_CHOICE_FIELD = "payment_choice";
|
|
360
|
+
/** Name of the radio group that carries the chosen cash point. */
|
|
361
|
+
declare const CASH_POINT_FIELD = "cash_point";
|
|
362
|
+
/** Fields of the page form (contact, delivery, address, method) for the JSON POST of the embedded payment. */
|
|
363
|
+
declare function formFields(form: HTMLFormElement | null | undefined): Record<string, string>;
|
|
364
|
+
type PaymentMethodClassNames = Partial<Record<'root' | 'legend' | 'choice' | 'radioLabel' | 'radio' | 'labelText' | 'hint' | 'icon' | 'brands' | 'panel' | 'cashPoint' | 'cashPointInput' | 'cashMore' | 'note' | 'alert' | 'status' | 'brickWrap' | 'brick' | 'submit' | 'rebuild', string>>;
|
|
365
|
+
type PaymentMethodTestIds = Partial<Record<'method' | 'submit' | 'cash' | 'redirectNote' | 'card' | 'syncing' | 'syncFailed' | 'rebuild' | 'noPayment', string>>;
|
|
366
|
+
type PaymentMethodSectionProps = {
|
|
367
|
+
/** From `buildPayChoices(payment.methods)`. */
|
|
368
|
+
choices: PayChoices;
|
|
369
|
+
/** The server total (`cart.cost.total`). Shown on the button and passed to the card form. Never computed here. */
|
|
370
|
+
amount: Money;
|
|
371
|
+
/** Cart (or checkout) id: scopes the stored attempt id so a reload reuses it. */
|
|
372
|
+
scope?: string;
|
|
373
|
+
/** The page `<form>`: its fields travel with the card payment and it is validated before charging. */
|
|
374
|
+
formRef: RefObject<HTMLFormElement | null>;
|
|
375
|
+
/** POST endpoint that charges the card (`handlers.pay` on the server). */
|
|
376
|
+
payUrl: string;
|
|
377
|
+
/** POST endpoint that re-reads the payment (`handlers.status`). Enables the 3DS / review polling. */
|
|
378
|
+
statusUrl?: string;
|
|
379
|
+
/** Row preselected. Default: `choices.defaultValue`. */
|
|
380
|
+
defaultChoice?: string | null;
|
|
381
|
+
/** Value of the delivery group; the card form waits until it is `deliveryReady` and `syncDelivery` has settled. */
|
|
382
|
+
delivery?: string;
|
|
383
|
+
/** `false` while the buyer has not chosen a delivery that fixes the total (e.g. address pending). Default true. */
|
|
384
|
+
deliveryReady?: boolean;
|
|
385
|
+
/**
|
|
386
|
+
* Saves the chosen delivery on the server cart so the server total includes it. Resolve `true` once the new total
|
|
387
|
+
* has been read back (the `amount` prop is then up to date). Called once per delivery, whatever the payment row (so
|
|
388
|
+
* the total on the button and in the shop's summary always holds the chosen delivery). Without it nothing waits.
|
|
389
|
+
*
|
|
390
|
+
* Resolve `'requote'` when the server refused the rate because the quote expired or changed and the shop is loading
|
|
391
|
+
* fresh rates: the section then says so (`quoteChanged`, a status, not an error), keeps the card in the page and
|
|
392
|
+
* tries again with the next delivery value. `false` is a real failure (the card degrades to the redirect).
|
|
393
|
+
*/
|
|
394
|
+
syncDelivery?: (delivery: string) => Promise<boolean | 'requote'>;
|
|
395
|
+
/** A two-step checkout still collecting the address: the button reads "continue" and no card form shows. */
|
|
396
|
+
addressFirst?: boolean;
|
|
397
|
+
/** The address must be saved again before paying. */
|
|
398
|
+
retryAddress?: boolean;
|
|
399
|
+
/** Disables the button (the shop is not ready to take payment). */
|
|
400
|
+
blocked?: boolean;
|
|
401
|
+
/** The page form is submitting. */
|
|
402
|
+
busy?: boolean;
|
|
403
|
+
/** Names of fields with a server error (`payment_method`, `cash_point`). */
|
|
404
|
+
invalid?: ReadonlySet<string>;
|
|
322
405
|
nonce?: string;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
form?: string[];
|
|
406
|
+
locale?: string;
|
|
407
|
+
messages?: Parameters<typeof paymentMethodMessages>[1];
|
|
408
|
+
/** Name for a plain method (`PaymentMethod` without options). Default: the key as it comes. */
|
|
409
|
+
methodLabel?: (methodKey: string) => {
|
|
410
|
+
label: string;
|
|
411
|
+
hint?: string;
|
|
330
412
|
};
|
|
331
|
-
/**
|
|
332
|
-
|
|
413
|
+
/** Per-row icon by option (`card`, `cash`, `wallet`, `credits`) or `plain`. Replaces the default marks of that row. */
|
|
414
|
+
icons?: Partial<Record<PaymentOptionKey | 'plain', ReactNode>>;
|
|
415
|
+
/**
|
|
416
|
+
* Brand marks (`BrandMark`): the provider's mark on its account / no-card rows and on a plain method, the cash point
|
|
417
|
+
* marks on the cash row and next to each point, and `cardBrands` on the card row. Default true; `false` keeps the
|
|
418
|
+
* rows text-only.
|
|
419
|
+
*/
|
|
420
|
+
brandMarks?: boolean;
|
|
421
|
+
/** Card networks drawn on the card row (`visa`, `mastercard`, `amex`, `carnet`…), as the shop's provider accepts them. */
|
|
422
|
+
cardBrands?: readonly string[];
|
|
423
|
+
/** How to print the total on the button. Default `formatMoney`. */
|
|
424
|
+
renderAmount?: (amount: Money) => ReactNode;
|
|
425
|
+
/** Anchor to the cart for the "rebuild" action when the cart expired. Default: plain `<a href>`. */
|
|
426
|
+
rebuildHref?: string;
|
|
427
|
+
renderLink?: (props: {
|
|
428
|
+
href: string;
|
|
429
|
+
className?: string;
|
|
430
|
+
children: ReactNode;
|
|
431
|
+
testId?: string;
|
|
432
|
+
}) => ReactNode;
|
|
433
|
+
/** Called once the order is closed in the page (approved, under review or voucher). Navigate to the thank-you page. */
|
|
434
|
+
onDone: (outcome: PaymentOutcome) => void;
|
|
435
|
+
/** The server total changed under the buyer: re-read the cart (the card form remounts with the new amount). */
|
|
436
|
+
onAmountChanged?: () => void;
|
|
437
|
+
onEvent?: (event: PaymentEvent) => void;
|
|
438
|
+
classNames?: PaymentMethodClassNames;
|
|
439
|
+
testIds?: PaymentMethodTestIds;
|
|
440
|
+
/** Hide the section button (drive the form some other way). Card payments then need `PaymentMethodHandle`-less flows. */
|
|
441
|
+
hideSubmit?: boolean;
|
|
442
|
+
/** Replaces the transport built from `payUrl` / `statusUrl`. */
|
|
443
|
+
transport?: PaymentTransport;
|
|
444
|
+
/** Extra props for the card form (`adapter`, `adapters`, `messages`, `minHeight`, `storage`, timeouts...). */
|
|
445
|
+
brickProps?: Partial<Omit<PaymentBrickProps, 'client' | 'amount' | 'transport' | 'onResult' | 'onEvent' | 'onFallback'>>;
|
|
333
446
|
};
|
|
334
447
|
/**
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
448
|
+
* "Payment method", hybrid. Card: the provider's secure form INSIDE the page (`PaymentBrick`) with the shop's own
|
|
449
|
+
* button. Cash: payment points and a voucher on order. Provider account and no-card payments redirect. Without
|
|
450
|
+
* JavaScript, or if the card form does not load, everything falls back to the plain redirect flow (the page form's
|
|
451
|
+
* normal submit); the cash point radios and the notes work without JavaScript with the `payments.css` sheet.
|
|
452
|
+
*
|
|
453
|
+
* Money: the form amount is the server total passed in `amount` (already holding the chosen delivery); nothing is added
|
|
454
|
+
* or recalculated here.
|
|
338
455
|
*
|
|
339
|
-
*
|
|
456
|
+
* Accessibility: one labelled `fieldset` with native radios; notes in `role="status"`, problems in `role="alert"`; the
|
|
457
|
+
* button explains its busy state and is never silently disabled while the card form is loading.
|
|
340
458
|
*/
|
|
341
|
-
declare function
|
|
342
|
-
/** `Content-Security-Policy` or, during the rollout week, `Content-Security-Policy-Report-Only`. */
|
|
343
|
-
declare function paymentCspHeaderName(reportOnly: boolean): string;
|
|
459
|
+
declare function PaymentMethodSection(props: PaymentMethodSectionProps): react.JSX.Element;
|
|
344
460
|
|
|
345
461
|
/** CSS custom properties (set by the shop in its stylesheet) -> provider widget variables. */
|
|
346
462
|
declare const PAYMENT_THEME_TOKENS: {
|
|
@@ -361,4 +477,4 @@ declare const PAYMENT_THEME_TOKENS: {
|
|
|
361
477
|
*/
|
|
362
478
|
declare function readPaymentTheme(el: Element | null | undefined, tokens?: Record<string, string>): Record<string, string>;
|
|
363
479
|
|
|
364
|
-
export { type EmbeddedPaymentState, type EmbeddedPaymentStatus, type FetchTransportOptions, type LoadScriptOptions, MERCADOPAGO_BRICKS_KIND, type MercadoPagoAdapterOptions, type MercadoPagoCtor, type MountedPaymentForm, PAYMENT_THEME_TOKENS, PaymentBrick, type PaymentBrickHandle, type PaymentBrickProps, PaymentChallenge, type PaymentChallengeProps, type
|
|
480
|
+
export { CASH_POINT_FIELD, type EmbeddedPaymentState, type EmbeddedPaymentStatus, type FetchTransportOptions, type LoadScriptOptions, MERCADOPAGO_BRICKS_KIND, type MercadoPagoAdapterOptions, type MercadoPagoCtor, type MountedPaymentForm, PAYMENT_CHOICE_FIELD, PAYMENT_THEME_TOKENS, PayChoices, PaymentBrick, type PaymentBrickHandle, type PaymentBrickProps, PaymentChallenge, type PaymentChallengeProps, type PaymentEvent, type PaymentFallbackReason, type PaymentFormAdapter, type PaymentFormData, type PaymentFormError, type PaymentFormMountOptions, PaymentHttpError, type PaymentMethodClassNames, type PaymentMethodMessages, PaymentMethodSection, type PaymentMethodSectionProps, type PaymentMethodTestIds, type PaymentSubmitRequest, type PaymentTransport, type UseEmbeddedPaymentOptions, VoucherCard, type VoucherCardProps, createFetchTransport, formFields, loadPaymentSdk, mercadoPagoBricksAdapter, paymentMethodMessages, readPaymentTheme, resetPaymentSdkCache, sanitizeMercadoPagoFormData, useEmbeddedPayment };
|