# Connect Stripe

Configure a restricted API key, webhook and API version, verify and activate credentials, and complete a test purchase.

Last updated: 2026-11-06

[Web version](https://www.longplayai.com/docs/guides/stripe)

<a id="scope"></a>

## 1. Choose execution and environment

Use this guide for Longplay runs payments: Longplay executes payments with your Stripe API key and verifies Stripe webhooks to update billing and entitlements. You need Owner/Admin access to the target App and configuration access to the matching Stripe account. Complete Sandbox first, then configure Live separately.

- Open Integrations → Payment connections → Stripe in Console, select the target App and Sandbox, and confirm How payments run is Longplay runs payments.
- In Stripe, select the account and sandbox/test mode for this integration and record its acct_… ID. Live uses its own account identity, rk_live_… key, endpoint and signing secret; do not assume Sandbox and Live have the same acct_… ID.
- Sandbox is an App business environment and does not switch API deployments. Copy the webhook URL shown in the current Console; a production-hosted App uses the same API host with different environment paths for Sandbox and Live.

> If your backend already executes payments, choose Merchant records billing results (record_only) and follow the merchant execution guide; that mode does not require Stripe credentials in Longplay.

- [Open Stripe payment connections](https://console.longplayai.com/workspace/payment-connections/stripe)
- [Environments](https://www.longplayai.com/docs/guides/environments.md#scope)
- [Merchant execution](https://www.longplayai.com/docs/guides/merchant-execution.md)

<a id="api-key"></a>

## 2. Create a restricted API key

- On Stripe's API keys page, confirm the account and test/Live mode, click Create restricted key and use a dedicated name for this App/environment.
- Start with None and grant the Read/Write permissions your flows need from the table below. Write includes Read; unused conditional capabilities can remain None. Include dependencies required by Stripe's permission editor.
- Save rk_test_… for Sandbox or rk_live_… for Live and hand it privately to the authorized configurator. The API key calls Stripe's API; the webhook's whsec_… verifies notification signatures. They are not interchangeable. A Longplay Server Key is a separate credential for your backend's Longplay SDK calls.

- [Stripe: create restricted API keys](https://docs.stripe.com/keys/restricted-api-keys)

<a id="permissions"></a>

## API key permissions and purpose

**Grant permissions for enabled flows**

| Stripe resource | Access | When needed |
| --- | --- | --- |
| Account | Read | Verify account identity during activation. |
| Webhook Endpoints | Read | Verify endpoint ID, URL, mode, version and events. |
| Customers | Write | Create and update payers. |
| Products / Prices | Write | Synchronize managed products and prices. |
| Checkout Sessions | Write | Create, read and expire Checkout Sessions. |
| Invoices | Write | Managed invoicing, collection, auto top-up and invoice operations. |
| Subscriptions | Write | Recurring purchases, trials, changes and cancellation, including cancellation after refunds. |
| Subscription Schedules | Write | Schedule changes effective at renewal. |
| Invoice Items | Write | Invoice-item and usage-billing flows. |
| Coupons | Write | Create and apply managed discounts. |
| Charges | Read | Inspect original payments for refunds. |
| Refunds | Write | Execute and reconcile refunds. |
| Payment Intents | Read; Write for receipt sending | Reconcile payments; updating receipt_email needs Write. |
| Setup Intents / Payment Methods | Read | Verify saved-payment-method setup and readiness for later charges. |
| Promotion Codes / Tax Rates | Read | Quote existing promotion codes or explicit tax rates. |
| Credit Notes | Read | Read credit notes or check that read capability when needed. |

Webhook Endpoints Read is sufficient for the runtime key to verify an existing endpoint. Provisioning an endpoint through Stripe's API separately needs Webhook Endpoints Write; this does not require widening the runtime key or granting an unrestricted sk_… key, Payouts or Transfers.

<a id="activate-api"></a>

## 3. Save and activate the API key

- In the Stripe payment connection, click Verify sign-in and verify with your current Longplay password or linked Google account. Complete sensitive operations within ten minutes. An existing login or management grant does not replace recent identity verification.
- Choose API Key and enter acct_…, the matching rk_… and Purchase return URL; click Update credentials first when updating an existing connection. Use the deployed site's exact HTTPS return page; HTTP localhost/127.0.0.1 is for local development only. The return URL is not the webhook URL.
- Click Encrypt and save Stripe credential. This creates a Pending verification/staged candidate and does not activate it.
- Click Verify and activate on that candidate. Longplay reads the Stripe account and activates the API key after checking its account and environment. Confirm the API Key shows Active before configuring the webhook.

> API-key activation proves account identity and environment matching only. The separate capability check reports resource read permissions; a missing unrelated read permission does not block API-key activation. Write permissions, signed delivery and actual purchases require separate verification.

<a id="webhook"></a>

## 4. Configure the Stripe webhook

- Expand Key permissions and webhook requirements for this connection and copy its complete receiver URL, recommended API version and event list, then check the supported versions below. The URL has the form `https://<API_HOST>/api/webhooks/stripe/<ENVIRONMENT_UUID>`; use the displayed value rather than constructing it from the App UUID or return page.
- In Stripe Workbench → Webhooks for the matching account and mode, create an event destination, choose Your account and Snapshot, enter that URL and select a supported API version; prefer Console's recommended version for new endpoints.
- Explicitly subscribe to the events below and enable the endpoint. The hosted integration verifies a standard we_… endpoint; Thin events, Connect events from other accounts or payment_intent.succeeded alone are not equivalent configurations.
- Record we_…, exact URL, mode, API version and events. Reveal that endpoint's signing secret (whsec_…) and save it privately for the next step; keep API keys and signing secrets out of frontend code, Git, issues and logs.

- [Stripe: create a webhook endpoint](https://docs.stripe.com/api/webhook_endpoints/create)

<a id="events"></a>

## Required webhook events

The connection checks each of these 29 events. Select the explicit names rather than relying on All events/*; extra events do not replace missing required ones.

**enabled_events**

```json
[
  "checkout.session.completed",
  "checkout.session.expired",
  "checkout.session.async_payment_succeeded",
  "checkout.session.async_payment_failed",
  "payment_intent.succeeded",
  "charge.refunded",
  "refund.created",
  "refund.updated",
  "refund.failed",
  "charge.dispute.created",
  "charge.dispute.updated",
  "charge.dispute.closed",
  "customer.discount.created",
  "customer.discount.updated",
  "customer.subscription.created",
  "customer.subscription.updated",
  "customer.subscription.deleted",
  "customer.subscription.paused",
  "customer.subscription.resumed",
  "customer.subscription.pending_update_expired",
  "customer.subscription.pending_update_applied",
  "invoice.created",
  "invoice.paid",
  "invoice.finalized",
  "invoice.updated",
  "invoice.voided",
  "invoice.marked_uncollectible",
  "invoice.payment_failed",
  "invoice.payment_action_required"
]
```

<a id="versions"></a>

## API version requirements

**Supported Snapshot event versions**

| api_version |
| --- |
| `2026-08-26.dahlia` |
| `2026-10-28.endive` |

- The current validator requires endpoint.api_version to exactly match a supported version above. Both Dahlia and the listed Endive version are accepted; an existing compatible endpoint need not be replaced to match Console's recommendation. Unlisted versions, including other dates in the same release family, and null/account-default versions do not automatically pass. Confirm the target deployment supports the chosen version.
- For a new endpoint, if Dashboard cannot select a supported version, have an authorized administrator use Stripe's create-endpoint API with explicit api_version, url and the complete enabled_events. The runtime key still needs only Webhook Endpoints Read.
- If an existing endpoint uses an unsupported version, retain it and contact the integration maintainer to agree compatibility work and any migration. Do not replace or downgrade it to bypass validation, or merely remove the version comparison. Supporting another version requires checking event fields, parsing and business outcomes before adaptation, verification and activation.
- Stripe API-request and webhook Snapshot versions are separate settings; upgrading your application's Longplay SDK does not change Stripe endpoint payloads. Basic integration does not require another webhook API-version field in your database, but the receiver must support the actual event format. Signing-secret rotation versions are separate.

- [Stripe: webhook versioning](https://docs.stripe.com/webhooks/versioning)

<a id="activate-webhook"></a>

## 5. Save and activate the signing secret

- Return to the same App/environment's Stripe connection and confirm the API key is Active. Repeat Verify sign-in if needed, choose Webhook secret, check the bound acct_… and enter the endpoint's we_…, full URL and whsec_….
- First Encrypt and save Stripe credential, then click Verify and activate on that candidate. Longplay uses the active API key to retrieve the endpoint and checks mode, exact URL, enabled status, API version and required events before activating the signing secret.
- Read the connection again and confirm both API Key and Webhook are Active and the connection is no longer pending. After a failed save, refresh to check whether a candidate exists; a locally saved secret, staged state or active API key does not mean the webhook is active.

> Local Stripe CLI forwarding is Sandbox-only: choose Local forwarding and use the whsec_… printed by stripe listen, without a Dashboard endpoint ID/URL. That secret is not interchangeable with a hosted endpoint's secret. When the endpoint was not checked, a subsequent real signed event is required to verify delivery. Use the hosted-endpoint steps above for deployed sites.

<a id="verify"></a>

## 6. Verify signed delivery and purchases

- Run the connection's capability check and inspect the reads needed by your enabled flows. Passing reads does not prove Write permissions; verify writes through the corresponding Sandbox business operations.
- Create and save a Product, then publish an Offering Version in the same App/environment. Follow previewAttach → attach in the purchase guide, retain the original requestId/operationId and complete an actual test purchase with a Stripe test card.
- Confirm successful delivery to the correct endpoint in Stripe's delivery records, and inspect signature verification and processing in Longplay's Stripe notification records. HTTP 2xx, an endpoint-read check or a return-page redirect alone does not prove payment fulfilment.
- Call readSubscriptionOperation with the original operationId, confirm complete and readHoldings/balances to confirm entitlements. Resend the same Stripe event and read the original operation to confirm no duplicate purchase or entitlement/credit grant; cancellation, failure and expiry must not grant access.
- After Sandbox passes, independently repeat account matching, key permissions, webhook, signing secret, return URL and activation for Live. Plan and authorize real charges separately; passing Sandbox does not activate Live.

> This webhook flows from Stripe to Longplay. The merchant notification guide covers Longplay to your backend with a separate signing key; it does not replace Stripe webhook setup.

- [Start a purchase](https://www.longplayai.com/docs/guides/commerce.md#purchase)
- [Stripe test cards and purchase results](https://www.longplayai.com/docs/guides/testing.md#payments)
- [Notifications and webhooks](https://www.longplayai.com/docs/guides/notifications.md)

<a id="troubleshooting"></a>

## Troubleshoot saving, verification and delivery

**Check the failing stage**

| Symptom | Action |
| --- | --- |
| Saving or activation returns 403 | First check App management permission and identity verification within ten minutes. Version, mode or URL validation can also return 403; if a candidate was saved, inspect endpoint requirements next. Do not attribute every 403 to versioning. |
| Stripe reads return 401/403 | Check the key's account, test/Live mode, validity and the read permissions used by the request, such as Account/Webhook Endpoints. |
| Webhook verification fails | Compare account, mode, exact URL, enabled status, API version and every required event; confirm the API key is active. |
| Configuration conflict/409 | Refresh and read current state. An account bound to another App, endpoint replacement or overlapping rotation needs review; do not repeatedly create connections. |
| Active but no delivery, or signature verification fails | Check that the Stripe endpoint is enabled and reachable, subscriptions match and whsec_… belongs to this endpoint/mode. A hosted endpoint cannot use the CLI forwarding secret. |
| Purchase remains pending after return | Keep the original requestId/operationId, inspect Stripe delivery and Longplay processing, then read the original operation; do not create another purchase or grant credits from the return page. |
| Server encryption is not configured | Ask the deployment administrator to configure credential encryption; do not use frontend or plaintext storage instead. |
