Overview
PayPal is a globally recognized payment platform that allows TelemanAI users to accept payments via:- PayPal accounts
- Credit and debit cards
- PayPal Credit
- Local payment methods in 200+ markets
- 25+ currencies
Prerequisites
- A PayPal Business account (Sign up here)
- Business verification completed
- Bank account linked to your PayPal account
Setup Instructions
Create PayPal Business Account
- Visit PayPal Business Signup
- Choose “Business Account” type
- Complete business information
- Verify your email address
- Link a bank account for withdrawals
Get API Credentials
- Log in to PayPal Developer Dashboard
- Go to My Apps & Credentials
- Choose Sandbox or Live depending on your needs
- Under “REST API apps”, click Create App
- Name your app (e.g., “TelemanAI Sandbox”)
- Copy the Client ID and Secret
- Switch to Live tab
- Click Create App
- Complete app details
- Copy the Client ID and Secret
Configure Environment Variables
Add PayPal credentials to your For Live Mode:
.env file:For Sandbox Mode:Always start with sandbox mode for testing before going live.
Testing the Integration
Create Sandbox Accounts
- In PayPal Developer Dashboard, go to Sandbox → Accounts
- You’ll see pre-created test accounts:
- Business Account: For receiving payments
- Personal Account: For making test payments
- Click View/Edit to see account credentials
- Note the email and password for testing
Make a Test Purchase
- Go to TelemanAI pricing page
- Select a subscription plan
- Click Subscribe Now
- Choose PayPal as payment method
- You’ll be redirected to PayPal sandbox
- Log in with test personal account credentials
- Complete the payment
- You’ll be redirected back to TelemanAI
Payment Flow
Implementation Details
PayPal Gateway Service
SeePayPalGateway.php for implementation:
PayPalGateway.php (lines 8-45)
Handling Payment Callback
PayPalGateway.php (lines 52-73)
Supported Currencies
PayPal supports 25+ currencies:- USD - US Dollar
- EUR - Euro
- GBP - British Pound
- CAD - Canadian Dollar
- AUD - Australian Dollar
- JPY - Japanese Yen
- CNY - Chinese Yuan
- INR - Indian Rupee
- SGD - Singapore Dollar
- HKD - Hong Kong Dollar
- MXN - Mexican Peso
- BRL - Brazilian Real
Currency is set via
PAYPAL_CURRENCY environment variable.Webhook Configuration
Set up webhooks to receive payment notifications:Create Webhook
- In PayPal Developer Dashboard, go to your app
- Scroll to Webhooks section
- Click Add Webhook
- Enter webhook URL:
Select Event Types
Subscribe to these events:
PAYMENT.CAPTURE.COMPLETEDPAYMENT.CAPTURE.DENIEDPAYMENT.CAPTURE.REFUNDEDCHECKOUT.ORDER.APPROVEDCHECKOUT.ORDER.COMPLETED
Sandbox vs Live Mode
Sandbox Mode (Testing)
- No real money processed
- Uses sandbox test accounts
- Separate API endpoints
- Testing environment only
- Full PayPal experience simulation
- Pre-created in Developer Dashboard
- Email format:
[email protected] - Password visible in dashboard
- Can create custom test accounts
Live Mode (Production)
- Verified PayPal Business account
- Bank account linked
- Business information complete
- HTTPS enabled (required)
- Terms accepted
Routes Configuration
PayPal payment routes (seeroutes/paypal.php):
| Route | Method | Description |
|---|---|---|
/paypal/payment | GET/POST | Initiate PayPal payment |
/paypal/callback | GET | Payment return URL |
/paypal/cancel | GET | Payment cancelled URL |
/paypal/webhook | POST | Webhook endpoint |
Database Schema
Payment records inpayment_histories table:
Security Best Practices
Troubleshooting
Authentication Failed
Authentication Failed
Problem:
Authentication failed errorSolution:- Verify Client ID and Secret are correct
- Ensure you’re using correct mode (sandbox vs live)
- Check credentials match the environment
- Remove any extra spaces in
.envfile - Clear config cache:
php artisan config:clear
Redirect Not Working
Redirect Not Working
Problem: Not redirected to PayPalSolution:
- Check
returnUrlandcancelUrlare set correctly - Ensure URLs are publicly accessible
- Verify HTTPS is enabled for production
- Check PayPal API response for errors
- Review application logs
Payment Approved But Not Processed
Payment Approved But Not Processed
Problem: PayPal payment approved but subscription not activatedSolution:
- Verify callback route is accessible
- Check
completePurchaseis called correctly - Ensure
PayerIDandpaymentIdare in URL - Review callback handler logic
- Check database for payment record
Sandbox Account Login Fails
Sandbox Account Login Fails
Problem: Can’t log in with sandbox accountSolution:
- Verify you’re on sandbox.paypal.com
- Use the exact email from Developer Dashboard
- Click “View/Edit” to see current password
- Try resetting sandbox account password
- Create a new sandbox test account
Currency Not Supported
Currency Not Supported
Problem: Selected currency rejectedSolution:
- Check PayPal supports the currency
- Verify currency code is correct (ISO 4217)
- Ensure your account is enabled for that currency
- Some currencies require account approval
- Update
PAYPAL_CURRENCYin.env
Webhook Not Received
Webhook Not Received
Problem: Webhooks not hitting endpointSolution:
- Ensure webhook URL is publicly accessible
- Verify HTTPS is enabled
- Check webhook ID is correct
- Test endpoint with PayPal’s webhook simulator
- Review webhook logs in PayPal Dashboard
PayPal Dashboard
Key sections in PayPal Dashboard:- Activity: View all transactions
- Invoicing: Create and send invoices
- Reports: Download transaction reports
- Disputes: Manage buyer disputes
- API Credentials: Manage API access
- Webhook Events: Monitor webhook delivery
Advanced Features
Express Checkout
Implement PayPal Express Checkout for faster payments:Subscription Billing
For recurring subscriptions:Refunds
Process refunds programmatically:Going Live Checklist
Complete Business Verification
- Submit business documents to PayPal
- Verify business email
- Link bank account
- Complete tax information
Update to Live Credentials
- Get live API credentials from Developer Dashboard
- Update
.envwith live credentials - Set
PAYPAL_SANDBOX=false - Clear config cache
Configure Live Webhooks
- Create webhook for production URL
- Update
PAYPAL_WEBHOOK_ID - Test webhook delivery
Transaction Fees
PayPal charges transaction fees: Standard Rates (US):- Domestic: 2.9% + $0.30 per transaction
- International: 4.4% + fixed fee
- Currency conversion: 3-4% above exchange rate
- 5% + $0.05 per transaction
Fees vary by country and transaction type. Check PayPal’s pricing page for your region.
Next Steps
Stripe Integration
Add Stripe as alternative payment method
Razorpay Integration
Configure Razorpay for Indian market
Subscription Management
Manage user subscriptions
Payment Analytics
Track payment metrics