@12-apps/payments-frontend 3.34.4 → 3.36.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 +1 -1
- package/src/card/fields.tsx +33 -14
- package/src/components/checkout/card-view.tsx +24 -10
- package/src/components/checkout/cart-changed.tsx +273 -0
- package/src/components/checkout/checkout-flow.tsx +65 -81
- package/src/components/checkout/checkout-frame.tsx +175 -0
- package/src/components/checkout/checkout-steps.tsx +57 -83
- package/src/components/checkout/icons.tsx +5 -0
- package/src/components/checkout/method-tabs.tsx +249 -0
- package/src/components/checkout/payment-status-parts.tsx +13 -3
- package/src/components/checkout/payment-step-frame.tsx +206 -0
- package/src/components/checkout/payment-step-layout.tsx +169 -14
- package/src/components/checkout/payment-summary-phone.tsx +158 -0
- package/src/components/checkout/payment-summary.tsx +290 -0
- package/src/components/checkout/pix-after-copy.tsx +1 -1
- package/src/components/checkout/pix-pane.tsx +172 -147
- package/src/components/checkout/pix-parts.tsx +6 -4
- package/src/components/checkout/pix-view.tsx +37 -17
- package/src/components/checkout/screens-copy.ts +48 -3
- package/src/components/checkout/screens-en-US.ts +17 -0
- package/src/components/checkout/screens-pt-BR.ts +17 -0
- package/src/components/checkout/start-payment.ts +48 -19
- package/src/components/checkout/use-checkout-controller.ts +6 -2
- package/src/index.ts +3 -0
|
@@ -43,6 +43,7 @@ export const PT_BR_CHECKOUT_SCREENS_COPY: CheckoutScreensCopy = {
|
|
|
43
43
|
copyPasteTab: 'Copia e cola',
|
|
44
44
|
qrTab: 'QR code',
|
|
45
45
|
qrHeading: 'Pelo celular',
|
|
46
|
+
otherDeviceHeading: 'Ou pague de outro aparelho',
|
|
46
47
|
copyPasteHeading: 'Pix Copia e Cola',
|
|
47
48
|
or: 'ou',
|
|
48
49
|
qrInstructions: 'Abra o app do seu banco no celular, escolha **Pix › Ler QR code** e aponte para a tela.',
|
|
@@ -88,6 +89,16 @@ export const PT_BR_CHECKOUT_SCREENS_COPY: CheckoutScreensCopy = {
|
|
|
88
89
|
payingWithSavedDetails: 'Pagando com os seus dados salvos',
|
|
89
90
|
changeAction: 'Alterar',
|
|
90
91
|
},
|
|
92
|
+
layout: {
|
|
93
|
+
payHeading: 'Como você quer pagar?',
|
|
94
|
+
summaryTitle: 'Resumo do pedido',
|
|
95
|
+
total: 'Total',
|
|
96
|
+
totalDueCaption: (items) => `Total a pagar · ${items} ${items === 1 ? 'item' : 'itens'}`,
|
|
97
|
+
lineLabel: (quantity, name) => `${quantity}× ${name}`,
|
|
98
|
+
taxIdOnFileShort: 'CPF ✓',
|
|
99
|
+
changeAddress: 'Alterar endereço',
|
|
100
|
+
stepProgress: (step, steps, label) => `Etapa ${step} de ${steps} · ${label}`,
|
|
101
|
+
},
|
|
91
102
|
error: {
|
|
92
103
|
confirming: 'Estamos confirmando seu pagamento',
|
|
93
104
|
cannotContinue: 'Não foi possível continuar',
|
|
@@ -129,6 +140,12 @@ export const PT_BR_CHECKOUT_SCREENS_COPY: CheckoutScreensCopy = {
|
|
|
129
140
|
invalidResponse: 'Resposta inválida do servidor.',
|
|
130
141
|
offline: 'Não foi possível conectar. Verifique sua conexão e tente novamente.',
|
|
131
142
|
},
|
|
143
|
+
cartChanged: {
|
|
144
|
+
heading: 'Seu carrinho mudou',
|
|
145
|
+
support: 'O pagamento foi preparado para o carrinho anterior. Atualize para pagar o valor certo.',
|
|
146
|
+
refreshAction: 'Atualizar pagamento',
|
|
147
|
+
refreshFailed: 'Não foi possível atualizar o pagamento',
|
|
148
|
+
},
|
|
132
149
|
validation: {
|
|
133
150
|
taxIdInvalid: 'CPF inválido.',
|
|
134
151
|
nameRequired: 'Informe seu nome.',
|
|
@@ -124,28 +124,57 @@ export function useStartPayment(input: {
|
|
|
124
124
|
failure.fail(result.error);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
// reason every other raised order is: the confirmation this is about to
|
|
129
|
-
// show has to survive a tab the phone discards on the way to it.
|
|
130
|
-
if (result.data.status !== "AWAITING_PAYMENT") {
|
|
131
|
-
rememberHostedOrder(result.data, { tenantSlug, basket: parkedBasket(basket) });
|
|
132
|
-
setOrder(result.data);
|
|
133
|
-
setFinalStatus(result.data.status);
|
|
134
|
-
setStep("status");
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (handOverToProvider(result.data, navigate, tenantSlug, basket)) return;
|
|
138
|
-
// PARKED EVEN THOUGH NOBODY IS LEAVING (FUT-1140). A low-memory phone
|
|
139
|
-
// discards this tab while the shopper is in their bank app, and the SPA
|
|
140
|
-
// that comes back has never heard of the order it raised — so the buyer
|
|
141
|
-
// meets an empty cart and a retry button instead of the confirmation for
|
|
142
|
-
// the payment they just made.
|
|
143
|
-
rememberHostedOrder(result.data, { tenantSlug, basket: parkedBasket(basket) });
|
|
144
|
-
setOrder(result.data);
|
|
127
|
+
routeRaisedOrder(result.data, { navigate, tenantSlug, basket, setOrder, setFinalStatus, setStep });
|
|
145
128
|
},
|
|
146
129
|
[
|
|
147
130
|
buyer, saveProfile, createOrder, failure, navigate, tenantSlug, basket,
|
|
148
131
|
setCreating, setDecline, setOrder, setFinalStatus, setStep,
|
|
149
132
|
],
|
|
150
133
|
);
|
|
151
|
-
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* What becomes of an order the host just raised — or re-priced (FUT-1139): the
|
|
138
|
+
* three outcomes of {@link useStartPayment} after its refusal branch, shared so
|
|
139
|
+
* a refresh routes a PAID or handed-off answer exactly as a raise does.
|
|
140
|
+
*/
|
|
141
|
+
export function routeRaisedOrder(
|
|
142
|
+
order: CheckoutOrder,
|
|
143
|
+
ctx: {
|
|
144
|
+
navigate: CheckoutNavigate;
|
|
145
|
+
tenantSlug: string | undefined;
|
|
146
|
+
basket: CheckoutBasketIdentity | undefined;
|
|
147
|
+
setOrder: Dispatch<SetStateAction<CheckoutOrder | null>>;
|
|
148
|
+
setFinalStatus: Dispatch<SetStateAction<OrderStatus | null>>;
|
|
149
|
+
setStep: Dispatch<SetStateAction<Step>>;
|
|
150
|
+
},
|
|
151
|
+
): void {
|
|
152
|
+
const { navigate, tenantSlug, basket, setOrder, setFinalStatus, setStep } = ctx;
|
|
153
|
+
// NOTHING LEFT TO PAY — see the docblock. Parked first for the same
|
|
154
|
+
// reason every other raised order is: the confirmation this is about to
|
|
155
|
+
// show has to survive a tab the phone discards on the way to it.
|
|
156
|
+
if (order.status !== "AWAITING_PAYMENT") {
|
|
157
|
+
rememberHostedOrder(order, { tenantSlug, basket: parkedBasket(basket) });
|
|
158
|
+
setOrder(order);
|
|
159
|
+
setFinalStatus(order.status);
|
|
160
|
+
setStep("status");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (handOverToProvider(order, navigate, tenantSlug, basket)) return;
|
|
164
|
+
// PARKED EVEN THOUGH NOBODY IS LEAVING (FUT-1140). A low-memory phone
|
|
165
|
+
// discards this tab while the shopper is in their bank app, and the SPA
|
|
166
|
+
// that comes back has never heard of the order it raised — so the buyer
|
|
167
|
+
// meets an empty cart and a retry button instead of the confirmation for
|
|
168
|
+
// the payment they just made.
|
|
169
|
+
rememberHostedOrder(order, { tenantSlug, basket: parkedBasket(basket) });
|
|
170
|
+
setOrder(order);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** {@link routeRaisedOrder}, bound to one checkout and stable while its inputs are. */
|
|
174
|
+
export function useRaisedOrderRoute(ctx: Parameters<typeof routeRaisedOrder>[1]): (order: CheckoutOrder) => void {
|
|
175
|
+
const { navigate, tenantSlug, basket, setOrder, setFinalStatus, setStep } = ctx;
|
|
176
|
+
return useCallback(
|
|
177
|
+
(order: CheckoutOrder) => routeRaisedOrder(order, { navigate, tenantSlug, basket, setOrder, setFinalStatus, setStep }),
|
|
178
|
+
[navigate, tenantSlug, basket, setOrder, setFinalStatus, setStep],
|
|
179
|
+
);
|
|
180
|
+
}
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
useSettledPort,
|
|
12
12
|
type Step,
|
|
13
13
|
} from "./checkout-actions";
|
|
14
|
-
import {
|
|
14
|
+
import { useOrderRefresh } from "./cart-changed";
|
|
15
|
+
import { useRaisedOrderRoute, useStartPayment } from "./start-payment";
|
|
15
16
|
import { useConfirmationWait } from "./confirmation-wait";
|
|
16
17
|
import { useCheckoutCopy } from "./copy-context";
|
|
17
18
|
|
|
@@ -144,6 +145,9 @@ export function useCheckoutController(
|
|
|
144
145
|
const { payWithEmail, handleResolved } = useResolutionActions({
|
|
145
146
|
buyer, method, startPayment, setBuyerState, setDecline, setFinalStatus, setStep,
|
|
146
147
|
});
|
|
148
|
+
// Re-price the order in place when the cart moved under it (FUT-1139), routed as a raise is.
|
|
149
|
+
const route = useRaisedOrderRoute({ navigate, tenantSlug, basket, setOrder, setFinalStatus, setStep });
|
|
150
|
+
const refresh = useOrderRefresh({ order, buyer, saveProfile, createOrder, route });
|
|
147
151
|
const retry = useRetryAction({
|
|
148
152
|
decline, order, clearError, setOrder, setDecline, setFinalStatus, setStep, setFreshInstrument,
|
|
149
153
|
});
|
|
@@ -166,6 +170,6 @@ export function useCheckoutController(
|
|
|
166
170
|
...resumeSurface(resume, confirming),
|
|
167
171
|
createError: failure.message, errorField: failure.field, errorCode: failure.code,
|
|
168
172
|
goToMenu: onExitToMenu, back, editBuyer,
|
|
169
|
-
goToPayment, startPayment, payWithEmail, handleResolved, retry, completed,
|
|
173
|
+
goToPayment, startPayment, refresh, payWithEmail, handleResolved, retry, completed,
|
|
170
174
|
};
|
|
171
175
|
}
|
package/src/index.ts
CHANGED
|
@@ -60,6 +60,7 @@ export {
|
|
|
60
60
|
type CheckoutFlowProps,
|
|
61
61
|
} from './components/checkout/checkout-flow';
|
|
62
62
|
export type { BackActionEmphasis } from './components/checkout/payment-status-parts';
|
|
63
|
+
export type { CheckoutDeliverySummary, CheckoutSummaryLine } from './components/checkout/payment-summary';
|
|
63
64
|
|
|
64
65
|
// ---------------------------------------------------------------------------
|
|
65
66
|
// The MOUNTED buyer checkout (FUT-741) and the checkout PIPELINE (FUT-1240).
|
|
@@ -118,6 +119,7 @@ export {
|
|
|
118
119
|
// pack section by section types the section it is writing (FUT-760).
|
|
119
120
|
export type {
|
|
120
121
|
CardPaneCopy,
|
|
122
|
+
CartChangedCopy,
|
|
121
123
|
CheckoutScreensCopy,
|
|
122
124
|
CheckoutTransportCopy,
|
|
123
125
|
CheckoutValidationCopy,
|
|
@@ -125,6 +127,7 @@ export type {
|
|
|
125
127
|
MethodPickerCopy,
|
|
126
128
|
PayerSummaryCopy,
|
|
127
129
|
PaymentErrorCopy,
|
|
130
|
+
PaymentLayoutCopy,
|
|
128
131
|
PixAfterCopyCopy,
|
|
129
132
|
PixPaneCopy,
|
|
130
133
|
SettlingCopy,
|