# Stripe

Take payments in the app you build, through your own Stripe account.

Connect your own Stripe account to take payments in the apps you build. Payments go straight to your Stripe account, with your own keys.

The Payments page on the API keys step of the Stripe setup, with the publishable and secret key fields.

## What you can do

- Take one-time payments and subscriptions in your app.
- Give your customers a portal to manage their subscription.
- React to payments with webhooks.
- Query your Stripe data with SQL, next to your own tables.

## Take payments in your app

1. ### Add a database

   Payments run on your project backend, so set up a database first. See [Lyna Cloud](/features/cloud/overview#set-up-a-database).
2. ### Connect your Stripe account

   Open **Settings > Lyna Cloud > Payments** and choose **Configure integration**. Paste your Stripe publishable and secret keys, review the Stripe data, and pick the edge functions to deploy: **Checkout session**, **Payment intent**, **Subscription manager**, **Customer portal** and **Webhook handler**. See [Payments](/features/cloud/payments).
3. ### Build the flow

   Ask the AI, for example: "Add a pricing page with a Buy button that opens Stripe Checkout through the checkout session function, and a thank-you page after payment."
4. ### Test, then go live

   Build with your test keys and Stripe's test cards. When everything works, replace them with your live keys and publish.

> [!WARNING]
>
> **Keep the secret key on the server**
>
> Your Stripe secret key must never be in your app's code. The edge functions read it on the server. See [Secrets](/features/cloud/secrets).

## The edge functions

| Function                 | What it does in your app                                    |
| ------------------------ | ----------------------------------------------------------- |
| **Checkout session**     | Opens a Stripe Checkout page for a purchase.                |
| **Payment intent**       | Starts a payment that your own form completes.              |
| **Subscription manager** | Creates and changes your customers' subscriptions.          |
| **Customer portal**      | Opens the page where a customer manages their subscription. |
| **Webhook handler**      | Receives the events your Stripe account sends.              |

## Query your Stripe data

After setup, your customers, products, prices, subscriptions, invoices, payment intents, charges, balance and events are tables in the `stripe` schema. Query them on the **Query** tab of **Payments**, or join them with your own tables in the [SQL editor](/features/cloud/database#sql-editor).

## Webhooks

To react to payments (for example, to unlock a feature when a subscription starts), deploy the **Webhook handler** function.

1. ### Create the endpoint in Stripe

   In your Stripe Dashboard, create a webhook endpoint that points to the function's invoke URL.
2. ### Paste the signing secret

   Copy the endpoint's signing secret and paste it in the setup.

## Your Lyna plan

Your Lyna plan is billed separately, through a secure checkout. Upgrade, change or cancel your plan, update your card or download invoices in **Settings > Account > Subscription and usage**. See [Subscription and usage](/features/account/subscription-and-usage).

## Related

- [Payments](/features/cloud/payments): The Payments page in detail.
- [Edge functions](/features/cloud/edge-functions): Edit the Stripe functions.
- [Secrets](/features/cloud/secrets): Where your keys belong.
- [Subscription and usage](/features/account/subscription-and-usage): Your Lyna plan and billing.
