PySaaS
  • ๐Ÿ‘‹Introduction
  • ๐ŸšงInstallation and Setup
    • ๐Ÿง Installation
    • ๐Ÿ‘ฏUser Authentication - Firebase
    • ๐Ÿ‘ฏUser Authentication - Supabase
    • ๐Ÿ’ฐSubscriptions - Lemon Squeezy
    • ๐Ÿ’ปBlog CMS - Notion
    • ๐Ÿ“ŠGoogle Analytics
    • ๐ŸงชTesting
  • ๐Ÿš—Deployment
    • Hosting Options
    • Generalized Instructions
  • โ‰๏ธTroubleshooting
    • ๐Ÿ”ฅFirebase Setup
    • Firebase - Setting up Custom Domain for Emails
    • Firebase - Customizing Reset Emails
    • ๐Ÿ‹Lemon Squeezy Setup
    • โ†”๏ธNGROK Setup
    • ๐Ÿ’ปNotion Setup
    • โฌ†๏ธUpdating Project from Pynecone to Reflex
Powered by GitBook
On this page
  • Lemon Squeezy Setup
  • Get Your API Key
  • Redirect Setup
  • Product URL
  • Enable Webhooks
  1. Installation and Setup

Subscriptions - Lemon Squeezy

Monetize Your Application with Lemon Squeezy

PreviousUser Authentication - SupabaseNextBlog CMS - Notion

Last updated 1 year ago

Lemon Squeezy Setup

In this section, you'll configure the payment provider used by your app to allow users to subscribe to a plan and manage their billing settings directly in-app.

First, create an account on .

Get Your API Key

You'll need a Lemon Squeezy API key in order to provide customized, pre-filled checkouts and in-app subscription management to your users.

Navigate to Settings > API in the menu bar and click the "+" button to create a new API Key.

Fill in your Lemon Squeezy API environment variable in the .env file.

LM_API_KEY=

Redirect Setup

After your customers subscribe to a plan, you should redirect them back to your app which will show that they are now successfully subscribed to a plan.

To handle the redirect, navigate to Store > Products, and click into the product you've created for your app's subscription. If you haven't created a product yet, you can do so easily by pressing the "+" button.

Lemon Squeezy has recently changed and does not allow you to directly input a redirect URL. This can still be done by specifying a button in the confirmation modal with a link. I would recommend doing something similar to this:

Product URL

Retrieve your product URL from Product Details > Share > Checkout Link and include it in .env:

LM_URL=

Enable Webhooks

To allow users to manage subscription and billing settings directly in your app, Lemon Squeezy has to be able to send webhooks to the backend API route that processes them, which is included in the PySaaS codebase.

If you are having trouble setting up ngrok, please visit the ngrok setup page in the troubleshooting section of the documentation here: NGROK Setup

Lastly, when you create your webhook's signing secret fill in the corresponding environment variable value in your .env file.

LM_SIGNING_SECRET=

For the demo, our redirect link is which will take users back to the dashboard where they're still signed in and can see their updated subscription plan status. For now, for testing purposes, you can put .

To enable this, navigate to Settings > Webhooks and click the "+" button to create a new webhook. Your URL will eventually correspond to your app's domain similar to the redirect setup, but for now, we'll be sending it to . To do this, quickly set up in the middle to put localhost on the internet. For events, we'll be listening for "subscription_created" and "subscription_updated".

๐Ÿšง
๐Ÿ’ฐ
https://demo.pysaas.io/dashboard
http://localhost:3000/dashboard
http://localhost:8000/webhooks/lmsqueezy
ngrok
Lemon Squeezy