-
Notifications
You must be signed in to change notification settings - Fork 9
Installation Guide
This guide will walk you through installing and setting up the JazzCash Payment Gateway package in your Laravel application.
Before installing the package, ensure you have:
- PHP 8.1 or higher
- Laravel 9.0, 10.0, 11.0, or 12.0
- Composer installed
- A JazzCash merchant account with:
- Merchant ID
- Password
- Hash Key
- Sandbox URL
- Production URL
Install the package using Composer:
composer require zfhassaan/jazzcashPublish the configuration file to your config directory:
php artisan vendor:publish --tag=jazzcash-configThis will create config/jazzcash.php in your application.
Alternatively, you can use the interactive publish command:
php artisan vendor:publishThen select the JazzCash service provider option (usually option 9 or the number shown for zfhassaan\jazzcash\provider\ServiceProvider).
Add the following environment variables to your .env file:
# JazzCash Configuration
JAZZCASH_PAYMENTMODE=sandbox
JAZZCASH_MERCHANTID=your_merchant_id
JAZZCASH_PASSWORD=your_password
JAZZCASH_HASHKEY=your_hash_key
JAZZCASH_MPIN=your_mpin
JAZZCASH_PRODUCTION_URL=https://payments.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform
JAZZCASH_SANDBOX_URL=https://sandbox.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform
JAZZCASH_RETURNURL=https://yourdomain.com/payment/callback| Variable | Description | Required |
|---|---|---|
JAZZCASH_PAYMENTMODE |
sandbox or production
|
Yes |
JAZZCASH_MERCHANTID |
Your JazzCash merchant ID | Yes |
JAZZCASH_PASSWORD |
Your JazzCash password | Yes |
JAZZCASH_HASHKEY |
Your JazzCash hash key | Yes |
JAZZCASH_MPIN |
Your JazzCash MPIN | Optional |
JAZZCASH_PRODUCTION_URL |
Production API URL | Yes |
JAZZCASH_SANDBOX_URL |
Sandbox API URL | Yes |
JAZZCASH_RETURNURL |
URL to redirect after payment | Yes |
For Laravel 8, 9, and 10, you need to manually register the service provider in config/app.php:
'providers' => [
// ... other providers
\zfhassaan\jazzcash\provider\ServiceProvider::class,
],For Laravel 11+, the service provider is auto-discovered.
For Laravel 8, 9, and 10, add the facade alias in config/app.php:
'aliases' => Facade::defaultAliases()->merge([
'Jazzcash' => \Zfhassaan\JazzCash\Facade\JazzcashFacade::class,
])->toArray(),For Laravel 11+, the facade is auto-discovered.
To verify the installation, you can test the service provider registration:
// In tinker or a test route
php artisan tinker
// Test facade
use zfhassaan\JazzCash\JazzCash;
$jazzcash = new JazzCash();
$jazzcash->setAmount(100);
echo $jazzcash->getAmount(); // Should output: 100Solution: Ensure you've registered the service provider in config/app.php (Laravel < 11) or that auto-discovery is enabled.
Solution: Ensure you've registered the facade alias in config/app.php (Laravel < 11).
Solution:
- Run
php artisan config:clear - Ensure
.envfile has all required variables - Verify
config/jazzcash.phpexists
Solution:
- Run
composer dump-autoload - Clear config cache:
php artisan config:clear
After installation, proceed to:
- Configuration Guide - Configure the package
- Getting Started - Learn basic usage
- Understanding Hosted Checkout - Understand payment processing