Skip to content

Close the payment verification bypass and limit fee access - #16

Merged
anishmehta24 merged 4 commits into
mainfrom
fix/fees-access
Nov 17, 2026
Merged

anishmehta24 merged 4 commits into
mainfrom
fix/fees-access

Conversation

@anishmehta24

@anishmehta24 anishmehta24 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Found while checking the HOD role's "no unrestricted financial access" rule.

Summary

  • Payment bypass: POST /fees/payments/verify-razorpay accepted the signature test_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:

    • the simulated signature is only accepted in test mode, meaning outside production with no secret configured;
    • in production both payment endpoints return 503 PAYMENTS_NOT_CONFIGURED until RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET are set;
    • a real Razorpay signature is checked against the configured secret.
  • Ownership: a student can only create orders for, and verify payments on, their own invoices.

  • Read access: GET /fees/invoices and GET /fees/receipts had 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-mode before 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.
  • Locally:
    • faculty and HOD got 403 on invoices and receipts, an HOD creating an invoice got 403, and admin got 200;
    • with two temporary ₹1 invoices, a student ordering another student's invoice got 404, and a forged signature got 400;
    • the test-mode payment on their own invoice produced a receipt. The temporary invoices were removed afterwards.

- 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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T22:17:06.712902Z 4884fb4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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
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.

1 participant