Skip to content

Direct-link join flow with payment chooser (replace per-invite tokens) #3173

Closed

Description

@bokelley

Problem

Today the only admin-side path to bill a prospect is the membership-invite flow (PR #3142):

  1. Admin types prospect email → POST /api/admin/accounts/:orgId/invite-membership
  2. Server generates a per-invite token, emails recipient
  3. Recipient clicks link → /invite/:token → signs in → accepts agreement
  4. Server unconditionally calls createAndSendInvoice — invoice issues
  5. 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

  1. Admin shares a link like https://agenticadvertising.org/join?tier=aao_membership_member_15000&[email protected]&referral=…
  2. Page renders the suggested tier (with option to switch to another eligible tier)
  3. WorkOS sign-in or sign-up, in-line
  4. Membership agreement checkbox + sign
  5. 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)
  6. Both paid paths converge on pending_agreement_user_id recording 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

What's net new

  1. /join page (or rework the existing /join/:referralCode page): tier selector → agreement checkbox → payment chooser → POST to one of the existing endpoints. ~1 small page.
  2. Admin "Generate Membership Link" affordance on the account-detail UI: produces the shareable URL.
  3. Eligibility rules for which tiers show "Pay by invoice" vs. card-only (likely tier-tier × cents threshold; mostly already encoded via is_invoiceable).
  4. Wire/ACH flow: probably just static instructions for now; no API changes needed.
  5. Optional: admin UI shows recent "link generated" entries with the from-attribution so admins can see conversion.

Out of scope

  • Replacing the existing /invite/:token flow immediately — keep both running for a deprecation window. Eventually remove the per-token machinery once /join traffic 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

Activity

  1. added
    enhancement
    claude-triaging
    on Apr 25, 2026
  2. bokelley commented on Apr 25, 2026

    @bokelley
    ContributorAuthor

    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 /join flow routes through /api/checkout-session and /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

  3. added
    claude-triaged
    and removed
    claude-triaging
    on Apr 25, 2026
  4. added this to the Evergreen milestone on May 17, 2026
  5. bokelley commented on Aug 13, 2026

    @bokelley
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude-triagedenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions