Testing payments locally
Assuming you have the ngrok url running, you can test the authentication flow locally.
-
Set
config.payments.enabledtotrueinconfig.ts - Install Stripe CLI
- Login to Stripe
- Listen for webhooks
- Copy the webhook secret
.env file:
- Run your app
- Test the payment flow
- Card number: 4242 4242 4242 4242
- Expiry date: Any future date
- CVC: Any 3 digits
- Postal code: Any 5 digits
Configuring payments in production
-
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_KEYSTRIPE_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/webhookd. Select the following events:customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedcheckout.session.completedinvoice.payment_succeededinvoice.payment_failed
-
Update Environment Variables
Ensure these environment variables are set in your production environment (e.g., Vercel):
Devising Your Pricing Strategy (In the Future)
Plan Structure - The simpler the better
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
- Start with a simple free plan to attract users
- Include basic but valuable features
- Use as lead generation for premium plans
-
Pro Plan
- Position as recommended option with visual cues
- Price competitively ($29-99/month range)
- Target growing teams/businesses, for example
- Include most-requested features
-
Enterprise Plan (if applicable)
- Custom solutions and premium support
- Use “Contact Sales” CTA
- Focus on scalability features
Add Negotiation Features
Integrate SalesNip if you want to offer AI-powered price negotiations.Prevent Disputes
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.
Common Issues & Troubleshooting
Test cards aren’t working locally
Make sure you’re using the correct Stripe test cards for your testing.Webhooks aren’t being received
- Verify your ngrok URL is correct and the tunnel is active
- Ensure the webhook endpoint in Stripe matches exactly your application’s endpoint path
- Check your STRIPE_WEBHOOK_SECRET is correctly set in your .env file
Payment succeeded but subscription not created
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.