Repository navigation
fix-payment-confirmation - #166
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Emir icyer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
Hey Emir, awesome job on this. It looks like a solid fix. One small thing to consider: toNumber() is fine for normal order totals, and toFixed(2) is there if you would rather store the amount as a two-decimal string, like "15.50", instead of a JavaScript number. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Arsh-S
left a comment
There was a problem hiding this comment.
Good catch! Two things: skip the confirm if the order is already CONFIRMED, otherwise the stats cache double counts. And sellers can't see the mismatch anywhere yet, add paidAmount / paymentMismatchAt to BasicOrderSchema and show it on the seller order page. @eicyer
- confirmOrderPayment returns early for already-CONFIRMED orders so the stats cache isn't double counted - Store paidAmount as a two-decimal string via toFixed(2) - Add paidAmount / paymentMismatchAt to BasicOrderSchema - Show a payment mismatch warning on the seller order page
Fixes Venmo payment confirmation so it stops skipping safety checks, and stops silently dropping mismatched payments.
Description
updateOrderPaymentStatuswas writing the order's payment status directly instead of going through the normal confirm-payment path — so it skipped the inventory check (risk of overselling limited items) and never refreshed the fundraiser's stats cache. It now calls the sameconfirmOrderPaymentfunction admins use.PENDING, so they kept getting "please pay" reminders for money they'd already sent, and nobody on the seller side was told. It now records the mismatch on the order (newpaidAmount/paymentMismatchAtcolumns), stops the reminder job from nagging that order, and immediately emails the buyer with what we received vs. what's owed.testing
Automated: added 10 new tests covering both fixes —
backend/src/api/order/__tests__/order.services.test.ts(confirm routes through the real inventory check + cache refresh, with/without a payment method, mismatch recording) andbackend/src/api/email/__tests__/email.services.test.ts(confirms on exact match and within the 1¢ tolerance, records + emails on mismatch, wraps confirm errors).Manual path for a reviewer: create a VENMO order, send
updateOrderPaymentStatus(orderId, wrongAmount)— order should getpaidAmount/paymentMismatchAtset and the buyer should get a mismatch email instead of the order silently staying pending.Dependencies
Builds on #164 (rebased Jest test infrastructure) as it has a test suite.
Appendix / notes
paid_amount,payment_mismatch_atcolumns onorders) — not yet applied, seebackend/prisma/migrations/20261004174637_add_order_payment_mismatch_fields/.