# Step 10: Add sign-in, email and payments

> Pagebee Academy, part 3 (Launch). Better Auth for sign-in, kept in your own database. Resend to send the emails. Stripe Checkout to take money. Three MCP servers, so your agent sets most of it up.

Time: A day. Cost: Free to start. Stripe takes 1.5% + 20p per UK card payment, 2.9% + 30¢ in the US.

## Why it matters

These three are where products leak trust. A sign-in email that lands in spam, a payment that went through but didn't unlock anything, a password reset that never arrives. Each is someone who wanted to use your product and couldn't.

**Better Auth** is an open-source sign-in library. Your users live in your own Postgres database, not in a sign-in company's, so you never pay per user and never have to migrate them. It's now also the home of Auth.js (NextAuth), so it's the safe pick for a new project. Start with magic links (a sign-in link by email) and add Google sign-in when people ask for it.

**Resend** sends those emails. The free plan is 3,000 emails a month and 100 a day, which is plenty until launch day.

**Stripe Checkout** is a payment page Stripe hosts for you. You never touch card numbers. Your app only needs to know when someone has paid, and Stripe tells it with a webhook (a message Stripe sends to your server).

## Do this

1. Sign up at [resend.com](https://resend.com). Add a domain under **Domains**, using a subdomain like `mail.tally.app` so your sending reputation stays separate from your normal email. Click **Sign in to Cloudflare** and Resend adds the DNS records for you.
2. Sign up at [stripe.com](https://stripe.com). Build everything in a **sandbox** first (from the account picker, **Sandboxes**), where the card `4242 4242 4242 4242` always works and no money moves.
3. Add both MCP servers, then type `/mcp` in Claude Code to sign in to each:

```
claude mcp add --transport http resend https://mcp.resend.com/mcp
claude mcp add --transport http stripe https://mcp.stripe.com/
```

4. Paste the prompt below. It wires up sign-in, email and payments in one pass, with a test for each.
5. Test the payment flow on your computer with the Stripe CLI, which forwards Stripe's webhooks to your local app:

```
brew install stripe/stripe-cli/stripe
stripe login
stripe listen --forward-to localhost:3000/api/stripe/webhook
```

6. When it all works, add your live keys to Secret Manager, create the live webhook endpoint in the Stripe dashboard pointing at your domain, and deploy.

## Paste into Claude Code

```text
Add sign-in with Better Auth using magic links, storing users and sessions in our Postgres database. Send the emails through Resend from hello@mail.tally.app, as plain, short emails. Then add payments with Stripe Checkout in our Stripe sandbox: create the product and a £6 monthly price, a checkout button for signed-in users, and a webhook at /api/stripe/webhook that verifies the signature and marks the user as paid on checkout.session.completed. Make the webhook safe to receive twice. Keep every key in .env (and list the names in .env.example). Explain how to test each part.
```

## The trap: Unlocking the product on the thank-you page

If your app marks someone as paid when they land on the success page, anyone can visit that page. People also close the tab before it loads. Only the webhook, with its signature checked, should change what someone has paid for.

## Using something else

Clerk and Supabase Auth are hosted sign-in services: quicker to start, but your users live in their database and you pay per user as you grow. Postmark and Amazon SES send email well too. Paddle and Lemon Squeezy act as the seller for you and handle sales tax worldwide, for a higher fee than Stripe.

## Adding Google sign-in later

In the Google Cloud console, open **Google Auth Platform**, click **Get started**, and fill in **Branding** and **Audience** (choose **External**). Under **Clients**, create a web client with your domain's callback URL, and give the ID and secret to Better Auth. Ask only for name and email, and publish the app out of Testing before launch, or real users will see a warning.

## Sources

- [Better Auth: magic link](https://www.better-auth.com/docs/plugins/magic-link)
- [Auth.js joins Better Auth](https://better-auth.com/blog/authjs-joins-better-auth)
- [Resend pricing](https://resend.com/pricing)
- [Resend: domains with Cloudflare](https://resend.com/docs/dashboard/domains/cloudflare)
- [Resend MCP server](https://resend.com/docs/mcp-server)
- [Stripe: sandboxes](https://docs.stripe.com/sandboxes)
- [Stripe: fulfil orders](https://docs.stripe.com/checkout/fulfillment)
- [Stripe MCP](https://docs.stripe.com/mcp)
- [Stripe UK pricing](https://stripe.com/gb/pricing)
- [Google: OAuth consent setup](https://support.google.com/cloud/answer/15544987)

Checked 24 November 2026. https://pagebee.ai/academy/sign-in-email-payments
