fix: show actionable Pix-minimum error on below-minimum charges#2186
fix: show actionable Pix-minimum error on below-minimum charges#2186abalinda wants to merge 2 commits into
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughQRPayPage 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. ChangesPix Below-Minimum Payment Error Handling
🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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. Comment |
Code-analysis diffPainscore total: 5876.31 → 5864.33 (-11.98) 🆕 New findings (13)
✅ Resolved (13)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
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.
There was a problem hiding this comment.
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. |
| } 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.` | ||
| ) |
| 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() | ||
| }) |
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_MINIMUMerror from Manteca and shows a clear message stating the BRL minimum for Pix payments.Risk
Low / FE-only. Single
else ifbranch in the qr-pay error handler — no API, schema, or shared-state changes. No cross-repo impact.QA
Below-minimum Pix charge shows the Pix minimum-amount errorinqr-pay-states.test.tsx.