How referrals are protected
Referrals are checked on the server, so no one can fake a doctor, a rate or a fee from the browser.
In short
The browser passes on only the referral code. The server finds the doctor, the rate and the fee itself, and refuses anything it cannot verify. Changes to roles, rates, codes, orders and payouts can only be made by admins, and every change is logged.
What the browser sends
The site keeps the code from the doctor's link and sends that one string with the order request. It never sends a doctor ID, a rate or an amount. Those come from the server.
What the server checks
- Code lookup: an unknown, turned-off or replaced code is ignored. The order still goes through at the normal price.
- Rate snapshot: each order saves the doctor's rate at the moment it is placed. Later changes do not alter it.
- Fee from server prices: the item prices come from the product list on the server, and the fee is worked out from them.
- Self-referral block: if the buyer's email address or phone number matches the doctor's, no fee is recorded.
- Guessing limits: repeated guesses at codes are rate-limited, and each code has a random part, so it cannot be worked out from a doctor's name.
What each account can see
- Patients see their own orders and profile.
- Doctors see only their own referrals and payouts. Patient names are masked, and no email address, phone number or street address is shown.
- Admins see the full dashboard.
Database rules stop any account from reading rows that are not theirs.
What only admins can change
Roles, fee rates, codes, order statuses and payouts change only through admin actions, and the server checks the admin role for each one. Every action is written to the audit log.
Turning a code off
Codes can be turned off or replaced at any time. A replaced code stops working straight away.