[PK-60] BE+FE: PayBySquareError → 503 payment_misconfigured + FE fallback #25
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "agent/be-dev/b3ee7b4e"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Súhrn
Defenzívne mapovanie BE↔FE pre prípad, keď QR sa nedá vygenerovať kvôli zlej konfigurácii (napr. invalid IBAN cez
.env).BE
app/api/orders/[id]/payment-qr/route.ts:PayBySquareError→503 { error: "payment_misconfigured", code, message }.500zostáva len pre skutočné internal failures (DB výpadok, nečakaná výnimka).pay_by_square_misconfigured(scodeaorder_id).FE
fe/src/lib/api.ts:getPaymentQrrozlišuje 503 podľabody.error:payment_misconfigured→kind: "misconfigured"(scode)kind: "not_configured"(back-compat pre prípad chýbajúcehoPAYMENT_IBAN).fe/src/components/order/PaymentQrCard.tsx: novýPaymentMisconfiguredCard(VS + kontakt +421 903 400 326).PaymentNotConfiguredCardponechaný.fe/src/app/objednavka/[id]/page.tsx: branch premisconfigured.showQrSectionnetreba meniť (už zobrazoval všetko, čo nie jeunavailable).Testy
be/tests/payment-qr-route.test.ts: 2 nové prípady —invalid_ibanajinvalid_variable_symbol→503 payment_misconfigured+codev tele. Plus uistenie, že generickýErrorstále vracia500/internal_error.API kontrakt
Pred:
GET /api/orders/:id/payment-qrna config error →500 { error: "invalid_iban", message: "..." }Po:
GET /api/orders/:id/payment-qrna config error →503 { error: "payment_misconfigured", code: "invalid_iban", message: "..." }FE prijíma oba a renderuje fallback. Žiadny iný klient na endpoint nesiaha.
Test plan
npm testvbe/(202 testov)npm run typecheck+npm run lintvfe/.env→/objednavka/<id>musí ukázaťPaymentMisconfiguredCard(nie biele miesto)Closes PK-60.
BE app/api/orders/[id]/payment-qr/route.ts mapuje PayBySquareError na 503 { error: "payment_misconfigured", code, message } namiesto generického 500. 500 zostáva pre skutočné internal failures. FE getPaymentQr rozlišuje 503 podľa body.error: payment_misconfigured → kind: "misconfigured", inak kind: "not_configured". Stránka objednávky renderuje nový PaymentMisconfiguredCard (VS + kontakt +421 903 400 326), takže UI už pri config bugu (napr. invalid IBAN cez .env) nezostane tiché. Testy: rozšírený be/tests/payment-qr-route.test.ts pre invalid_iban a ďalší PayBySquareError kód. Co-authored-by: multica-agent <github@multica.ai>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.