-
Notifications
You must be signed in to change notification settings - Fork 9
Configuration Guide
Hassaan Ali edited this page Dec 7, 2025
·
1 revision
This guide covers all configuration options available in the JazzCash package.
The configuration file is located at config/jazzcash.php after publishing. You can publish it using:
php artisan vendor:publish --tag=jazzcash-configAll configuration values are loaded from your .env file. Here's a complete list:
# API URLs
JAZZCASH_PRODUCTION_URL=https://payments.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform
JAZZCASH_SANDBOX_URL=https://sandbox.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform
# Authentication
JAZZCASH_MERCHANTID=your_merchant_id
JAZZCASH_PASSWORD=your_password
JAZZCASH_HASHKEY=your_hash_key
# Application Settings
JAZZCASH_RETURNURL=https://yourdomain.com/payment/callback
JAZZCASH_PAYMENTMODE=sandbox# MPIN (if required)
JAZZCASH_MPIN=your_mpin
# Timezone (defaults to Asia/Karachi)
JAZZCASH_TIMEZONE=Asia/KarachiThe configuration file structure:
return [
'api_url' => env('JAZZCASH_PRODUCTION_URL', ''),
'sandbox_api_url' => env('JAZZCASH_SANDBOX_URL', ''),
'merchant_id' => env('JAZZCASH_MERCHANTID', ''),
'password' => env('JAZZCASH_PASSWORD', ''),
'hash_key' => env('JAZZCASH_HASHKEY', ''),
'return_url' => env('JAZZCASH_RETURNURL', ''),
'mode' => env('JAZZCASH_PAYMENTMODE', 'sandbox'),
'mpin' => env('JAZZCASH_MPIN', ''),
'timezone' => env('JAZZCASH_TIMEZONE', 'Asia/Karachi'),
];The package supports two modes:
JAZZCASH_PAYMENTMODE=sandbox- Uses
JAZZCASH_SANDBOX_URLfor API calls - Safe for testing
- Uses test credentials
- No real transactions processed
JAZZCASH_PAYMENTMODE=production- Uses
JAZZCASH_PRODUCTION_URLfor API calls - Real transactions processed
- Requires production credentials
- Use with caution
You can modify configuration at runtime:
// Change mode
config(['jazzcash.mode' => 'production']);
// Update merchant ID
config(['jazzcash.merchant_id' => 'new_merchant_id']);
// Update return URL
config(['jazzcash.return_url' => 'https://newdomain.com/callback']);$merchantId = config('jazzcash.merchant_id');
$mode = config('jazzcash.mode');
$apiUrl = config('jazzcash.api_url');JAZZCASH_PAYMENTMODE=sandbox
JAZZCASH_PRODUCTION_URL=https://payments.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform
JAZZCASH_SANDBOX_URL=https://sandbox.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantformJAZZCASH_PAYMENTMODE=sandbox
JAZZCASH_PRODUCTION_URL=https://payments.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform
JAZZCASH_SANDBOX_URL=https://sandbox.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantformJAZZCASH_PAYMENTMODE=production
JAZZCASH_PRODUCTION_URL=https://payments.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform
JAZZCASH_SANDBOX_URL=https://sandbox.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform-
Never commit
.envfile - Keep credentials secure - Use environment variables - Don't hardcode values
- Rotate credentials regularly - Update keys periodically
- Use different credentials - Separate sandbox and production
- Restrict access - Limit who can access configuration
The package validates configuration on service initialization. Missing required values will throw exceptions:
// Required values
- merchant_id
- password
- hash_key
- return_url
- api_url or sandbox_api_url (based on mode)Test your configuration:
use zfhassaan\JazzCash\JazzCash;
try {
$jazzcash = new JazzCash();
$jazzcash->setAmount(100)
->setBillReference('TEST-123')
->setProductDescription('Test');
// Configuration is correct if no exception is thrown
echo "Configuration is valid!";
} catch (\RuntimeException $e) {
echo "Configuration error: " . $e->getMessage();
}Solution: Clear config cache:
php artisan config:clear
php artisan config:cacheSolution: Check JAZZCASH_PAYMENTMODE in .env:
# Verify mode
php artisan tinker
>>> config('jazzcash.mode')Solution:
- Verify credentials in JazzCash dashboard
- Check for extra spaces in
.envvalues - Ensure you're using correct mode (sandbox vs production)
- Getting Started - Start using the package
- Understanding Hosted Checkout - Understand payment processing
- API Reference - Explore available methods