@12-apps/payments-frontend 1.20.0 → 1.20.2

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": "1.20.0",
3
+ "version": "1.20.2",
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": "^1.23.0",
20
+ "@12-apps/payments-backend": "^2.0.2",
21
21
  "react-qr-code": "^2.2.0"
22
22
  },
23
23
  "peerDependencies": {
@@ -26,6 +26,18 @@ import { ProviderSetupGuide } from './ProviderSetupGuide';
26
26
  */
27
27
  export const CHECKOUT_CONFIRM_ACTION = 'checkout-integrado-confirmado';
28
28
 
29
+ /**
30
+ * The confirm button's copy when a section does not author its own.
31
+ *
32
+ * InfinitePay's wording, because it was the only confirmable guide when this
33
+ * was a constant — and a constant is what made it wrong everywhere else: Stripe
34
+ * and Stone both own a step no API can report, and neither of them has a
35
+ * "Checkout Integrado" to have enabled. Sections say what they are asking about
36
+ * via `SetupSection.confirmLabel`; this fallback keeps InfinitePay's rendered
37
+ * guide identical.
38
+ */
39
+ const CONFIRM_LABEL_FALLBACK = 'Já habilitei o Checkout Integrado';
40
+
29
41
  /** Does this section end in a question only the owner can answer? */
30
42
  function isConfirmable(section: SetupSection): boolean {
31
43
  return section.steps.some((step) => step.action === CHECKOUT_CONFIRM_ACTION);
@@ -133,6 +145,28 @@ function ConfirmedRow({ section, onReopen }: { section: SetupSection; onReopen:
133
145
  );
134
146
  }
135
147
 
148
+ /**
149
+ * Everything the owner's confirmation contributes to this screen: the button's
150
+ * copy, and the one-line row the step collapses into once the walkthrough is
151
+ * past it.
152
+ *
153
+ * One function because both read the SAME section — the one that ASKS, which is
154
+ * not necessarily the one that is open. Deriving them apart is how a screen
155
+ * ends up captioning one step and collapsing another.
156
+ */
157
+ function confirmationOf(
158
+ guide: Guide,
159
+ { stage, confirmed, editing }: { stage: number; confirmed: boolean; editing: boolean },
160
+ ): { label: string; settledSection: SetupSection | null } {
161
+ const asking = confirmableStage(guide);
162
+ const section = asking >= 0 ? sectionAt(guide, asking) : null;
163
+ const settled = confirmed && !editing && asking >= 0 && stage > asking;
164
+ return {
165
+ label: section?.confirmLabel ?? CONFIRM_LABEL_FALLBACK,
166
+ settledSection: settled ? section : null,
167
+ };
168
+ }
169
+
136
170
  export function SetupGuideSection({
137
171
  guide,
138
172
  confirmed,
@@ -159,12 +193,7 @@ export function SetupGuideSection({
159
193
 
160
194
  const stage = effectiveStage(guide, confirmed, editing, stored);
161
195
  const open = sectionAt(guide, stage);
162
- // The confirmed step keeps a row of its own once the walkthrough has moved
163
- // past it — it is the claim step 3 is about to test, and when the provider
164
- // refuses to mint a link the owner needs somewhere to press Revisar.
165
- const settledStage = confirmableStage(guide);
166
- const settled = confirmed && !editing && settledStage >= 0 && stage > settledStage;
167
- const settledSection = settled ? sectionAt(guide, settledStage) : null;
196
+ const { label, settledSection } = confirmationOf(guide, { stage, confirmed, editing });
168
197
 
169
198
  return (
170
199
  <Box data-testid="payments-setup">
@@ -172,10 +201,7 @@ export function SetupGuideSection({
172
201
  guide={{ ...guide, sections: open ? [open] : [] }}
173
202
  activeStage={stage}
174
203
  actions={{
175
- [CHECKOUT_CONFIRM_ACTION]: {
176
- label: 'Já habilitei o Checkout Integrado',
177
- run: onConfirm,
178
- },
204
+ [CHECKOUT_CONFIRM_ACTION]: { label, run: onConfirm },
179
205
  }}
180
206
  beforeSections={
181
207
  <>