# Payments

Connect Stripe to your backend, query customers, products and subscriptions with SQL, and deploy ready-made Stripe edge functions.

The **Payments** page connects your Stripe account to your project database. Your Stripe data becomes tables you can query, and Lyna can deploy the edge functions your app needs to take payments. Open **Settings > Lyna Cloud > Payments**.

The Payments page after setup, on the Overview tab with the Stripe resources and example queries.

## What you can do

- Save your Stripe keys to the project in one step.
- Read Stripe customers, products, prices, subscriptions, invoices, payment intents, charges, balance and events as tables in a `stripe` schema.
- Join Stripe data with your own tables in SQL.
- Deploy ready-made functions for checkout, payment intents, subscriptions, the customer portal and webhooks.

## Set up Stripe

1. ### API keys

   Choose **Configure integration**. Paste your Stripe **Publishable key** (`pk_live_` or `pk_test_`) and **Secret key** (`sk_live_` or `sk_test_`). Find them in your Stripe Dashboard under Developers, API keys.
2. ### Data

   Review the Stripe resources that will be available as tables. Some can be written to, others are read-only.
3. ### Functions (optional)

   Pick the edge functions to deploy: **Payment intent**, **Checkout session**, **Subscription manager**, **Customer portal** and **Webhook handler**. The webhook handler needs a webhook signing secret from Stripe. You can skip this step and add functions later.
4. ### Let Lyna configure it

   Lyna saves the keys, configures the database wrapper, deploys the functions and writes their URLs. When it is done, the page shows **Connected**.

> [!NOTE]
>
> **Start in test mode**
>
> Use your `pk_test_` and `sk_test_` keys while you build. Switch to live keys only when you are ready to take real payments.

## After setup

| Tab          | What it shows                                                                                                        |
| ------------ | -------------------------------------------------------------------------------------------------------------------- |
| **Overview** | The Stripe resources (Active or Inactive) and example queries you can copy.                                          |
| **Tables**   | The foreign tables in the `stripe` schema and their columns.                                                         |
| **Query**    | Run read-only SQL on the `stripe` schema, in **Guided** mode (pick a resource, a filter and a limit) or **Raw SQL**. |

## Remove the integration

In **Danger zone**, choose **Remove integration** and type `REMOVE`. This drops the `stripe` schema and the wrapper. Your Stripe keys stay in `.env`: delete them yourself if you no longer need them.

## Good to know

- Payments needs a project database. If Lyna cannot configure your database automatically, the page explains how to set up the Stripe wrapper by hand.
- Only editors can configure payments.
- For the whole payment flow in your app, from test keys to webhooks, see [Stripe](/integrations/stripe).

## Related

- [Stripe](/integrations/stripe): Take payments in your app.
- [Edge functions](/features/cloud/edge-functions): Edit the deployed Stripe functions.
- [Secrets](/features/cloud/secrets): Where keys belong.
