Black Branch/Docs
All sections

Card payments (Stripe)

This page is for an owner who wants viewers to pay by card on the site. After it, your own Stripe account takes tips, points purchases, gifted subscriptions and the monthly Supporter subscription. You are the merchant: every payment lands in your Stripe balance, and Stripe pays it out to your bank on your Stripe payout schedule. Black Branch never holds your money and takes no share of it.

Card payments are a module, off on a new install. Switch it on during setup (the Modules page) or later in Admin Panel → Payments → Connections, where Card payments (Stripe) is the first row of the Stripe card. The website applies this switch at once. Its steps then appear on the setup pages, and in the Admin Panel's How to set up Card payments (Stripe) guide on the same page.

What viewers see once it is set up is on Tips, store and subscriptions.

What connecting Stripe gives you

Stripe charges a fee on each payment. Stripe sets it, by country and payment method: see Stripe's pricing page.

Before you start

🔴 Protect your personal name and home address. Stripe can show customers a business or legal name, a support address and contact details on receipts and card statements. Check what a paying viewer will see before you go live: Protect your personal name and home address.

Test mode and live mode

Stripe keeps two separate worlds in every account. Test mode uses test keys (they contain _test_) and accepts only Stripe's test card numbers, so no real money moves. Live mode uses live keys (they contain _live_) and takes real cards. Keys, webhooks, prices and customers made in one mode do not exist in the other. Every value you paste on this page must come from the same mode.

The site works out the mode from the key you paste, and Check says which one it found.

Step 1: a restricted key and the publishable key

Stripe gives every account two kinds of API key:

  1. Open the Stripe Dashboard → Developers → API keys. Check that the test/live switch at the top shows the mode you want.
  2. Copy the Publishable key (pk_test_… or pk_live_…). You paste it in item 6 below.
  3. Under Restricted keys, choose Create restricted key. If Stripe asks how the key will be used, choose the option for your own integration.
  4. Give it a name you will recognise, such as "Community site".
  5. Set every permission to None, then set only the nine in the table below. Copy the key (rk_…) when Stripe shows it.
  6. On the setup page (or Admin Panel → Payments → Connections, card Stripe), paste the restricted key into Stripe secret key and the publishable key into Stripe publishable key, then press Check.

🖼 Image: the Stripe restricted-key form with the six Read and three Write permissions set.

The permissions the site needs, and why:

Permission Level What it lets the site do Why it is needed
Checkout Sessions Write Open the card payment window and read it back afterwards Every tip, gift, points purchase and subscription starts as a Checkout Session. The site also reads a session to show the "thank you" page and to match a failed payment to what was being bought.
Customers Write Create and read a Stripe customer for a signed-in buyer Brings a signed-in viewer's saved card and address back next time, and ties their subscription to their site account.
Customer portal Write Open Stripe's billing page for a subscriber This is what Manage subscription opens, so subscribers can change their card or cancel without asking you.
Subscriptions Read See a viewer's subscriptions and their status Stops a viewer being charged twice, and keeps the site's record of who is a Supporter in step with Stripe.
Invoices Read Read a subscription's invoices Renewals and failed renewals arrive as invoices; the site reads them to count each month's payment and note a failed one.
PaymentIntents Read Read a single payment Matches a failed payment, refund or dispute to the tip or purchase it belongs to.
Webhook Endpoints Read List the webhook destinations on your account Only for the webhook's Check in step 2 and for the Doctor.
Account Read Read your account's settings Reads the name Stripe prints on buyers' card statements, so the site can add a short word like TIP or GIFT after it without cutting your name off. The check also uses it to confirm the key works.
Prices Read Read a price you made in Stripe Reads the Supporter subscription's amount and currency (see Subscriptions), and lets Check confirm the price is monthly.

Check reads your account, then one page of each kind of object the site reads. If the key is missing a Read permission, the result names it ("the key cannot read …"), and you add it to the key in Stripe: you can edit a restricted key's permissions after making it. The check cannot test the three Write permissions without creating something real, so it never tries. A green check does not prove that checkout, the customer record or the billing portal will work. Step 4 proves them.

Both keys are stored encrypted on your server. A new or replaced key is used from the next payment on; no restart is needed.

Step 2: the webhook

