# 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 (conditional pricing) The idea: a **hidden field** `donor_tier` holds `regular` / `donor` / `member`. The JS sets it from the email lookup, and your payment options are shown/hidden by FluentForms conditional logic based on its value. 1. **Hidden field.** Add a *Hidden Field*, name it exactly `donor_tier`, default value `regular`. 2. **Email field.** Note its name (default `email`). 3. **Payment options.** Set up two payment items (or two options of a multiple-choice payment field) — a regular price and a discounted price — and give each **conditional logic**: - **Regular price:** show when `donor_tier` **is** `regular` - **Donor price:** show when `donor_tier` **is** `donor` **OR** `donor_tier` **is** `member` (add both rules with "match any"). 4. **Custom HTML.** Add a *Custom HTML* element and paste the snippet below, setting `KEY` to your `PUBLIC_LOOKUP_SECRET` (and `EMAIL_SELECTOR` if your email field isn't named `email`). > FluentForms is Vue-driven, so a plain `input.value = …` won't update its > model and conditional logic won't fire. The snippet uses the native value > setter + dispatches `input`/`change`, which is the reliable way to make FF > notice a programmatic change. Test on your form; if conditional logic still > doesn't react, tell me your FF version and I'll adapt. ## Snippet ```html
``` ## Test ``` curl "https://scan.beartariacampgrounds.com/api/public/donor-eligibility?key=&email=" # donor/member -> {"eligible":true,"tier":"member"} # anyone else -> {"eligible":false,"tier":null} ``` If member and donor get the **same** discounted price, simplify: set the donor price to show when `donor_tier` **is not** `regular`, and you can ignore the member/donor distinction.