Skip to Content
Stripe integrationConnecting Stripe

Connecting Stripe

LicenseManager connects to your Stripe account with a restricted API key: a key you create in Stripe, which can only do what you allow it to. It needs four permissions, a fifth one to sell subscriptions, and three optional ones, to refund canceled licenses, cancel subscriptions and open the Stripe customer portal, all explained below. Every other one stays on None.

The connection belongs to your organization, not to a product: once connected, every product of the organization can map prices of that Stripe account. You manage it from the Integrations page of any product.

Live mode and test mode

Stripe keeps live and test mode apart, and so does LicenseManager:

  • Your live products use a live mode key, starting with rk_live_. Only real payments create licenses.
  • Your test products use a test mode key, starting with rk_test_. Only test payments create licenses, which are test licenses.

They are two separate connections. Connect Stripe from a live product to sell for real, and from a test product to try the integration with Stripe’s test cards . They can even be two different Stripe accounts, or a sandbox .

We recommend connecting test mode first, mapping a test price and paying it with a test card, to see the whole flow before selling for real.

Connect your account

Open the Integrations page

In LicenseManager, open a product: a live one to connect live mode, a test one to connect test mode. Click Integrations in the sidebar, then Connect Stripe.

Screenshot connect strip button

The dialog lists the permissions the key needs, with a link to the right page of your Stripe dashboard. Keep it open.

Create a restricted key in Stripe

Open the API keys page  of your Stripe dashboard, in the mode you are connecting: for test mode, turn on Test mode or use the test API keys page .

Click Create restricted key.

Stripe screenshot creating restricted api key

When Stripe asks you how you will be using the key, select Providing this key to a third party application.

Stripe screenshot step1 creating key

Give it a name and check Customize permissions for this key.

Stripe screenshot step2 creating key

Set its permissions

Set these permissions, and leave every other one on None:

ResourceAccess
Checkout SessionsReadRequired
PricesReadRequired
ProductsReadRequired
SubscriptionsReadRequired to sell subscriptions
SubscriptionsWriteOptional
Customer portalWriteOptional
RefundsWriteOptional
Webhook EndpointsWriteRequired

Stripe groups the resources by category: Checkout Sessions is under Checkout, Prices and Products under Core or Products depending on your dashboard, Subscriptions and Customer portal under Billing, Refunds under Core, and Webhook Endpoints under Webhook. Use the search box of the page to find them.

  • Subscriptions: Read is only needed to sell subscriptions. It’s checked once you map a recurring price, and every day from then on.
  • Subscriptions: Write is only needed to cancel the subscription of the subscription licenses you cancel from LicenseManager. Without it, cancel subscriptions from Stripe.
  • Customer portal: Write is only needed to open the Stripe customer portal from the customer portal, where customers manage their subscriptions.
  • Refunds is only needed to refund canceled licenses automatically. Without it, the key connects, refunds are turned off, and you refund the payments from Stripe yourself.

Copy the key

Click Create key. Stripe shows the key, starting with rk_live_ or rk_test_: copy it.

Depending on your account settings, Stripe shows the key only once. If you lose it, create a new one: you can replace the key at any time.

Paste it in LicenseManager

Back in the Connect Stripe dialog, paste the key and click Connect Stripe.

Screenshot add key

LicenseManager then:

  1. Checks the key is a Stripe key, of the right mode.
  2. Checks Stripe accepts it, and that it has every read permission, Subscriptions: Read included once a recurring price is mapped. When some are missing, the error lists them all, so you fix them in one go.
  3. Creates the webhook on your Stripe account, which checks the Webhook Endpoints permission.
  4. Checks whether it has the optional Refunds, Subscriptions: Write and Customer portal: Write permissions. When it doesn’t, what they’re for is turned off, and the Refunds and Subscriptions cards of the Integrations page show a warning.
  5. Reads your account’s name, to show it.
  6. Stores the key, encrypted.

Stripe is connected. Next, map your prices to policies: until you do, payments don’t create anything.

Permissions

Here is exactly what LicenseManager does with each permission. It never uses any other part of the Stripe API.

Checkout Sessions: Read

When Stripe notifies LicenseManager that a checkout was paid, the notification doesn’t include what was bought. LicenseManager reads the checkout’s line items, the prices and quantities, to know which licenses to create and how many.

It only reads the checkouts Stripe notifies it of, never lists your past checkouts, and doesn’t read the payment details, like card numbers, which aren’t part of a checkout anyway. When connecting, it lists one checkout only to check the permission is there.

Prices: Read

LicenseManager lists your prices when you create a mapping, so you pick one instead of copying its id, and reads the price you picked to check it can be paid: active, not metered, of an active product. Without it, it couldn’t tell you a price was archived.

