Skip to main content
The Stripe connection records your payments, refunds, disputes, and subscription changes as revenue. Squasher reads the last 13 months of objects when you connect, then records new events from a webhook. It uses a restricted key with read permissions only and does not change anything in Stripe.

Prerequisites

  • A Stripe account, and permission to create restricted keys and webhook endpoints in it.
  • Product analytics available for the project. See Product analytics.
  • A Squasher API key with the providers:write permission, if you connect with the CLI or the API. See API keys.

Create a restricted key

  1. In the Stripe Dashboard, open Developers, then API keys, and create a restricted key.
  2. Give the key Read access to these resources. Leave every other resource at None.
  1. Copy the key. It starts with rk_live_ (or rk_test_ in test mode). Squasher refuses secret keys (sk_), because it only reads.

Connect Stripe

The CLI reads the key from the STRIPE_RESTRICTED_KEY environment variable or from stdin. It has no flag for the key, so the key does not stay in your shell history.
The command prints the webhook URL and the event types to select.
Squasher checks the key against Stripe before it saves it, and then starts to read past objects. A live key records only live events, and a test key records only test events.

Add the webhook endpoint

  1. In the Stripe Dashboard, open Developers, then Webhooks, and add an endpoint.
  2. Paste the webhook URL from the connect step. Use API version 2024-06-20 or earlier for the endpoint, so invoice events include the paying charge.
  3. Select these events: charge.succeeded, charge.captured, charge.updated, charge.refunded, charge.refund.updated, refund.created, refund.updated, charge.dispute.funds_withdrawn, charge.dispute.funds_reinstated, invoice.paid, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, customer.subscription.paused, customer.subscription.resumed, checkout.session.completed, customer.created, and customer.updated.
  4. Copy the signing secret of the endpoint (it starts with whsec_) and save it in Squasher:
The command reads the secret from stdin. Squasher accepts only events signed with this secret and less than 5 minutes old, and it records each Stripe event id once.

Check the connection

The check shows when the last webhook event arrived and whether Squasher has read the past payments. Squasher also re-reads the last 3 days every 15 minutes, so a missed webhook delivery is recorded later.

Disconnect Stripe

Squasher deletes the stored key and signing secret. Recorded revenue stays. Delete the webhook endpoint and the restricted key in the Stripe Dashboard too.

Next steps

Revenue

How Squasher counts revenue and MRR, and how revenue links to people.

Revenue API

Read revenue and MRR from your own tools.