Stripe integration

Auto-send branded invoice + receipt emails on Stripe events. PDF attached. Mercury-style design.

What it does

Listens for invoice.paid, invoice.payment_succeeded, invoice.finalized, and invoice.payment_failed. For each:

  • Renders a Mercury-style invoice PDF on the fly.
  • Sends an HTML email with the PDF attached, branded with your company name + logo + colors.
  • Subject + body adapt to the event type (paid → "Receipt for invoice…", finalized → "Invoice…", payment_failed → "Payment failed for invoice…").

Setup

  1. Brand → Integrations → Connect Stripe. Maillayer mints an integration row + a webhook URL.
  2. Stripe dashboard → Developers → Webhooks → Add endpoint. Paste:
    https://<your-app>/api/hooks/stripe/<integrationId>
    Subscribe to invoice.paid, invoice.payment_succeeded,invoice.finalized, invoice.payment_failed.
  3. Copy Stripe's signing secret (whsec_…) and paste it into the Maillayer integration's Webhook signing secret field.
  4. Stripe → Developers → API keys. Copy your secret key (sk_live_…) and paste it into the integration's Stripe secret key field — encrypted at rest with your AUTH_SECRET.
  5. Fill in From email, Company name, address, and email for the PDF header.
  6. Save. Stripe will start firing events on the next invoice.

What gets sent

The email body is a clean Mercury-style card: large amount panel, "Paid on" / "Due by" line, attached PDF, optional "View on Stripe" button (if hosted_invoice_url is present in the event).

Skipped invoices
Zero-amount invoices and drafts are skipped (recipients don't need an empty receipt). Stripe occasionally fires finalized for $0 invoices — Maillayer no-ops cleanly.