Repository navigation
Description
Problem
Today the only admin-side path to bill a prospect is the membership-invite flow (PR #3142):
- Admin types prospect email →
POST /api/admin/accounts/:orgId/invite-membership - Server generates a per-invite token, emails recipient
- Recipient clicks link →
/invite/:token→ signs in → accepts agreement - Server unconditionally calls
createAndSendInvoice— invoice issues - Recipient pays via the Stripe-hosted invoice "Pay" button (clicks 4 → 5 are card entry on a Stripe page)
This works, but it has friction we don't actually need:
- The recipient has no choice in payment method. They get an invoice whether they wanted card or not. Card-paying recipients have to navigate the Stripe-hosted invoice page, which is good but not as clean as a Checkout session.
- Every invite is one-shot, locked to a specific tier. Admin picks the tier upfront. If the prospect wants a different tier, the admin has to revoke and re-send.
- Per-invite tokens add machinery (creation, expiration, revocation, status state machine) for an outcome the admin doesn't really need to control. The signed-in user IS the source of truth; we don't need a token to identify them again later.
Proposal
Replace the per-invite token machinery with a shareable join link that walks the recipient through the same authenticated-issuer flow but with payment-method choice baked in.
Recipient flow
- Admin shares a link like
https://agenticadvertising.org/join?tier=aao_membership_member_15000&[email protected]&referral=… - Page renders the suggested tier (with option to switch to another eligible tier)
- WorkOS sign-in or sign-up, in-line
- Membership agreement checkbox + sign
- Payment chooser:
- Pay by card → POST to
/api/checkout-session→ redirect to Stripe Checkout - Pay by invoice (Net 30) → POST to
/api/invoice-request→ confirmation page ("We've emailed your invoice") - Wire / ACH → instructions to email [email protected] (for big buyers; not all tiers)
- Pay by card → POST to
- Both paid paths converge on
pending_agreement_user_idrecording for deterministic webhook attribution.
Tier eligibility for invoice is already a per-product field (is_invoiceable); the chooser just hides the option when the tier doesn't qualify.
Admin flow
Admin UI replaces the "Send Invite" modal with a "Generate Membership Link" affordance that produces a shareable URL with tier + referral pre-filled. Admin can paste it into Slack, an email, a calendar invite, an SDR sequence — whatever channel they prefer. No per-recipient state on our side.
What about the membership_invites table
Keep it as a soft tracking record ("who suggested what to whom, when") but it stops being load-bearing on the auth/billing path. Optional: log a row when someone lands on a /join?from=…&tier=… link so we can attribute referrals/conversions, but the row is no longer required to issue billing.
Why this is better
- Recipient gets agency. They pick payment method; they can switch tiers if the admin's suggestion was off.
- Card UX gets the proper Checkout session, not the Stripe-hosted invoice fallback. One less click; tighter UI.
- PO/AP buyers can pick the invoice path and the primary contact (the person who signs the agreement) is still the record-of-truth member, even if AP receives the actual Stripe invoice email later. Resolves the open follow-up from PR fix(billing): require authenticated session to issue invoices/payment links #3142's adtech-product review.
- Admin overhead drops. No invite tokens to track, expire, revoke. Re-sending a link is just "copy URL again."
- Conversion friction drops. 4 clicks (link → sign-in → agreement → pay button) is roughly the floor; we get the cleaner card UX as a free bonus.
Existing primitives we reuse
POST /api/checkout-session— already authenticated, already correct (PR fix(billing): require authenticated session to issue invoices/payment links #3142)POST /api/invoice-request— already authenticated, already recordspending_agreement_user_id(PR fix(training-agent): webhook envelope protocol uses AdCP domain, not 'mcp' #2876)blockIfActiveSubscriptionguard — already wired into both (PR fix(billing): refuse to mint a duplicate subscription on an org #3171, in flight)- WorkOS sign-in/sign-up — already used by the existing
/join/:referralCodepage is_invoiceableper-product flag — already filters tiers in admin UI- Customer Portal — already linked from the duplicate-sub 409 response
What's net new
/joinpage (or rework the existing/join/:referralCodepage): tier selector → agreement checkbox → payment chooser → POST to one of the existing endpoints. ~1 small page.- Admin "Generate Membership Link" affordance on the account-detail UI: produces the shareable URL.
- Eligibility rules for which tiers show "Pay by invoice" vs. card-only (likely tier-tier × cents threshold; mostly already encoded via
is_invoiceable). - Wire/ACH flow: probably just static instructions for now; no API changes needed.
- Optional: admin UI shows recent "link generated" entries with the from-attribution so admins can see conversion.
Out of scope
- Replacing the existing
/invite/:tokenflow immediately — keep both running for a deprecation window. Eventually remove the per-token machinery once/jointraffic dominates. - Designing the payment-chooser visual (separate design pass).
Acceptance criteria
- An admin can generate a shareable join link from the account detail page in 2 clicks.
- A recipient who is not an existing AAO user can land on the link, sign up via WorkOS, sign the agreement, and pay by card with a Stripe Checkout session minted in their authenticated session.
- A recipient who is an existing user lands on the same flow without re-creating an account; if their org already has an active sub the page shows the duplicate-sub 409 and links to the customer portal.
- The invoice path still works end-to-end and still records
pending_agreement_user_id. - No regression in cross-org contamination protection — caller-supplied identity must never become the Stripe customer.
References
- PR fix(billing): require authenticated session to issue invoices/payment links #3142 — payment-link issuer lockdown
- PR fix(billing): refuse to mint a duplicate subscription on an org #3171 — duplicate-subscription guard (in flight)
- The Triton/Encypher incident (Apr 2026) — the original motivation for both
Activity
bokelley commentedon Apr 25, 2026
Triage
Classification: Feature request
Bucket(s): admin / ops tools (server-side join page, admin UI, Stripe billing)
Status: deferred
Blocked-on: #3171 — resurfaces on merge. The new
/joinflow routes through/api/checkout-sessionand/api/invoice-request; both require the duplicate-subscription guard from #3171 to be live before this flow is safe to build on.Note for the next sweep: once #3171 lands, this issue has security-sensitive dimensions (WorkOS auth, Stripe customer identity binding, cross-org contamination acceptance criteria) — route to human review rather than auto-execute.
Triaged by Claude Code. Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
Generated by Claude Code
bokelley commentedon Aug 13, 2026
Closing as completed in the current onboarding/billing shape. Authenticated users can discover and request access to existing organizations, admins can approve join requests, and checkout or invoice selection runs through the guarded public billing endpoints without relying on the old unconditional per-invite invoice path.