Building Block

Payment & Checkout

Stripe Checkout Sessions, subscription billing, and deposit payment flows — Claude deploys the full PHP payment stack in a single conversation. Zero platform commission beyond Stripe’s standard rate.

Payment & checkout patterns

Three Stripe integration patterns — from a one-time product checkout to recurring subscriptions with customer portals. Pure PHP and vanilla JS, no third-party payment plugins required.

Pattern 1 — Stripe Checkout Session

The fastest path from button click to completed payment. Claude generates a PHP endpoint that creates a Stripe Checkout Session and redirects the buyer to Stripe’s hosted payment page — PCI-compliant by default, no card data touches your server.

PHP Stripe PHP SDK Checkout Session Webhook MySQL SMTP
  • checkout.php: server-side Stripe Checkout Session creation with product name, price, and quantity from your page
  • Success and cancel redirect URLs configured per session — no shared global redirect
  • webhook.php: listens for checkout.session.completed, verifies Stripe webhook signature, writes order to MySQL
  • MySQL orders table: stripe_session_id, email, amount_pence, status, created_at
  • SMTP order confirmation email to buyer triggered on webhook receipt — HTML formatted with order reference
  • Test mode / live mode toggle via a single STRIPE_SECRET_KEY PHP constant — swap key to go live, no code changes
Prompt to use with Claude

Add a Stripe Checkout Session to my site for a product called “[Product name]” priced at £[amount]. Create checkout.php to redirect to Stripe Checkout on button click. Create webhook.php handling checkout.session.completed — write the order to a MySQL orders table and send a confirmation email via SMTP to the buyer. Success redirect to /thank-you, cancel redirect to /[product-page]. Store the Stripe secret key as a PHP constant. CSS in theme.css, no inline styles.

Pattern 2 — Stripe Subscriptions & Customer Portal

Recurring billing with monthly and annual plans, Stripe-hosted subscription management, and a customer portal so members can upgrade, downgrade, or cancel without contacting you. PHP session-based access control gates any page to active subscribers only.

PHP Stripe Subscriptions Customer Portal Webhook MySQL Session Auth
  • Stripe Checkout Session in subscription mode with separate monthly and annual Price IDs
  • Webhook events handled: customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.payment_failed
  • MySQL members table: stripe_customer_id, email, plan, status (active / past_due / cancelled)
  • auth_check.php: include at the top of any page to redirect unauthenticated or lapsed subscribers to /pricing
  • Stripe Customer Portal link generated server-side — members click “Manage billing” and are redirected to Stripe’s hosted portal
  • SMTP welcome email on subscription creation; automatic payment failure notification on invoice.payment_failed
Prompt to use with Claude

Build a Stripe subscription system on my site. Two plans: Monthly at £[price]/month (Price ID: [monthly_price_id]) and Annual at £[price]/year (Price ID: [annual_price_id]). Create checkout.php for subscription Checkout Sessions. Create webhook.php handling subscription.created, subscription.updated, subscription.deleted, invoice.payment_failed — update a MySQL members table accordingly. Create portal.php to redirect logged-in members to the Stripe Customer Portal. Create auth_check.php to gate any page — redirect to /pricing if not an active subscriber. Send a welcome email via SMTP on signup. CSS in theme.css.

Pattern 3 — Deposit & Balance Payments

Collect a deposit upfront via Stripe Checkout, store the booking, and email a balance payment link when the work is complete. Ideal for service businesses: photographers, consultants, event venues, tradespeople. The balance link uses a Stripe Payment Link for zero-friction completion.

PHP Stripe Checkout Stripe Payment Links MySQL SMTP Admin Panel
  • Stripe Checkout Session for deposit amount (configurable percentage of total — e.g. 25%, 50%)
  • MySQL bookings table: booking_ref, email, total_pence, deposit_paid, balance_due, status
  • Booking status values: deposit_paidbalance_sentcomplete
  • SMTP deposit confirmation with unique booking reference and balance amount outstanding
  • admin/bookings.php: table of all bookings with status and per-row “Send balance link” button
  • Balance payment link generated via Stripe Payment Links API and emailed to client on admin action
  • Webhook handles both checkout.session.completed (deposit) and payment_intent.succeeded (balance) to update status
Prompt to use with Claude

Build a deposit payment system for my service business. Clients pay a [25]% deposit via Stripe Checkout to confirm a booking. Store bookings in a MySQL bookings table with booking_ref, email, total, deposit, balance, and status fields. Send a SMTP confirmation email with the booking ref. Create admin/bookings.php listing all bookings — with a “Send balance link” button per row that emails the client a Stripe Payment Link for the outstanding amount. Handle deposit and balance completed webhooks to update booking status. CSS in theme.css.

Every payment pattern includes

Zero platform commission

Claude deploys direct Stripe integrations — no payment plugin taking 1–2% on every transaction. You pay Stripe’s standard processing fee. Nothing else.

PCI-compliant by default

Stripe Checkout and Payment Links handle all card data. No card numbers reach your server — Stripe’s PCI DSS compliance covers you automatically.

Full backend included

PHP webhook handlers, MySQL orders tables, and SMTP confirmation emails — not just the payment button. Claude builds the complete backend in the same conversation.

Test before going live

All patterns use a single STRIPE_SECRET_KEY constant. Swap your test key for the live key when you’re ready. No code changes, no redeployment needed.

Pair payments with

Combine payment patterns with these building blocks for a complete transactional site.

Pricing Tables

Showcase your plans with a pricing table and link each tier directly to its Stripe Checkout Session.

View patterns

Booking & Scheduling

Pair deposit checkout with an appointment booking engine for a complete service business flow.

View patterns

Auth & Members

Gate member-only pages using PHP session checks tied to your Stripe subscription status.

View patterns

Deploy your first payment flow today

From £6.99/month. First month free — no credit card required.