> For the complete documentation index, see [llms.txt](https://docs.petal.build/petal-pro-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.petal.build/petal-pro-documentation/v1.7.0/fundamentals/stripe-billing.md).

# Stripe billing

Easily add payment plans to your web app with our Stripe integration (v1.7.0 onwards).

## The Stripe schema

To help understand subscriptions, it's useful to know how Stripe structures its data.

<figure><img src="https://2959515543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHHjyspJsNlFy25BeBYYU%2Fuploads%2FW7y4N37F0Y5rHm0HCdba%2Fstripe_subscriptions.png?alt=media&amp;token=cda0a5a6-d78a-4360-8fb7-321c88f77bcf" alt=""><figcaption><p>The Stripe schema</p></figcaption></figure>

As we can see, a Subscription comprises several SubscriptionItems, which each match to a Price. This allows you a large amount of flexibility in constructing your subscription plans. Think of a plan in terms of a collection of Prices.

Thus, when you want to define plans for your users to buy, you:

* Create a Product in Stripe
* For that product, you create any number of prices - usually a monthly and yearly price
* You copy the Price IDs and add them to your Petal Pro config as `items`:

<figure><img src="https://2959515543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHHjyspJsNlFy25BeBYYU%2Fuploads%2FCwV8G9eJfcUxD63pq6tK%2FXnapper-2024-01-04-09.37.57.jpg?alt=media&amp;token=dd2acdc9-eaae-44fa-9b99-41a935477a9d" alt=""><figcaption><p>In config.exs, you can add your plans</p></figcaption></figure>

Usually, you will only have one "item" in there. But sometimes you may want to add two - eg. you might have a once-off price as well as a monthly price.

Quantity will also mostly stay the same - 1. If your plans have a number of seats - then `quantitiy` would represent that variable.

The other info in the config is mainly for your front-end UI. The Stripe Prices are the main thing you want to copy across from Stripe.&#x20;

### How our config is used to create checkout sessions

* Explain what a checkout session is, how our items are passed in as line items and how it generates a hosted checkout page Stripe
* Explain how webhooks work and how we use Oban

These docs are a work in progress. Expect more soon! For now follow the ["Adding a subscription" guide](/petal-pro-documentation/v1.7.0/guides/adding-a-subscription.md).
