Setup and Work with Stripe for Payments
DO NOT upgrade any Stripe dependencies unless you’re following their official migration guide and understand the breaking changes. Upgrading without proper migration can break your payment processing, webhooks, and billing functionality. The current Stripe version in the boilerplate is tested and stable.
Setting up payment processing is only necessary when you have a working product that’s ready to accept payments. During the initial learning and MVP development phase, you can keep payments disabled in your Titan config. Only set up a company and payment processing if you’re ready to accept payments.
This guide covers working with payments with Stripe in Titan.
Titan comes with a complete Stripe integration that handles payments, subscriptions, and webhooks. All the necessary code is already implemented to process payments and update your database when payment events occur.
Assuming you have the ngrok url running, you can test the authentication flow locally.
Set config.payments.enabled
to true
in config.ts
Install Stripe CLI
When you run the Stripe CLI webhook listener, it will print a webhook signing secret. Copy this value and add it to your .env
file:
Navigate to your pricing page and attempt to make a payment using the Stripe test card details:
When the payment is successful, you should see the event logged in your Stripe CLI and the subscription created in both Stripe and your database.
Switch to Production Stripe mode
a. Login to your Stripe Dashboard
b. In the top-right corner, toggle from ‘Test Mode’ to ‘Live Mode’
c. Create a new product in production or replicate your test products
d. Copy your Production Price ID(s) for your subscriptions/products
e. Copy your Production API Keys:
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
STRIPE_SECRET_KEY
Set up the Production Webhook
a. In your Stripe Dashboard, go to ‘Developers’ > ‘Webhooks’
b. Click ’+ Add Destination’
c. Set the endpoint URL to https://[your-production-domain]/api/payments/webhook
d. Select the following events:
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
checkout.session.completed
invoice.payment_succeeded
invoice.payment_failed
e. Copy the webhook signing secret for your environment variables
Update Environment Variables
Ensure these environment variables are set in your production environment (e.g., Vercel):
Remember, choose recurring subscriptions only when you can consistently deliver ongoing value. Forcing subscriptions when value is one-time will lead to high churn rates.
Free Tier
Pro Plan
Enterprise Plan (if applicable)
Integrate SalesNip if you want to offer AI-powered price negotiations.
ByeDispute / Chargeblast are tools that help you prevent disputes with your customers. They provide a dashboard to monitor your disputes and a set of tools to help you resolve them.
Pricing is simple and transparent. Worth paying for if you’re starting to get disputes. Just setup a few rules and it’ll handle the rest.
Monitor conversion rates and gather user feedback to optimize your pricing strategy. Keep pricing simple at launch to not confuse users. You can always adjust based on market response.
Make sure you’re using the correct Stripe test cards for your testing.
Check the logs in your Stripe CLI output and your application server logs for any error messages.
Never use production Stripe keys in development or test environments. Always use test mode keys for development.