Paddle Integration Overview
PreLaunch comes with built-in integration for the Paddle payment system, allowing you to easily process payments and manage user subscriptions. Paddle offers a powerful billing system with support for global payments and subscription management.
Features
- Support for one-time payments and subscription plans
- Built-in checkout flow
- Sandbox testing environment
- Webhook integration for automatic subscription status updates
- Customer account management
- Support for multiple currencies
Prerequisites
Before using the Paddle integration, you need to:- Create a Paddle account
- Create products and pricing plans in the Paddle dashboard
- Obtain API keys and client tokens
Environment Setup
Set Environment Variables
Add the following environment variables to your.env.local
file:
Get Paddle Credentials
- Log in to your Paddle Dashboard
- Navigate to Developer Tools > Authentication
- Copy your API Key
- Get your Client Token - create one in Developer Tools > Clients
Product Configuration
Set Up Products in Paddle
- Navigate to Catalog > Products in the Paddle dashboard
- Click Create Product
- Fill in the product details and save
- Create product prices (at least one price per product)
- Note down the product ID and price ID
Update PreLaunch Configuration
In theconfig.ts
file, update the configuration using the product and price IDs you created in Paddle:
Using Paddle Checkout
PreLaunch provides two ways to use Paddle checkout:1. Using the Pre-built Checkout Button
The simplest method is to use the built-inButtonCheckout
component:
2. Using the Paddle.js API
If you need more customization options, you can directly use the Paddle.js API:Webhook Setup
To handle Paddle events (such as successful payments, subscription status changes, etc.), you need to set up a webhook:- Navigate to Developer Tools > Webhooks in the Paddle dashboard
- Create a new webhook endpoint with the URL:
https://yourdomain.com/api/paddle/webhook
- Select the events you want to receive (at minimum:
subscription.activated
,subscription.cancelled
,payment.succeeded
) - Copy the generated webhook secret to your
.env.local
file:PADDLE_NOTIFICATION_WEBHOOK_SECRET
Customer Account Management
PreLaunch includes a customer account management component that allows users to view and manage their subscriptions:Local Development Notes
In your local development environment:- Set
PADDLE_SANDBOX=true
in your.env.local
file - Use product and price IDs created in the Paddle sandbox environment
- Note that webhooks need a publicly accessible URL; you can use tools like ngrok to create a temporary public URL for testing webhooks
Troubleshooting
Checkout button not displaying or not working
Checkout button not displaying or not working
Webhook not receiving events
Webhook not receiving events
Check the following:
- Is the webhook URL publicly accessible?
- Is
PADDLE_NOTIFICATION_WEBHOOK_SECRET
correctly set? - Check the webhook logs in the Paddle dashboard for failure records
Subscription status not updating
Subscription status not updating
Confirm the following:
- Is the webhook correctly set up and receiving events?
- Is the database connection working?
- Check server logs for errors
Production Deployment
When you’re ready to deploy to production:- Create production environment products and pricing plans in Paddle
- Update environment variables, set
PADDLE_SANDBOX=false
- Use production environment API keys and client tokens
- Update the webhook URL to point to your production domain