Products: Read

Shows the names of your Stripe products next to their prices, in the price picker and the mappings table. Prices only have an amount and an optional nickname: the product’s name is what tells them apart.

Subscriptions: Read

When Stripe notifies LicenseManager of a change to a subscription, or of one of its invoices, LicenseManager reads the subscription: its status, price, quantity and period, to keep its license in line. Reading it rather than trusting the notification means events arriving late or out of order never undo a newer change.

It only reads the subscriptions Stripe notifies it of, and lists one only to check the permission is there. It’s only checked once you map a recurring price: sellers of one-time prices don’t need it. Without it, mapping a recurring price is refused, and once one is mapped, the integration is in Error.

Subscriptions: Write (optional)

When you cancel a subscription license from LicenseManager, its Stripe subscription is canceled, immediately and without proration. It’s the only change made to subscriptions: LicenseManager never creates, updates or resumes one.

When connecting, and during the daily check, it checks the permission by updating a subscription that doesn’t exist: Stripe checks the permission first, so nothing changes. Without it, LicenseManager refuses to cancel subscription licenses: cancel their subscriptions from Stripe, and the licenses expire.

Customer portal: Write (optional)

When a customer clicks Manage subscription in the customer portal, LicenseManager creates a Stripe customer portal  session for their Stripe customer, and sends them to it. What they can do there is set by your customer portal settings  in Stripe.

It’s checked like the other optional permissions, by opening a session for a customer that doesn’t exist. Without it, the Manage subscription button of the customer portal tells customers their subscription can’t be opened: they manage it through the emails and links Stripe sends them.

Refunds: Write (optional)

When a customer cancels a license during the money back guarantee of its policy, LicenseManager refunds its payment: the license’s price, taxes included. It only refunds the payments of the licenses canceled, never anything else, and you can turn automatic refunds off from the Refunds card of the Integrations page.

When connecting, and during the daily check, it checks the permission by asking to refund a payment that doesn’t exist: Stripe checks the permission first, so nothing is refunded.

Without it, the key still connects: refunds are turned off, and the Refunds card warns you that canceled licenses aren’t refunded. Refund their payments from Stripe yourself. To turn refunds on later, give the key the permission in Stripe, then click Check now.

Webhook Endpoints: Write

The only required write permission. It’s used to:

  • Create the webhook when you connect, pointing to LicenseManager, so Stripe notifies it of payments. It’s named LicenseManager: creates licenses from payments.
  • Keep it working: the daily check points it at LicenseManager again with the right events, turns it back on if Stripe disabled it, and creates it again if it was deleted.
  • Delete it when you disconnect, so Stripe stops sending events nobody listens to.

Write access to webhook endpoints lets the key change any webhook of your account, but LicenseManager only touches the one it created.

The webhook listens to these events only:

EventWhy
checkout.session.completedA checkout was completed: creates the licenses, if it’s paid.
checkout.session.async_payment_succeededA delayed payment of a checkout succeeded: creates the licenses.
invoice.paidA subscription was paid: creates its license on the first invoice, renews it on the next ones, and records the payment.
invoice.payment_failedA subscription payment failed: records it, the license staying valid for the grace period.
customer.subscription.created, customer.subscription.updatedA subscription changed: follows its plan, quantity, period and cancellation.
customer.subscription.deletedA subscription ended: expires its license.
customer.subscription.paused, customer.subscription.resumedA subscription was paused or resumed: expires its license, or follows it again.
price.updatedFlags a mapping whose price was archived, and clears it when the price is active again.
price.deletedFlags a mapping whose price was deleted.
product.updatedFlags the mappings of a product that was archived, and clears them when it’s active again.
product.deletedFlags the mappings of a product that was deleted.

Integrations connected before subscriptions were supported get the subscription events added by the next daily check, or right away with Check now.

Why not a secret key?

A secret key (sk_live_…) works too, and LicenseManager accepts it, but it gives full access to your Stripe account: charging customers, refunding, reading everything. If it leaked, anyone could use it. A restricted key with these permissions limits what anyone holding it can do, so we strongly recommend it.

The Stripe card

Screenshot stripe card

Once connected, the Stripe card of the Integrations page shows:

  • Status: Active when everything works, Error when something needs fixing, Disconnected when Stripe rejects the key. See statuses.
  • Account: the name of your Stripe account, or Unknown when the key can’t read it, which is expected for a restricted key without account permissions and changes nothing.
  • API key: the start and end of the key, like rk_live_…Ab3d, to recognize it in your Stripe dashboard.
  • Webhook: the URL Stripe sends the events to.
  • Last checked: the last health check.
  • Last event: the last time Stripe sent an event. None yet until the first one.

The Refunds card

