Headlessly
Integrations

Stripe

Truth source for all Billing entities and financial metrics.

Stripe is not "an integration to add later." It's the truth source for all Billing entities from day 1.

Connect

import { Integration } from '@headlessly/platform'

await Integration.connect({ provider: 'stripe', apiKey: process.env.STRIPE_KEY })

Entity Mapping

headless.lyStripeDirection
Customerstripe.customersBidirectional
Productstripe.productsBidirectional
Pricestripe.pricesBidirectional
Subscriptionstripe.subscriptionsBidirectional
Invoicestripe.invoicesBidirectional
Paymentstripe.payment_intentsBidirectional

Creating a Subscription in headless.ly creates a Stripe subscription. Stripe webhooks flow back as events in the immutable log.

Financial Metrics

Real metrics derived from Stripe data:

MetricDerivation
MRRSum of active subscription amounts, normalized monthly
ARRMRR × 12
Churn RateCancellations / total subscriptions
NRRIncluding expansions, contractions, and churn
LTVRevenue per customer / churn rate
ARPUMRR / active subscribers
import { Metric } from '@headlessly/analytics'

const mrr = await Metric.get('mrr')     // Real number from Stripe
const churn = await Metric.get('churn_rate')

Webhook Events

Stripe webhooks map to headless.ly events:

Stripe Eventheadless.ly Event
customer.subscription.createdSubscription.Created
customer.subscription.updatedSubscription.Updated
customer.subscription.deletedSubscription.Cancelled
invoice.paidInvoice.Paid
payment_intent.succeededPayment.Captured

React to events with handlers:

import { Invoice, Subscription } from '@headlessly/billing'

Invoice.paid((invoice, $) => {
  $.Event.create({ type: 'revenue', amount: invoice.total })
})

Subscription.cancelled((sub, $) => {
  $.Contact.update({ id: sub.contact, stage: 'Churned' })
})

On this page