A webhook is a message one service sends to another when something happens. When a viewer pays, a payment is refunded or a subscription renews, Stripe sends a webhook to your site saying so. The site never trusts the viewer's browser to say "I paid"; it waits for Stripe's message. That is why nothing is granted until this step is done. Stripe's explanation is Receive Stripe events in your webhook endpoint.

Anyone could send a message to your site pretending to be Stripe, so Stripe signs every webhook with a signing secret (whsec_…) that only Stripe and your site know. Your site checks the signature on every message and refuses any that does not match.

  1. Open the Stripe Dashboard → Developers → Webhooks, in the same mode as the keys from step 1.
  2. Choose Add destination (older dashboards say Add endpoint).
  3. Choose events from your account, and set the API version to 2026-07-29.dahlia, the version your setup page shows. It is the version this release reads payment events in, not necessarily the newest one. A destination on another version sends events in a shape the site was not written for.
  4. Select the thirteen events in the table below. The setup page lists them on one line, with a Copy button. Ticking "all events" also works.
  5. Choose a webhook endpoint as the destination type, and paste the endpoint URL from your setup page: https://example.com/api/billing/webhook (with your domain).
  6. Save it, open the new destination, and choose Reveal on the Signing secret. Copy it (whsec_…).
  7. Paste it into Stripe webhook signing secret on the setup page and press Check.

🖼 Image: a Stripe webhook destination showing the endpoint URL, the event list and the Reveal button for the signing secret.

The events, and what the site does with each:

Event What the site does
checkout.session.completed A checkout finished: records the tip, gift or points purchase, or starts tracking the new subscription
checkout.session.async_payment_succeeded A slower payment method (some wallets and bank payments) settled later: records it as above
checkout.session.async_payment_failed A slower payment failed after checkout: nothing was granted, so it is only logged
customer.subscription.created A new subscription: makes the viewer a Supporter and fires the "subscribed" alert
customer.subscription.updated A subscription changed (renewed, past due, set to cancel): updates the viewer's status
customer.subscription.deleted A subscription ended: ends the Supporter perks
invoice.paid A monthly renewal was paid: counts it on the support bar and in payment history
invoice.payment_failed A renewal could not be charged: noted in payment history
payment_intent.payment_failed A card was declined: noted in payment history
refund.created, refund.updated You refunded a payment: noted in payment history, and what the payment gave is taken back (see below)
charge.dispute.created, charge.dispute.closed A buyer opened a chargeback with their bank, and when it closed: noted in payment history; what the payment gave is taken back when it opens and given back if you win

What exactly a refund or dispute takes back, and what it leaves alone, is on How money flows.

Check confirms that a destination for your site's address exists in Stripe, is enabled, and sends every event above. It cannot read the signing secret back from Stripe, so it only checks that it looks like one. The first real payment proves it: a wrong secret makes your site refuse the message, and Stripe's webhook page shows the delivery as failed. A new signing secret applies at once.

Subscriptions

This step is optional. Tips and points purchases work with steps 1 and 2 alone: the site sets each amount itself. The Supporter subscription is billed by Stripe every month, from a recurring Price you create in your Stripe Dashboard. Gifted subscriptions charge the same price.

  1. Open the Stripe product catalogue, in the same mode as your keys, and choose Add product.
  2. Name it (for example "Supporter"), choose Recurring, billing period Monthly, and set your amount and currency. Save.
  3. Open the price and copy its id. It starts with price_ (not prod_, which is the product's id).
  4. Paste it into Supporter subscription price: on the setup page, the optional step The supporter subscription's price; later, Admin Panel → Payments → Connections, card Stripe.
  5. On the setup page, press Check. It asks Stripe whether the price exists, is active, is recurring and bills every month, and shows the amount it found, for example found: $5.00 a month (test).

The site reads the amount and currency from Stripe and shows them to viewers. To change the amount later, make a new price in Stripe and paste its id here. With the setting empty, card subscriptions and gifted subscriptions stay off, tips and points work as usual, and a PayPal plan (if you set one) still sells the subscription.

Manage subscription opens Stripe's customer portal. In live mode, Stripe needs you to save its portal settings once before the portal opens for anyone: in the Stripe Dashboard, open the customer portal settings, choose what subscribers may do (update their card, cancel), and save. Stripe explains it in the customer portal docs.

A viewer becomes a Supporter through a Stripe subscription, a gifted subscription, or a PayPal subscription (see PayPal and Venmo). Ko-fi, Patreon and Streamlabs send alerts but make nobody a Supporter.

Step 3: if your site is behind Cloudflare

If your front door is the Cloudflare tunnel, every webhook passes through Cloudflare before it reaches your server. Cloudflare's bot protection can take Stripe's automated messages for an attack and block them: the payment happens, but your site never hears about it. The setup page calls this step optional; on the tunnel, check it. In short: on Cloudflare's Free plan, turn Bot Fight Mode off, because no rule can make an exception to it; on Pro or higher, use Super Bot Fight Mode with a skip rule for the path /api/billing/webhook. The step on the setup page and the Doctor's fix line say the same. The full steps are on Cloudflare.

Your site cannot see your Cloudflare settings, so the Doctor's row Stripe gets past Cloudflare's bot protection stays grey, as a reminder to check by hand.

Step 4: one test purchase of each kind

The checks above only read. Nothing writes to Stripe until a viewer starts a payment, so prove the Write permissions once, with test keys and a test-mode webhook:

  1. Open your site signed in to your own account, and with Stripe's test card 4242 4242 4242 4242 (any future expiry date, any three digits) subscribe, tip, buy points, and gift a subscription to a second account.
  2. Open Manage subscription from your account.
  3. Each payment should show a "thank you" message, an alert on stream if your overlays are open, and a line at the top of Admin Panel → Payments → Payment history with a link to the payment in Stripe.
  4. In Stripe, open the webhook destination: the latest deliveries show 200 (accepted).
  5. Open the Doctor. The row Stripe: this site's webhook exists, is enabled and sends every event should be green.

If one of them fails, Stripe's Dashboard → Developers → Logs shows the refused request and the permission it lacked. Add that one permission to the key. Never switch to the full secret key instead.

Before you go live, go through Protect your personal name and home address: these checks prove the connection works, not what a paying viewer sees about you. Then switch to live mode: make a live restricted key, copy the live publishable key, add a live webhook destination with the same URL and events, make a live price, and paste all four over the test values.

Switching card payments off

With the module off there is no card checkout, and Stripe's webhook address on your site answers "not found". Stripe keeps undelivered events and retries them for about three days, so switching back on within that time loses nothing.

🔴 Card subscribers lose their Supporter perks at once while Stripe keeps charging them. Before you switch card payments off for good, cancel their subscriptions in Stripe, or switch the module back on.

When it goes wrong

What you see What it means What to do
rejected on the secret key The key was mistyped, deleted, or belongs to another account Copy it again from Stripe. A restricted key is shown in full only once; if you lost it, make a new one.
"the key cannot read …" The restricted key is missing a Read permission Edit the key in Stripe and set the named permission to Read.
The webhook check finds no destination No destination has exactly your site's address, or it is in the other mode Check the URL ends in /api/billing/webhook, uses your domain, and is in the same mode as your keys.
"the webhook does not send … of the events" The destination does not send all thirteen events Edit the destination in Stripe and add the missing ones.
"the webhook exists but is disabled" Stripe switched the destination off, often after many failed deliveries Fix the cause (usually Cloudflare, step 3), then enable it again in Stripe.
The price check says "Stripe has no price with this id in test mode" (or live) The price and the key are from different modes Make the price in the same mode as the key.
The price check says the key cannot read prices The key lacks Read on Prices Add it to the key in Stripe.
The price check says a one-time price, or "bills every year" The price is not monthly and recurring Make a new Recurring, Monthly price and paste its id.
No Subscribe or Gift button, or Subscribe opens your outside subscribe link No Supporter price is saved, or it cannot be read. (With a PayPal plan set, Subscribe still shows and opens the PayPal subscription; Gift needs the Stripe price.) Set a price (see Subscriptions).
A viewer paid but nothing appeared The webhook did not arrive or was refused Open the destination in Stripe and look at the failed delivery. 400 means the signing secret does not match: reveal it again and paste it. 403 behind Cloudflare means bot protection blocked it. 404 means the card payments module is off.
The card form never appears The publishable key is missing, or the module is off Check the Card payments (Stripe) switch and the publishable key on Admin Panel → Payments → Connections.
Live keys, but only test cards work (or the reverse) The keys and the webhook are from different modes Use keys, webhook and price from the same mode.

Next: PayPal and Venmo

← Connect your platforms