Skip to content

Enhance billing module — Stripe integration, plan tiers, and automatic suspension policies

Wire Enhance's built-in billing module to Stripe end-to-end — products, prices, webhooks, suspension grace periods, and the failure modes operators see in production.

You flip the Enhance billing module on, plug in your Stripe keys, define three plan tiers, and let the first ten signups flow through. Two months later you discover the operational gaps: a customer’s card failed silently because the webhook secret was wrong and Stripe could not notify the orchestrator, the dunning emails never sent because the SMTP relay on the orchestrator was misconfigured, and one site got suspended at 23:00 on a Sunday because the grace period was set to zero days. The Enhance billing module works — the part that needs your attention is the policy around it.

What’s happening

Enhance ships a first-party billing module that handles customer signup, plan selection, recurring charges, dunning, and automatic suspension. It is not a replacement for an accounting system — it is a “panel + commerce” layer that owns the customer lifecycle from signup to suspension. Stripe is the supported payment processor; PayPal and a few regional gateways are also supported, but Stripe is where the bulk of the integration logic lives.

The data model: in Enhance, a Plan maps to a Stripe Product with one or more Prices (monthly, annual). A customer subscribes to a Plan; Enhance creates a Stripe Customer + Subscription, then receives webhook events for every relevant state change. When invoice.payment_succeeded fires, the subscription is marked paid and the customer’s services stay active. When invoice.payment_failed fires, the dunning policy kicks in: N days of grace, M reminder emails, then automatic suspension of all that customer’s websites and mailboxes. Unsuspension on invoice.payment_succeeded after dunning is automatic.

The operational gotchas are predictable. Webhook secret drift — Stripe rotates the webhook signing secret if you regenerate the endpoint; if you don’t update Enhance, every event arrives, gets rejected with a 400, and Stripe stops delivering after enough failures. SMTP for billing emails — billing notifications use the orchestrator’s outbound mail config, which is separate from any customer mail server. If the orchestrator’s mail relay has bad credentials, all dunning emails silently bounce. Suspension policy — “Suspend immediately” sounds tight; in practice you want at least a 7-day grace plus 3 reminder emails before suspending, so an expired card on a Friday afternoon does not become a Sunday outage. Tax — Stripe Tax integrates with Enhance via the Stripe customer record, but you must configure the customer’s billing address before the first invoice or you’ll undercharge for VAT.

How to verify

Confirm the Stripe webhook is configured on both sides. In Stripe Dashboard → Developers → Webhooks, the endpoint should be https://orchestrator.example.com/api/billing/stripe/webhook with the events listed below. In Enhance: Settings → Billing → Payment Gateways → Stripe, the publishable + secret + webhook keys should be present:

# From the orchestrator, check the last 50 webhook deliveries
curl -fsS https://orchestrator.example.com/api/v3/billing/webhook-events \
  -H "Authorization: Bearer <admin-token>" \
  | jq '.[] | {received_at, event_type, status_code}' | head -50

Every recent event should show status_code: 200. A run of 400s means the webhook secret in Enhance doesn’t match Stripe’s.

Confirm dunning emails go out by triggering a fake failed payment in Stripe test mode:

# Create a test customer with a card that always fails, run a test charge,
# then check Enhance's outbound mail log
docker exec -t enhance-postfix tail -n 100 /var/log/mail.log | grep -i billing

Check the suspension job has not run prematurely. The Enhance scheduler logs suspension decisions:

docker logs enhance-scheduler 2>&1 | grep -i suspend | tail -20
# [billing-suspend] customer=42 status=skipped reason=in-grace-period (day 3/7)

If you see status=suspended on a customer who paid yesterday, the subscription state didn’t update — usually a missed invoice.payment_succeeded webhook.

The fix

Set up Stripe and Enhance in the right order.

1. Create the products + prices in Stripe first. Match your plan tiers exactly. In the Stripe Dashboard, create one Product per Enhance Plan (Starter, Pro, Agency) and one Price per billing interval (monthly, annual). Note the price_xxx IDs.

2. Configure the webhook endpoint in Stripe. Endpoint URL: https://orchestrator.example.com/api/billing/stripe/webhook. Required events:

customer.created
customer.updated
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
invoice.created
invoice.finalized
invoice.payment_succeeded
invoice.payment_failed
invoice.upcoming
charge.refunded

Copy the signing secret (whsec_xxx) — you’ll paste it into Enhance in step 4.

3. Configure the orchestrator outbound mail relay. Settings → Email → Outbound. Use an authenticated SMTP relay you trust (Postmark, SES, your own mail-relay node) — not a customer mail server. Send a test email and confirm it arrives. If billing emails bounce, this is the first thing to check.

4. In Enhance, wire Stripe. Settings → Billing → Payment Gateways → Stripe → enter publishable key, secret key, and webhook signing secret. Map each Plan to the Stripe Product + Price IDs from step 1. Save and run the built-in connection test — it should report “OK” for both API and webhook.

5. Define the dunning + suspension policy. Settings → Billing → Dunning. Recommended starting point:

On invoice.payment_failed:
  Day 0:  Send "payment failed" email, mark account in grace period
  Day 1:  Stripe retries automatically
  Day 3:  Send "payment retry failed" email
  Day 5:  Send "final notice" email
  Day 7:  Stripe retries automatically (last attempt)
  Day 8:  Auto-suspend all websites + mailboxes
  Day 30: Auto-delete account if still unpaid (configurable)

On invoice.payment_succeeded (after suspension):
  Auto-unsuspend within 60 seconds

Set the grace period long enough that a customer on holiday with an expired card doesn’t lose a Sunday. Most agencies run 7-10 days. Set the auto-delete window long enough that data recovery is possible — 30+ days minimum, and back the customer data up before the deletion job runs.

6. Test the failure path before going live. Stripe ships test card numbers that simulate every failure mode (4000 0000 0000 0341 for declined, 4000 0000 0000 0259 for fraudulent). Create a test customer, subscribe them, replace their default payment method with a declining card, fast-forward the subscription to the next billing cycle, and confirm the dunning emails fire in the right order. The orchestrator’s scheduler runs the suspension job daily; you can manually trigger it for the test customer to validate the suspension actually disables the websites.

7. Reconcile monthly. Compare Stripe’s revenue report against Enhance’s customer list. Customers who exist in Enhance but not in Stripe are either trials or stuck states from a half-broken signup — find and resolve them. Customers who exist in Stripe but not in Enhance are usually old test data; clean up.

The billing module turns Enhance into a real hosting product — but it inherits all the policy questions of a commerce stack. Run Managed Cloud Ops over your Enhance install and we handle the webhook drift, dunning policy, and SMTP relay alongside the panel itself. For Stripe-integrated signup flows you can scope the build with our team.