---
url: https://docs.sunlicense.com/integrations/stripe.md
---
# Stripe

For selling on your own site with **Payment Links** or **Checkout**. A paid checkout issues a license, and
the success page shows the key straight away.

## Setup

1. SunLicense: **Integrations → Stripe → Connect**. Map products by **Payment Link ID** (`plink_…`) or by
   a `sunlicense_product` value you put in the Checkout Session's `metadata`; or `*`.
2. Stripe **Developers → Webhooks → Add endpoint**: URL = the hook URL. Events:
   `checkout.session.completed`, `checkout.session.async_payment_succeeded`, `charge.refunded`,
   `charge.dispute.created`, `charge.dispute.closed`, `customer.subscription.deleted`.
3. Copy the endpoint's **signing secret** (`whsec_…`) into the integration.
4. Payment Link → **After payment → Don't show confirmation page → redirect** to the redeem URL with
   `?session_id={CHECKOUT_SESSION_ID}` (the integration page shows it ready to copy). For Checkout, use
   the same value as `success_url`.

The buyer lands on the redeem page, which waits a few seconds for the webhook and then shows the key. The
Checkout Session ID is unguessable, so no email is asked.

## Behaviour

| Stripe event | SunLicense does |
|---|---|
| `checkout.session.completed` (paid) / `async_payment_succeeded` | One license per session |
| `charge.refunded` (fully refunded) | Revokes; partial refunds keep the license |
| `charge.dispute.created` | Suspends; `charge.dispute.closed` won → reinstates, lost → revokes |
| `customer.subscription.deleted` | Suspends the subscription's license |

`Stripe-Signature` is verified (HMAC-SHA256, 5-minute tolerance). Test-mode and live-mode endpoints have
different secrets: connect one integration per mode.
