Skip to content

Jazzcash - Laravel Jazzcash Payment Gateway Integration

License

Notifications You must be signed in to change notification settings

akcybex/laravel-jazzcash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



Jazzcash

Build Status Total Downloads Latest Stable Version License

Installation Steps

1. Require the Package

After creating your new Laravel application you can include the Laravel Jazzcash package with the following command:

composer require akcybex/laravel-jazzcash 

2. Add the Jazzcash Merchant Sandbox or Live Credentials

Next make sure to Jazzcash Merchant Sandbox or Live credentials to your .env file & their environment to use relevant credentials:

# Jazzcash Merchant
JAZZCASH_ENVIRONMENT=sandbox #You can set sandbox or live

SANDBOX_JAZZCASH_MERCHANT_ID=
SANDBOX_JAZZCASH_PASSWORD=
SANDBOX_JAZZCASH_INTEGERITY_SALT=
SANDBOX_JAZZCASH_RETURN_URL=
SANDBOX_JAZZCASH_ENDPOINT=https://sandbox.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform

JAZZCASH_MERCHANT_ID=
JAZZCASH_PASSWORD=
JAZZCASH_INTEGERITY_SALT=
JAZZCASH_RETURN_URL=
JAZZCASH_ENDPOINT=https://payments.jazzcash.com.pk/CustomerPortal/transactionmanagement/merchantform

3. Run Migration

Next to run migration command to migrate jazzcash transaction table.

php artisan migrate 

4. Generate MWALLET Request Form Fields, Generate form & Send Payment Request

Next to generate MWALLET request form fields from your checkout details and set amount as well as send request:

Note: Currently this package is only supporting MWALLET request soon we will add other features.

// ...

// Get request data after validation while submitting checkout
$i = $request->all();

// will return form fields
$data = \AKCybex\JazzCash\Facades\JazzCash::request()->setAmount($i['amount'])->toArray($i);

// ...

Pass generated fields data to view and then paste this code in view:

{{-- ... --}}

@php
    $jazzcash_environment = config('jazzcash.environment');
@endphp
<form name="redirect-to-payment-gateway" method="POST" action="{{ config("jazzcash.$jazzcash_environment.endpoint") }}">
    @foreach($data as $key => $value)
        <input type="hidden" name="{{ $key }}" value="{{ $value }}">
    @endforeach
</form>
<script>
    setTimeout(function () {
        document.forms['redirect-to-payment-gateway'].submit();
    }, 1000);
</script>

{{-- ... --}}

this will submit your request to jazzcash merchant and redirect automatically.

5. Handle Jazzcash response on transaction complete

Lastly, you just need to check code and get checkout details from jazzcash object which was submitted while checkout.

// ...

Route::post('/jazzcash/payment', function (\Illuminate\Http\Request $request, $gateway) {
    $jazzcash = \AKCybex\JazzCash\Facades\JazzCash::response();
    if ($jazzcash->code() == 000) {
        // Checkout form details you can get here
        $order = $jazzcash->order();
        
        // ...
    } else {
        $error = $jazzcash->message();
        // ...
    }

});

// ...

Support

Contact Us

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

About

Jazzcash - Laravel Jazzcash Payment Gateway Integration

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages