LogoLogo
v2.0.0
v2.0.0
  • 🌸What is Petal Pro?
  • πŸ’‘Changelog
  • ⏫Upgrade guide
  • Guides
    • πŸš€Creating a web app from start to finish
    • 🌎Deploy to Fly.io
    • πŸ’³Adding a subscription
    • πŸ”’Creating Your Own API
  • πŸ‘©β€πŸ³Recipes
    • πŸ’How to apply a recipe with git cherry pick
    • #️⃣UUIDs
    • ✍️First/Last name
    • πŸ—ΊοΈGoogle Maps
    • Password Hashing for Windows
  • Fundamentals
    • πŸ’ΏInstallation
    • πŸ“‚Folder structure
    • πŸ—ƒοΈIncluded Pages
    • πŸ˜€Users & Authentication
    • 🏒Organizations & Multitenancy
    • πŸ’³Stripe billing
    • πŸ””User Notifications
    • 🧊Components
    • ⬛Dark mode
    • 🎨Branding
    • 🌱Seeding
    • πŸ“„Layouts & Menus
    • πŸ–ΌοΈImage uploads
    • πŸ‘₯Impersonation
    • πŸ› οΈBackground Tasks and Jobs
    • πŸ”§Util & Helpers
    • πŸ“§Emails
    • πŸͺJavascript Hooks
    • πŸ“šExtra Hex Libraries
    • πŸ—οΈGenerators
    • πŸ—£οΈTranslations
    • πŸ–οΈContributing
    • πŸ›«Deployment
    • πŸ›‘οΈTesting
    • πŸ”’REST API
Powered by GitBook
On this page
  • The Stripe schema
  • How our config is used to create checkout sessions

Was this helpful?

  1. Fundamentals

Stripe billing

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

PreviousOrganizations & MultitenancyNextUser Notifications

Was this helpful?

The Stripe schema

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

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:

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.

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
The Stripe schema
In config.exs, you can add your plans