Overview
Stripe is TelemanAI’s recommended payment gateway for global subscription billing. It supports:- Credit and debit card payments
- 135+ currencies
- Strong authentication (3D Secure)
- Automatic invoice generation
- Subscription management
- Webhook notifications
Prerequisites
- A Stripe account (Sign up here)
- Business verification completed (for production)
- Bank account connected for payouts
Setup Instructions
Create Stripe Account
- Visit Stripe Dashboard
- Sign up with your business email
- Complete business verification
- Add bank account for payouts
Get API Keys
- Log in to Stripe Dashboard
- Click Developers → API keys
- You’ll see two types of keys:
- Publishable key:
pk_test_... - Secret key:
sk_test_...
- Publishable key:
pk_live_... - Secret key:
sk_live_...
Configure Environment Variables
Add Stripe credentials to your For Production (Live Mode):
.env file:For Testing (Sandbox Mode):Start with sandbox mode during development and testing.
Testing the Integration
Use Test Cards
Stripe provides test card numbers for different scenarios:Successful Payment:Payment Declined:Insufficient Funds:Full list of test cards
Make a Test Purchase
- Go to TelemanAI pricing page
- Select a subscription plan
- Click Subscribe Now
- Fill in billing information
- Enter test card number:
4242 4242 4242 4242 - Complete the purchase
- Verify subscription is activated
Webhook Configuration
Webhooks notify TelemanAI about payment events:Create Webhook Endpoint
- In Stripe Dashboard, go to Developers → Webhooks
- Click Add endpoint
- Enter your endpoint URL:
- Select events to listen for:
payment_intent.succeededpayment_intent.payment_failedcharge.refundedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deleted
Get Webhook Secret
After creating the webhook:
- Click on the webhook endpoint
- Click Reveal under “Signing secret”
- Copy the secret (starts with
whsec_...) - Add to your
.envfile:
Payment Flow
Understand how payments are processed:Implementation Details
Stripe Controller
SeeStripeController.php for implementation:
Key Methods:
| Method | Description | Line Reference |
|---|---|---|
index() | Display Stripe setup page | 20-23 |
update() | Save Stripe configuration | 26-46 |
stripe() | Display payment form | 51-60 |
stripePost() | Process payment | 63-164 |
Payment Processing Logic
StripeController.php (lines 75-114)
Stripe Gateway Service
StripeGateway.php (lines 11-31)
Supported Currencies
Stripe supports 135+ currencies. Common ones:- USD - US Dollar
- EUR - Euro
- GBP - British Pound
- CAD - Canadian Dollar
- AUD - Australian Dollar
- INR - Indian Rupee
- JPY - Japanese Yen
- SGD - Singapore Dollar
To change the currency, update the
currency parameter in the charge creation.Invoice Generation
TelemanAI automatically generates PDF invoices:StripeController.php (lines 128-138)
Test vs Production Mode
Sandbox Mode (Testing)
- Uses test API keys
- No real money charged
- Test cards accepted
- Separate dashboard data
- Webhooks can use localhost with Stripe CLI
Production Mode (Live)
- Business verification complete
- Bank account connected
- HTTPS enabled (required)
- Public webhook endpoint
- Terms of service acceptance
Security Best Practices
Troubleshooting
Invalid API Key Error
Invalid API Key Error
Problem:
Invalid API Key provided: sk_test_...Solution:- Verify the secret key is correct (no extra spaces)
- Ensure you’re using the right key for the environment
- Check that
.envfile is properly loaded - Clear config cache:
php artisan config:clear
Payment Succeeds but Subscription Not Activated
Payment Succeeds but Subscription Not Activated
Problem: Charge successful in Stripe but user subscription inactiveSolution:
- Check webhook is configured and receiving events
- Verify webhook secret is correct
- Review TelemanAI logs for errors
- Check database
payment_historiesandsubscriptionstables - Manually trigger webhook from Stripe Dashboard
Test Card Declined
Test Card Declined
Problem: Test card
4242 4242 4242 4242 is declinedSolution:- Ensure you’re in test mode:
STRIPE_ENVIRONMENT="sandbox" - Use test keys (starting with
pk_test_andsk_test_) - Check you entered a future expiry date
- Verify CVV is 3 digits
Currency Not Supported
Currency Not Supported
Problem: “Currency not supported” errorSolution:
- Check Stripe supports your currency
- Verify currency code is correct (ISO 4217)
- Update the
currencyparameter in charge creation - Some currencies require specific account setup
Webhook URL Not Accessible
Webhook URL Not Accessible
Problem: Stripe can’t reach webhook endpointSolution:
- Ensure URL is publicly accessible (not localhost)
- Verify SSL certificate is valid
- Check server firewall allows Stripe IPs
- Test URL accessibility with curl:
- For local testing, use Stripe CLI
Stripe Dashboard
Key sections of the Stripe Dashboard:- Payments: View all transactions
- Customers: Manage customer records
- Subscriptions: Track recurring payments
- Disputes: Handle chargebacks
- Logs: Debug API requests
- Webhooks: Monitor webhook delivery
- Reports: Financial reporting
Advanced Features
3D Secure Authentication
Stripe automatically handles Strong Customer Authentication (SCA):Payment Intents API
For advanced use cases, consider using Payment Intents:Customer Portal
Allow customers to manage their subscriptions:Going Live Checklist
Update to Live Keys
- Replace test keys with live keys
- Set
STRIPE_ENVIRONMENT="production" - Clear config cache
Configure Live Webhooks
- Create webhook for production URL
- Update
STRIPE_WEBHOOK_SECRET - Test webhook delivery
Next Steps
PayPal Integration
Add PayPal as an alternative payment method
Subscription Plans
Configure your subscription plans
Invoice Customization
Customize invoice templates
Payment Analytics
Track payment metrics