# FluentForms → donor discount lookup FluentForms has no native way to query an external database from a field. This wires it up with a small Custom JS block that calls our secret-gated endpoint and unlocks a discount when the entered email belongs to a donor/member. ## Endpoint ``` GET https://scan.beartariacampgrounds.com/api/public/donor-eligibility?key=&email= ``` - `key` = the value of `PUBLIC_LOOKUP_SECRET` (set in the backend `.env`). - Returns minimal JSON — never names or dollar amounts: - `{"eligible": true, "tier": "member"}` - `{"eligible": true, "tier": "donor"}` - `{"eligible": false, "tier": null}` - Rate-limited (30/min/IP) and CORS-restricted to `PUBLIC_LOOKUP_ORIGIN` (default `https://tickets.beartariacampgrounds.com`). > The secret is visible in page source, so treat this as *deterrence, not > security*. It only gates a discount and reveals a yes/no + tier, so the blast > radius is small. Rotate the secret by changing `PUBLIC_LOOKUP_SECRET` and > redeploying. ## Form setup 1. On the ticket form add a **Custom HTML** element (or use FluentForms Pro's custom JS). Give your email field a known name (default FF `email`). 2. Decide the discount mechanism. Two common options: - **Coupon:** configure a coupon in the form's payment settings; the JS auto-fills + applies it for eligible emails. - **Conditional price:** add a hidden field (e.g. `donor_tier`) and use FluentForms conditional logic to show a discounted payment option when it equals `member`/`donor`. 3. Paste the snippet below into the Custom HTML element, editing the marked constants and the `applyDiscount()` body to match your form. ## Snippet ```html
``` ## Test ``` curl "https://scan.beartariacampgrounds.com/api/public/donor-eligibility?key=&email=adam21stevens@gmail.com" # -> {"eligible":true,"tier":"member"} ```