Guides
Deployment Guide
Step-by-step guide to deploy your bKash payment integration to production.
Prerequisites
Before deploying, ensure you have:
- ✅ Active bKash merchant account
- ✅ Live App Key, App Secret, Username and Password from bKash Developer Portal
- ✅ PHP 7.4+ with required extensions
- ✅ Laravel 8, 9, 10, 11, or 12
- ✅ Valid SSL certificate for your domain
TLS Requirement
bKash requires TLS 1.2 or higher. Test your server by running:curl "https://tokenized.sandbox.bka.sh/v1.2.0-beta" -v
Switch to Production Credentials
Update your .env file with live credentials:
# Production Mode
BKASH_SANDBOX=false
# Live Credentials (Get from bKash Developer Portal)
BKASH_APP_KEY=your_live_app_key
BKASH_APP_SECRET=your_live_app_secret
BKASH_USERNAME=your_live_username
BKASH_PASSWORD=your_live_password
BKASH_BASE_URL=https://tokenized.pay.bka.sh/v1.2.0-beta
BKASH_CURRENCY=BDT
BKASH_VERIFY_SSL=trueGet Live Credentials
Apply for production access at the bKash Developer Portal.
bKash Developer Portal
Environment Variables
All bKash configuration is controlled via environment variables. Here's a complete list:
| Variable | Description | Production Value |
|---|---|---|
BKASH_SANDBOX | Enable/disable sandbox mode | false |
BKASH_APP_KEY | Your bKash App Key | Live App Key |
BKASH_APP_SECRET | Your bKash App Secret | Live App Secret |
BKASH_USERNAME | Your bKash Username | Live Username |
BKASH_PASSWORD | Your bKash Password | Live Password |
BKASH_BASE_URL | API Base URL | https://tokenized.pay.bka.sh/v1.2.0-beta |
BKASH_CURRENCY | Currency for transactions | BDT |
BKASH_VERIFY_SSL | Enable SSL verification | true |
BKASH_CALLBACK_URL | Payment callback URL | https://yourdomain.com/payment/callback |
URL Configuration
Make sure your application URL is correctly configured in .env:
APP_URL=https://yourdomain.com
# bKash callback URLs
BKASH_CALLBACK_URL=https://yourdomain.com/payment/callback
# Routes (define in routes/web.php)
# /payment - Payment form
# /payment/initiate - Initiate payment
# /payment/callback - Payment callback
# /payment/success - Success page
# /payment/cancel - Cancel pagePublic URLs Required
bKash must be able to reach your callback URLs. Make sure your application is publicly accessible.
Note: localhost will not work in production.
Deployment Steps
1. Deploy Your Code
Deploy your Laravel application to your production server:
# Push to your repository
git push origin main
# Or deploy manually
rsync -avz /path/to/project/ user@server:/var/www/your-app/2. Install Dependencies
cd /var/www/your-app
composer install --no-dev --optimize-autoloader3. Clear and Cache Config
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
# Cache for production
php artisan config:cache
php artisan route:cache
php artisan view:cache4. Run Migrations
php artisan migrate --forceTesting in Production
Before going live, test your integration with real (but small) transactions:
# Test with small amount (10 BDT)
php artisan tinker
>>> Bkash::createPayment(10, 'TEST-' . date('YmdHis'), 'TEST-' . date('YmdHis'));bKash Panel Configuration
Configure the following settings in your bKash merchant panel:
- App Key: Your production App Key
- App Secret: Your production App Secret
- Username: Your production Username
- Password: Your production Password
- Callback URL:
https://yourdomain.com/payment/callback
Register Your Server IP
For refunds and transaction queries, you may need to register your server's IP address with bKash in the developer portal.
Monitoring & Logging
Enable logging to monitor payment activity:
# Enable bKash logging
BKASH_LOG_ERRORS=true
BKASH_LOG_CHANNEL=dailyCheck logs at: storage/logs/laravel.log
Troubleshooting
Issue: "Invalid App Key" (2001)
- Check your
.envfile for correct App Key - Make sure you're using live credentials in production
- Verify
BKASH_SANDBOX=false
Issue: "Invalid App Secret" (2002)
- Check your
.envfile for correct App Secret - Ensure you're not using sandbox credentials
Issue: "Invalid Username/Password" (2003)
- Verify your production username and password
- Check for any special characters that might need escaping
Issue: "Token Expired" (2004)
- Tokens auto-refresh automatically
- Clear cache if needed:
php artisan cache:clear
Issue: "Callback URL not accessible"
- Make sure your application is publicly accessible
- Check if your firewall is blocking bKash IPs
- Verify the route exists and is correct
- Ensure HTTPS is enabled
Issue: SSL Certificate Error
- Set
BKASH_VERIFY_SSL=truefor production - Ensure your SSL certificate is valid
Performance Optimization
- Cache tokens - Tokens are automatically cached to reduce API calls
- Cache configuration with
php artisan config:cache - Use database sessions for better performance
- Monitor token expiry - Tokens expire every hour
Production Go-Live Checklist
- ✅ Get live bKash credentials from Developer Portal
- ✅ Update
BKASH_SANDBOX=false - ✅ Set
BKASH_VERIFY_SSL=true - ✅ Set correct
APP_URLwith HTTPS - ✅ Configure callback URL in bKash panel
- ✅ Test with small real transaction (10 BDT)
- ✅ Enable logging
- ✅ Register server IP for refunds (if required)
- ✅ Create database table for transactions
- ✅ Set up proper error handling and user feedback
Need Help?
Join the discussion on GitHub Discussions or open an issue for support.
bKash Support: developer@bka.sh