@12-apps/payments-frontend 3.7.0 → 3.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@12-apps/payments-frontend",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "type": "module",
5
5
  "description": "Browser half of the vendor-agnostic payments platform: plug-and-play MUI components for the per-provider settings page (credential form from each provider's schema, masked hints, verify/enable) and the checkout page (PIX QR + polling, card tokenization, hosted-checkout redirect), plus the headless hooks and fetch clients they build on. Talks only to the host's payments HTTP surface — never to a provider directly. Microfrontend-ready: no app coupling, host injects theme and auth.",
6
6
  "exports": {
@@ -17,7 +17,7 @@
17
17
  "storybook:build": "storybook build"
18
18
  },
19
19
  "dependencies": {
20
- "@12-apps/payments-backend": "^4.15.0",
20
+ "@12-apps/payments-backend": "^4.17.0",
21
21
  "react-qr-code": "^2.2.0"
22
22
  },
23
23
  "peerDependencies": {
@@ -1,8 +1,4 @@
1
- import type {
2
- CheckoutViewCopy,
3
- PaymentsUnavailableCopy,
4
- PaymentStatusCopy,
5
- } from "./view-copy";
1
+ import type { CheckoutViewCopy, PaymentStatusCopy } from "./view-copy";
6
2
 
7
3
  /**
8
4
  * The pt-BR pack — the exact sentences these views compiled in until 6.0.0,
@@ -10,15 +6,6 @@ import type {
10
6
  * what exempts this file from the copy-portability gate: Portuguese may ship,
11
7
  * it may not be silent.
12
8
  */
13
- export const PT_BR_PAYMENTS_UNAVAILABLE_COPY: PaymentsUnavailableCopy = {
14
- title: "Pagamento online indisponível",
15
- body: "Esta loja não recebe pagamentos pelo site. Combine o pagamento diretamente com a loja para concluir seu pedido.",
16
- remedyTitle: "Pagamento com o garçom",
17
- remedyBody: "Esta loja não recebe pagamentos pelo site. Chame o garçom para fechar a conta na mesa.",
18
- callAction: "Chamar garçom",
19
- callingAction: "Chamando...",
20
- };
21
-
22
9
  export const PT_BR_PAYMENT_STATUS_COPY: PaymentStatusCopy = {
23
10
  paid: {
24
11
  heading: "Pedido confirmado",
@@ -2,30 +2,26 @@
2
2
  * Every string the legacy checkout views render — required props, with NO
3
3
  * defaults, deliberately (the payments extraction's own doctrine, FUT-760):
4
4
  * a default in the origin host's language reads as finished to the next host
5
- * right up until a buyer sees it. These three views proved the point — the
6
- * flows factory's copy port existed, was REQUIRED, declared
5
+ * right up until a buyer sees it. These views proved the point — the flows
6
+ * factory's copy port existed, was REQUIRED, declared
7
7
  * `unavailableWithRemedyTitle` and `emptyCartAction`, and the views simply
8
8
  * never read it, so a host that dutifully passed copy still rendered another
9
9
  * product's voice.
10
10
  *
11
+ * The store-cannot-charge screen is NOT here any more. It shipped as a second
12
+ * component beside the factory's own — same two branches, but with the origin
13
+ * host's dining room welded into its API (`waiterAvailable`, `onCallWaiter`, a
14
+ * `checkout-call-waiter` test id) and a copy shape whose field names asked
15
+ * every adopter to name a waiter. The factory's screen says the same two
16
+ * things through `CheckoutAvailability.remedy` — a `{ label, onSelect }` the
17
+ * host fills with whatever its own remedy is — so the twin was deleted rather
18
+ * than renamed.
19
+ *
11
20
  * A pt-BR host imports {@link PT_BR_CHECKOUT_VIEW_COPY} from `./pt-BR` (the
12
21
  * package root re-exports it) and passes it by hand — one reviewable line,
13
22
  * never a silence.
14
23
  */
15
24
 
16
- /** The screen shown when the store cannot take money online. */
17
- export interface PaymentsUnavailableCopy {
18
- /** No remedy: the store simply does not charge online. */
19
- title: string;
20
- body: string;
21
- /** A remedy exists (the origin host: the waiter; a clinic: the front desk). */
22
- remedyTitle: string;
23
- remedyBody: string;
24
- /** The remedy button, idle and in flight. */
25
- callAction: string;
26
- callingAction: string;
27
- }
28
-
29
25
  /** The stepper's three labels, in flow order. */
30
26
  export interface CheckoutStepperCopy {
31
27
  dados: string;
package/src/index.ts CHANGED
@@ -84,19 +84,21 @@ export {
84
84
  type VaultedCardDisplay,
85
85
  } from './components/checkout/transport';
86
86
  export { type CheckoutHostPorts } from './components/checkout/use-checkout-controller';
87
- export { PaymentsUnavailable } from './components/checkout/payments-unavailable';
87
+ // No `PaymentsUnavailable` here. The store-cannot-charge screen ships once, as
88
+ // `createPaymentFlows().screens.PaymentsUnavailable`, which asks the host for a
89
+ // `CheckoutAvailability.remedy` — `{ label, onSelect }`, filled with whatever
90
+ // that host's remedy actually is. The component this line used to export was a
91
+ // second copy of the same screen with the origin host's dining room in its API.
88
92
  export type {
89
93
  CheckoutStepperCopy,
90
94
  CheckoutViewCopy,
91
95
  DadosStepCopy,
92
96
  EmptyCartCopy,
93
97
  PaymentStatusCopy,
94
- PaymentsUnavailableCopy,
95
98
  StatusOutcomeCopy,
96
99
  } from './components/checkout/view-copy';
97
100
  export {
98
101
  PT_BR_CHECKOUT_VIEW_COPY,
99
- PT_BR_PAYMENTS_UNAVAILABLE_COPY,
100
102
  PT_BR_PAYMENT_STATUS_COPY,
101
103
  } from './components/checkout/pt-BR';
102
104
  export { fetchCheckoutConfig } from './components/checkout/client';
@@ -1,88 +0,0 @@
1
- /**
2
- * What a shopper sees when the store cannot take money online.
3
- *
4
- * A store with no active payment provider used to render the full payment step
5
- * — PIX and Cartão side by side — and only fail at order creation, with a
6
- * "tente novamente em instantes" that no amount of retrying could fix. The
7
- * store is not momentarily busy; it simply does not charge online.
8
- *
9
- * The remedy depends on how the store operates, so the two cases are answered
10
- * differently rather than with one vague apology:
11
- *
12
- * waiter reachable — someone is there to take payment: offer the waiter.
13
- * not reachable — nobody is; say plainly that this store does not charge
14
- * online, so the shopper stops waiting for a payment screen.
15
- *
16
- * "Reachable" is a property of THIS shopper, not of the store: a mesas
17
- * restaurant also serves the balcão, and a shopper with no mesa has no comanda
18
- * for a waiter to close. Offering them the waiter sent them to a comanda screen
19
- * whose own mesa gate bounced them straight back to the menu — a dead end
20
- * dressed up as the remedy. So the caller decides, from the shopper's mesa.
21
- */
22
- import { Box } from "@mui/material";
23
- import type { JSX } from "react";
24
-
25
- import { useCheckoutComponents } from "./ui";
26
- import type { PaymentsUnavailableCopy } from "./view-copy";
27
-
28
- interface PaymentsUnavailableProps {
29
- /**
30
- * Every sentence this screen can say — the HOST's words (see
31
- * `./view-copy`). Until 6.0.0 the two remedies and the button were compiled
32
- * in, in one application's Portuguese, and a host that dutifully passed the
33
- * flows copy port still got them.
34
- */
35
- copy: PaymentsUnavailableCopy;
36
- /**
37
- * Whether THIS shopper can settle with a waiter — mesas on AND a mesa of
38
- * their own. Decides which remedy is offered.
39
- */
40
- waiterAvailable: boolean;
41
- /** Called when the shopper asks for a waiter. Omitted ⇒ no button. */
42
- onCallWaiter?: () => void;
43
- /** True while the waiter request is in flight. */
44
- calling?: boolean;
45
- }
46
-
47
- export function PaymentsUnavailable({
48
- copy,
49
- waiterAvailable,
50
- onCallWaiter,
51
- calling = false,
52
- }: PaymentsUnavailableProps): JSX.Element {
53
- const { Alert, Button } = useCheckoutComponents();
54
- if (!waiterAvailable) {
55
- return (
56
- <Box sx={{ display: "flex", flexDirection: "column", gap: 2 }} data-testid="checkout-payments-disabled">
57
- <Alert
58
- variant="info"
59
- title={copy.title}
60
- description={copy.body}
61
- showIcon
62
- />
63
- </Box>
64
- );
65
- }
66
-
67
- return (
68
- <Box sx={{ display: "flex", flexDirection: "column", gap: 2 }} data-testid="checkout-call-waiter">
69
- <Alert
70
- variant="info"
71
- title={copy.remedyTitle}
72
- description={copy.remedyBody}
73
- showIcon
74
- />
75
- {onCallWaiter ? (
76
- <Button
77
- variant="solid"
78
- size="lg"
79
- disabled={calling}
80
- onClick={onCallWaiter}
81
- dataTestId="checkout-call-waiter-button"
82
- >
83
- {calling ? copy.callingAction : copy.callAction}
84
- </Button>
85
- ) : null}
86
- </Box>
87
- );
88
- }