Stripe
Stripe Setup Tutorial
Fast Phoenix integrates seamlessly with Stripe to handle subscriptions and payments. Follow these steps to configure Stripe for your project.
Step 1: Prepare Your Environment Variables
Fast Phoenix uses environment variables to manage Stripe configuration. Open your .env
file and ensure the following variables are set:
Replace the placeholder values with your actual Stripe credentials and product/pricing details.
Step 2: Create Products and Prices in Stripe
Log in to Stripe Dashboard Access your Stripe Dashboard.
Create Two Products
Pro Plan
Name: Pro
Price: $30
Billing: Monthly
Enterprise Plan
Name: Enterprise
Price: $100
Billing: Monthly
Copy Product Price IDs After creating the products, navigate to the pricing details and copy the Price IDs for each product. Replace the
STRIPE_PRO_PRICE_ID
andSTRIPE_ENTERPRISE_PRICE_ID
values in your.env
file with these IDs.
Step 3: Set Up Stripe Webhooks
Stripe uses webhooks to notify your application about important events like successful payments.
Run Your Application Start your local development server:
Install Stripe CLI Download and install the Stripe CLI to set up webhook forwarding.
Forward Events to Your Application Use the Stripe CLI to forward webhook events to your local server:
Copy the generated signing secret and update your
.env
fileβsSTRIPE_SIGNING_SECRET
.Set Up Webhook Endpoint in Stripe For Prod
Navigate to the Webhooks section of the Stripe Dashboard.
Add a new endpoint pointing to
https://your-domain.com/webhooks/stripe
for production.
Step 4: Test Your Setup
Test Subscription Creation Use Stripe's test card numbers (e.g.,
4242 4242 4242 4242
) to simulate subscriptions.
Step 5: Optional - Enable Customer Portal
In the Stripe Dashboard, enable the Customer Portal.
Copy the Customer Portal URL and save it in your
.env
asSTRIPE_PORTAL_ID
.
Extra:
We have written a stripe_helpers.ex module that creates checkout sessions for new subscribers and upgrading/downgrading subscribers, and a request helper function for hitting up Stripe's API. For example:
Your Stripe setup is now complete! You can start accepting payments, managing subscriptions, and leveraging Fast Phoenixβs built-in features to streamline your billing processes. π
Last updated