Below the Stripe card, the Refunds card has the Refund canceled licenses automatically checkbox, checked by default: canceling a license bought through Stripe refunds its price, taxes included. Uncheck it to refund the payments from Stripe yourself. See automatic refunds.

When the API key lacks the optional Refunds: Write permission, the checkbox is disabled and the card warns that Refunds are turned off.

Subscription payments are never refunded: the setting only applies to licenses sold once.

The Subscriptions card

Once a recurring price is mapped, the Subscriptions card shows:

  • Grace period, in days: how long a subscription license stays valid after its period ends while its renewal is unpaid, as Stripe retries the payment. 7 by default, from 0 to 60. It applies to every product of the organization in the same mode.
  • A warning when the key lacks Customer portal: Write: the customer portal can’t open the Stripe customer portal.
  • A warning when the key lacks Subscriptions: Write: subscription licenses can’t be canceled from LicenseManager.

Health checks

Every day, LicenseManager checks each integration: that Stripe still accepts the key, that it has the read permissions, Subscriptions: Read included once a recurring price is mapped, that it can still manage the webhook, and which optional permissions it has. A key that lost an optional permission turns off what it’s for, like refunds, without putting the integration in Error; a key that was given it turns it back on. The check also repairs the webhook: when it was deleted from the Stripe dashboard it’s created again, when it was disabled it’s turned back on, and its URL and events are set back.

Click Check now to run it right away, for example after fixing a permission.

Screenshot check now

When a check finds a new problem, the owners and admins of the organization are emailed what’s wrong and how to fix it. The same problem isn’t emailed again every day.

Stripe error

Statuses

StatusMeaningWhat to do
ActiveEverything works.Nothing.
ErrorSomething needs fixing, explained on the card. Usually a permission removed from the key, a mapped price archived in Stripe, or a payment that couldn’t be turned into licenses.Read the reason, fix it, then click Check now.
DisconnectedStripe rejects the key: it was revoked, expired or deleted.Replace the API key.

When a price mapping is flagged, the integration shows Error too, with the mapping’s reason. It goes back to Active once the mapping is fixed or deleted.

While the integration is in Error or Disconnected, customers can still pay in Stripe without getting a license. See when the integration breaks.

Replace the API key

To rotate the key, add a permission, or recover from a Disconnected status, click Replace API key on the Stripe card, and follow the same steps as connecting with a new key.

  • With a key of the same Stripe account, the webhook and the mappings are kept: nothing else changes. Revoke the old key in Stripe afterwards.
  • With a key of another Stripe account, a webhook is created on the new account and the old account’s one is deleted when its key still works. The mappings are kept, but they point to prices of the old account, which the new one doesn’t sell: delete them and map the new account’s prices. To switch accounts, disconnecting first is clearer.

Disconnect Stripe

Click Disconnect on the Stripe card. LicenseManager:

  1. Deletes the webhook from your Stripe account. When the key no longer works, or the webhook is already gone, this step is skipped. When the key works but lacks the Webhook Endpoints: Write permission, disconnecting fails: give it back the permission, or delete the webhook yourself in Stripe, then try again.
  2. Deletes the connection and all its price mappings, for every product of the organization in that mode.

The licenses it created stay, with their customers. Payments no longer create licenses.

Then revoke the API key in your Stripe dashboard: LicenseManager no longer has it, but it’s still valid in Stripe until you do.

Troubleshooting

“This isn’t a Stripe secret or restricted key”: you pasted something else, like a publishable key (pk_…). Copy the restricted key, starting with rk_.

“This is a test mode key: live products need a live mode key”, or the opposite: you’re connecting from a live product with a test key. Create the key in the other mode, or connect from a test product.

“Stripe rejected the API key: it’s invalid, expired or revoked”: the key was mistyped, revoked, or expired. Create a new one.

“The API key lacks these permissions: …”: edit the key in Stripe to give it the listed permissions, and try again. You can edit a restricted key’s permissions without creating a new one.

“The API key can’t manage webhook endpoints”: the key lacks Webhook Endpoints: Write. Give it the permission, and try again.

“The API key lacks these permissions: Subscriptions: Read”, when mapping a recurring price: give the key the permission in Stripe, then map the price again.

“No link to the Stripe customer portal” or “Subscription licenses can’t be canceled here”, on the Subscriptions card: the key lacks the optional Customer portal: Write or Subscriptions: Write permission. Give it in Stripe, then click Check now.

“Refunds are turned off”, on the Refunds card: the key lacks the optional Refunds: Write permission, so canceled licenses aren’t refunded. Give it the permission in Stripe, then click Check now, or refund the payments from Stripe yourself.

“Stripe couldn’t be reached”: Stripe was unreachable or answered with an error. Try again in a few minutes.