Skip to content

fix: show actionable Pix-minimum error on below-minimum charges#2186

Open
abalinda wants to merge 2 commits into
devfrom
fix/qr-pay-pix-minimum-error
Open

fix: show actionable Pix-minimum error on below-minimum charges#2186
abalinda wants to merge 2 commits into
devfrom
fix/qr-pay-pix-minimum-error

Conversation

@abalinda
Copy link
Copy Markdown

@abalinda abalinda commented Jun 4, 2026

Summary

A below-minimum Pix charge previously fell through to the generic "something went wrong" error, so the user had no idea why their payment failed or what to do next. This detects the PAYMENT_DESTINATION_BELOW_MINIMUM error from Manteca and shows a clear message stating the BRL minimum for Pix payments.

Risk

Low / FE-only. Single else if branch in the qr-pay error handler — no API, schema, or shared-state changes. No cross-repo impact.

QA

  1. Initiate a QR/Pix payment whose destination is below the Pix minimum (sandbox).
  2. Expect the error: "This Pix charge is below the {MIN_PIX_AMOUNT_BRL} BRL minimum for Pix payments." instead of the generic error.
  3. Covered by unit test Below-minimum Pix charge shows the Pix minimum-amount error in qr-pay-states.test.tsx.

A below-minimum Pix charge surfaced the generic 'something went wrong'
error, leaving the user with no idea why the payment failed. Detect
PAYMENT_DESTINATION_BELOW_MINIMUM and tell them the BRL minimum so they
know the next step.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peanut-wallet Ready Ready Preview, Comment Jun 4, 2026 9:59am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6a25d12-b70c-4cfd-bd4e-8f5356ba6d41

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae0f35 and 58d2716.

📒 Files selected for processing (2)
  • src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/(mobile-ui)/qr-pay/page.tsx

Walkthrough

QRPayPage now treats a mantecaApi PIX rejection for amounts below the minimum by clearing the merchant-amount wait state and showing a Pix-specific MIN_PIX_AMOUNT_BRL error; a new test verifies the UI renders the Pix minimum-amount message when initiation rejects with PIX_MIN_AMOUNT.

Changes

Pix Below-Minimum Payment Error Handling

Layer / File(s) Summary
Error case handling
src/app/(mobile-ui)/qr-pay/page.tsx
Payment-lock fetch error handler detects PIX_MIN_AMOUNT, clears the "waiting for merchant amount" state, and sets an initiating-payment error message referencing MIN_PIX_AMOUNT_BRL.
Error state test
src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx
New test mocks mantecaApi.initiateQrPayment to reject with PIX_MIN_AMOUNT, renders QRPayPage using a Pix QR code, and asserts the Pix minimum-amount message (BRL minimum for Pix payments) is displayed.

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding actionable error messaging for below-minimum Pix charges.
Description check ✅ Passed The description is directly related to the changeset, providing context about the Pix minimum error handling, risk assessment, and QA steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Code-analysis diff

Painscore total: 5876.31 → 5864.33 (-11.98)
Findings: 0 net (+13 new, -13 resolved)

🆕 New findings (13)

  • critical complexity — src/app/(mobile-ui)/qr-pay/page.tsx — CC 291, MI 53.26, SLOC 942
  • high hotspot — src/app/(mobile-ui)/qr-pay/page.tsx — 92 commits, +1068/-1086 lines since 6 months ago
  • medium react-long-component — src/app/(mobile-ui)/qr-pay/page.tsx:81 — QRPayPage is 1481 lines — split it
  • medium high-mdd — src/app/(mobile-ui)/qr-pay/page.tsx:81 — QRPayPage: MDD 330.4 (uses across many lines from declarations)
  • medium high-mdd — src/app/(mobile-ui)/qr-pay/page.tsx:566 — : MDD 33.0 (uses across many lines from declarations)
  • medium method-complexity — src/app/(mobile-ui)/qr-pay/page.tsx:566 — CC 21 SLOC 114
  • medium react-effect-derives-state — src/app/(mobile-ui)/qr-pay/page.tsx:927 — small useEffect that only sets state from deps
  • low high-dlt — src/app/(mobile-ui)/qr-pay/page.tsx:566 — : DLT 18 (calls 18 distinct functions — high context load)
  • low high-mdd — src/app/(mobile-ui)/qr-pay/page.tsx:822 — : MDD 15.1 (uses across many lines from declarations)
  • low high-mdd — src/app/(mobile-ui)/qr-pay/page.tsx:886 — : MDD 14.5 (uses across many lines from declarations)
  • low high-mdd — src/app/(mobile-ui)/qr-pay/page.tsx:1377 — : MDD 14.5 (uses across many lines from declarations)
  • low high-mdd — src/app/(mobile-ui)/qr-pay/page.tsx:831 — : MDD 11.8 (uses across many lines from declarations)
  • low high-mdd — src/app/(mobile-ui)/qr-pay/page.tsx:777 — : MDD 10.3 (uses across many lines from declarations)

