Repository navigation
Close the payment verification bypass and limit fee access - #16
Conversation
- verify-razorpay accepted the signature test_sig_<paymentId> in every environment, and fell back to a known secret, so anyone could mark an invoice paid. The simulated signature is now accepted only in test mode (outside production with no secret), and production returns 503 until RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET are set. - Students can only create orders for, and verify payments on, their own invoices. - Invoice and receipt lists had no role check, so faculty and HODs could read every student's fees. They are now Admin (all) and Student (own) only, and only Admin creates fee structures and invoices.
The Pay button always completed a fake payment. It now does so only when the API reports test mode, says no money was charged, and otherwise tells the student online checkout isn't available yet. Fees is removed from the HOD sidebar and routes.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4884fb407c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Simulate or verify payment via test signature / Razorpay checkout | ||
| // Razorpay Checkout isn't integrated yet, so a payment can only be simulated, and only when the API is in test | ||
| // mode. Anywhere else, don't pretend the payment went through. | ||
| if (!order.testMode) { |
There was a problem hiding this comment.
Avoid creating a payment before checking checkout availability
When testMode is false (for example, in production with Razorpay keys configured), clicking Pay has already called createRazorpayOrder, which inserts a PENDING payment, before this check stops the flow. Since no checkout is launched, each retry leaves another unpaid payment record; check availability without creating an order, or reject the order request until checkout is available.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 28b0d88. The page now asks GET /fees/payment-mode first and only shows a Pay button when a payment can complete (test mode for now, since there's no Checkout step yet); otherwise it shows that online payment isn't available, so no order or pending payment is created.
The Pay button created an order (a pending payment) and only then stopped when checkout wasn't available, so every click left another unpaid payment. GET /fees/payment-mode tells the page whether a payment can complete; without test mode the page shows that online payment isn't available instead of a button.
# Conflicts: # apps/web/src/lib/navigation.tsx # docs/api.md
Found while checking the HOD role's "no unrestricted financial access" rule.
Summary
Payment bypass:
POST /fees/payments/verify-razorpayaccepted the signaturetest_sig_<paymentId>in every environment, and fell back to a known secret (test_secret) when none was set. Any student could mark their own invoice as paid without paying. Now:PAYMENTS_NOT_CONFIGUREDuntilRAZORPAY_KEY_IDandRAZORPAY_KEY_SECRETare set;Ownership: a student can only create orders for, and verify payments on, their own invoices.
Read access:
GET /fees/invoicesandGET /fees/receiptshad no role check, so faculty and HODs could read every student's fees. They're now Admin (whole college) and Student (own) only. Creating fee structures and invoices is Admin only. Per the spec: "HOD should not automatically inherit this access".Web: the Pay button always completed a fake payment. It now only does so when the API reports test mode, and says no money was charged. Otherwise it tells the student online checkout isn't available yet. Fees is removed from the HOD sidebar and routes.
From review: the page now asks
GET /fees/payment-modebefore creating an order, and only offers a Pay button when a payment can complete, so clicks never leave pending payments behind.Not included: real Razorpay Checkout in the browser. The web app still has no checkout step, so production needs that before online payments can work.
Validation
pnpm test(178 passed, 7 new; 191 together with current main),pnpm lint,pnpm typecheck,pnpm build,git diff --check.