Skip to content

Public affiliate signup on tenant pages — become an affiliate for <dn> (80%, 90-day) - #12

Merged
ralyodio merged 1 commit into
masterfrom
feat/domain-affiliate-join
Jul 10, 2026
Merged

Public affiliate signup on tenant pages — become an affiliate for <dn> (80%, 90-day)#12
ralyodio merged 1 commit into
masterfrom
feat/domain-affiliate-join

Conversation

@ralyodio

Copy link
Copy Markdown
Collaborator

What

Adds a "Become an affiliate for <dn>" widget to every parked-domain page (/?dn=<dn>, e.g. ?dn=moshscript.com). Anyone can join free, email-only, no login and instantly get a referral link for that domain — 80% commission, 90-day cookie.

How it works (reuses the existing referral rails — no schema change)

  • POST /api/affiliate/join (public): validates email + dn, calls findOrCreateAccountByEmail (creates a passwordless, claimable account) + enrollAffiliate (idempotent, 80% floor), and returns a domain-scoped link: https://moshcoding.com/?dn=<dn>&ref=<code>.
  • That link hits the existing middleware which drops the 90-day first-touch mc_ref cookie, and waitlist signups on <dn> already record ref, so conversions on that domain are credited to the affiliate.
  • To get paid, the affiliate logs in and sets a payout wallet in the dashboard (existing affiliate program).

Files

  • app/api/affiliate/join/route.ts — public join endpoint
  • components/AffiliateJoin.tsx — email form → referral link + copy button
  • components/Tenant.tsx — renders the widget; app/globals.css — styles

Verified (local, end-to-end)

  • join {email, dn:moshscript.com} → 80%, shareUrl …?dn=moshscript.com&ref=msejrba; idempotent (same code); bad email / missing dn → 400
  • ref link → Set-Cookie: mc_ref=…; Max-Age=7776000 (90 days)
  • tenant page renders the widget
  • waitlist signup on that domain → DB row ref=msejrba (credited); affiliate row code msejrba @ 80%

🤖 Generated with Claude Code

…<dn>)

Every parked-domain page (/?dn=<dn>) now has a 'Become an affiliate for <dn>'
widget: email-only signup, no login required. It creates a passwordless account
(claimable later) and enrolls it as an 80% affiliate, then returns a
domain-scoped referral link (…/?dn=<dn>&ref=<code>).

Reuses the existing referral rails end-to-end — the link drops the 90-day
first-touch mc_ref cookie (middleware) and waitlist signups on that domain are
tagged with the affiliate's ref, so conversions are credited. No schema change.

- POST /api/affiliate/join (public): findOrCreateAccountByEmail + enrollAffiliate
- components/AffiliateJoin.tsx: email form → referral link + copy
- Tenant.tsx renders it; globals.css styles it

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio
ralyodio merged commit ad90b67 into master Jul 10, 2026
2 checks passed
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