✅ Resolved (13)

  • src/app/(mobile-ui)/qr-pay/page.tsx — CC 290, MI 53.33, SLOC 937
  • src/app/(mobile-ui)/qr-pay/page.tsx — 90 commits, +1061/-1085 lines since 6 months ago
  • src/app/(mobile-ui)/qr-pay/page.tsx:81 — QRPayPage is 1475 lines — split it
  • src/app/(mobile-ui)/qr-pay/page.tsx:81 — QRPayPage: MDD 329.2 (uses across many lines from declarations)
  • src/app/(mobile-ui)/qr-pay/page.tsx:560 — : MDD 33.0 (uses across many lines from declarations)
  • src/app/(mobile-ui)/qr-pay/page.tsx:560 — CC 21 SLOC 114
  • src/app/(mobile-ui)/qr-pay/page.tsx:921 — small useEffect that only sets state from deps
  • src/app/(mobile-ui)/qr-pay/page.tsx:560 — : DLT 18 (calls 18 distinct functions — high context load)
  • src/app/(mobile-ui)/qr-pay/page.tsx:816 — : MDD 15.1 (uses across many lines from declarations)
  • src/app/(mobile-ui)/qr-pay/page.tsx:880 — : MDD 14.5 (uses across many lines from declarations)
  • src/app/(mobile-ui)/qr-pay/page.tsx:1371 — : MDD 14.5 (uses across many lines from declarations)
  • src/app/(mobile-ui)/qr-pay/page.tsx:825 — : MDD 11.8 (uses across many lines from declarations)
  • src/app/(mobile-ui)/qr-pay/page.tsx:771 — : MDD 10.3 (uses across many lines from declarations)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🧪 UI test report — ✅ all green

Suites

  • unit: 1302 ran, 0 failed, 0 skipped, 19.9s

📊 Coverage (unit)

metric %
statements 50.6%
branches 31.4%
functions 35.3%
lines 50.4%
⏱ 10 slowest test cases
time test
0.3s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every stamp stays within canvas at any count
0.3s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in updateUserById body
0.3s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in updateUserById
0.1s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Manteca PIX form ready shows merchant card + amount input + pay button
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid US account with spaces
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ETH address in lowercase
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle too long for US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid German IBAN
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle unresolvable ENS name
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

The backend rejects below-minimum Pix charges with error code
PIX_MIN_AMOUNT (manteca/qr-payment.ts), not PAYMENT_DESTINATION_BELOW_MINIMUM.
Matching the wrong string meant the friendly minimum-amount message never
rendered in production and the charge fell through to the generic error.
Match the actual code so the fix works end-to-end.
@abalinda abalinda marked this pull request as ready for review June 4, 2026 19:15
Copilot AI review requested due to automatic review settings June 4, 2026 19:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a specific, user-facing error message for below-minimum Pix QR charges so users aren’t left with the generic “something went wrong” state, and introduces a unit test to validate the new behavior.

Changes:

  • Add a provider-specific error branch in the QR-pay payment-lock error handler to show the Pix minimum (BRL) message.
  • Add a unit test covering the below-minimum Pix error path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/app/(mobile-ui)/qr-pay/page.tsx Adds a new provider-error branch to surface a Pix minimum-amount message instead of the generic failure state.
src/app/(mobile-ui)/qr-pay/tests/qr-pay-states.test.tsx Adds a unit test asserting that the Pix minimum-amount message is shown on the below-minimum error.

Comment on lines +536 to +541
} else if (error.message.includes('PIX_MIN_AMOUNT')) {
// no need to wait for merchant here since we know the amount is too low — just show an error with next steps
setWaitingForMerchantAmount(false)
setErrorInitiatingPayment(
`This Pix charge is below the ${MIN_PIX_AMOUNT_BRL} BRL minimum for Pix payments.`
)
Comment on lines +1178 to +1185
test('Below-minimum Pix charge shows the Pix minimum-amount error', async () => {
mockMantecaApi.initiateQrPayment.mockRejectedValue(new Error('PIX_MIN_AMOUNT'))

renderQrPay({ qrCode: 'pix://payment?id=123', type: 'PIX', t: '1' })

await waitFor(() => {
expect(screen.getByText(/BRL minimum for Pix payments/i)).toBeInTheDocument()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants