Payment Setup
This document provides an overview of setting up payments in your project using Stripe and LemonSqueezy. We'll cover the necessary environment variables, the steps to set up accounts, and where to configure them in your project.
- Stripe
- LemonSqueezy
Stripe Payment Setup
To set up payments using Stripe, follow these steps:
Setup
-
Create a Stripe Account:
- Go to Stripe and sign up for an account.
-
Obtain API Keys:
- In your Stripe Dashboard, navigate to the API section.
- Copy your Publishable Key and Secret Key. You'll need these for the environment variables.
-
Configure Webhooks:
- In the Stripe Dashboard, go to the Webhooks section and create a new endpoint.
- Set the endpoint URL to your webhook handler, e.g.,
https://yourdomain.com/api/stripe/webhook. - Select the events you want to listen to, such as
checkout.session.completed.
-
Add your API keys and webhook secret to
.env.local:- Rename
.env.exampleto.env.localif you haven't already. - Add your Stripe API keys and webhook secret to the environment variables:
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=<your_stripe_publishable_key>
STRIPE_SECRET_KEY=<your_stripe_secret_key>
STRIPE_WEBHOOK_SECRET=<your_stripe_webhook_secret> - Rename
Using Stripe in Your Project
Configure Stripe to handle payments as per the Stripe documentation.
Tip: Regularly test your Stripe integration using test keys and the Stripe CLI to ensure everything is working correctly.
LemonSqueezy Payment Setup
To set up payments using LemonSqueezy, follow these steps:
Setup
-
Create a LemonSqueezy Account:
- Go to LemonSqueezy and sign up for an account.
-
Configure Your Store:
- Set up your store in the LemonSqueezy dashboard with your products and pricing.
-
Obtain Store URL and Webhook Secret:
- In your LemonSqueezy Dashboard, navigate to the Webhooks section.
- Copy your store URL and webhook secret. You'll need these for the environment variables.
-
Add your store URL and webhook secret to
.env.local:- Rename
.env.exampleto.env.localif you haven't already. - Add your LemonSqueezy store URL and webhook secret to the environment variables:
NEXT_PUBLIC_LEMONSQUEEZY_STORE=<your_lemonsqueezy_store_url>
LEMONSQUEEZY_WEBHOOK_SECRET=<your_lemonsqueezy_webhook_secret> - Rename
Using LemonSqueezy in Your Project
No additional code changes are needed in your application. You can link to your store using the environment variable.
Example Link
To create a link to your LemonSqueezy store, use the environment variable:
const storeLink = process.env.NEXT_PUBLIC_LEMONSQUEEZY_STORE;
Tip: Ensure your LemonSqueezy store settings are configured correctly to handle webhooks and payment notifications.
Tip: Regularly check for updates and best practices in the Stripe documentation and the LemonSqueezy documentation to keep your integration secure and efficient.