PHPackages                             sindibad/zaincash - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. sindibad/zaincash

ActiveLibrary[Payment Processing](/categories/payments)

sindibad/zaincash
=================

v0.0.2(4y ago)0381PHP

Since Nov 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/sindibad-git/sindibad-git)[ Packagist](https://packagist.org/packages/sindibad/zaincash)[ RSS](/packages/sindibad-zaincash/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

[![zaincash-image](https://camo.githubusercontent.com/a60c4b0ce3504cf6e2d67e5564d45ed4b884e4fd8ef28565ea78bf7807c36e3c/68747470733a2f2f7332302e7069636f66696c652e636f6d2f66696c652f383434323530363231382f756e6e616d65645f72656d6f766562675f707265766965772e706e673f7261773d74727565)](https://camo.githubusercontent.com/a60c4b0ce3504cf6e2d67e5564d45ed4b884e4fd8ef28565ea78bf7807c36e3c/68747470733a2f2f7332302e7069636f66696c652e636f6d2f66696c652f383434323530363231382f756e6e616d65645f72656d6f766562675f707265766965772e706e673f7261773d74727565)

Laravel #1 Payment Gateway For Zaincash
=======================================

[](#laravel-1-payment-gateway-for-zaincash)

[![GitHub license](https://camo.githubusercontent.com/7c2dd8f2f4b6b759711947e461a1aa1ea8946da50b46575bc1320f630847f56c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73696e64696261642d6769742f73696e64696261642d676974)](https://github.com/sindibad-git/sindibad-git/blob/master/LICENSE)[![Packagist Version](https://camo.githubusercontent.com/23f6981b76147ecb8374d09e4262480e9f39c265947c35d2c1787a2e2eae5618/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696e64696261642f7a61696e63617368)](https://camo.githubusercontent.com/23f6981b76147ecb8374d09e4262480e9f39c265947c35d2c1787a2e2eae5618/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696e64696261642f7a61696e63617368)

This is a Laravel Package for Payment Gateway Integration. This package supports `Laravel 5.5+`.

Installation
------------

[](#installation)

The package can be installed via Composer:

```
$ composer require sindibad/zaincash
```

Configure
---------

[](#configure)

If you are not using `Laravel 5.5` or higher than you need to add the provider and alias.(otherwise skip this part)

In your `config/app.php` file add these two lines.

```
// In your providers array.
'providers' => [
    ...
    sindibad\zaincash\provider\ZaincashServiceProvider::class,
],

// In your aliases array.
'aliases' => [
    ...
    'ZainCash' => Zaincash\Payment\facades\ZainCash::class,
],
```

then run `php artisan vendor:publish` to publish `config/payment.php` file in your config directory as well as `zaincash/callback.blade.php` file in views directory.

In the config file you can set to use initial configs for all your payments. But you can also change some of these values like `eloquent_storage`,`callback_url`,`lang`,`eloquent_storage` at runtime.

Then fill the credentials for `zaincashGateway.php` file

```
    "eloquent_storage" => true, // Once enabled, package will create transaction_zaincash table(through zaincash:migrate command) and fill it's values when new transaction is submitted
    "callback_url" => "default", // default, /[your custom segment] for callback response
    "merchant_id" => "",
    "token" => '', //Secret key for jwt encode
    "msisdn" => "",
    "lang" => "en", //ar,en
    "production" => false,//Once set to true production url's will be used otherwise test url's are consumed
    ...
]
```

How to use
----------

[](#how-to-use)

### Invoice

[](#invoice)

your `Invoice` holds your payment details, so initially we'll talk about `Invoice` class.It is mainly used for transactioninit purpose;

#### Working with invoices

[](#working-with-invoices)

before doing anything you need to use `Invoice` class to create an invoice, Also note that if you're planning to use EloquentStorage use the following artisan command:

```
php artisan zaincash:migrate
```

In your code, use it like the below:

```
// At the top of the file.
use sindibad\zaincash\facades\ZainCash;
...

// Create new invoice.
$invoice = new Invoice;

// Set invoice amount.
$invoice->amount(1000);

// Set orderId if available, so you can get the value back on callback
$invoice->setOrderId($request->orderid);
// Set additional description or project type
$invoice->setServiceType("mydescription");
// As mentioned this can be set either in config file or directly in Invoice accessor
// !Note that once you set it here this will be priority and not the config file values
$invoice->setLang("en");
// Callback url for callback response you can also set it to `default` for testing etc.
$invoice->setCallbackUrl("http://localhost:8000/customcallback");
// As mentioned before enabling EloquentStorage will create transaction_zaincash table inside your main db with transaction records
$invoice->setEnableElequentStorage(true);
// This parameter is set for main zaincash view files. it will set back button text
$invoice->setBackBtnText("back");
// Redirect url for main views back button
$invoice->setBackBtnUrl("http://localhost:8000/");
// you could also add extra parameters to invoice and get them back in callback response
//you need to define a key for your Extra,note that you will use this key to receive your extra in callback
$invoice->appendExtra("key" , "value");

//Finally, use pay to initialize your transaction
$pay = $invoice->pay();
//You can access redirect url for payment within ['url'] index
$redirect_url=$pay['url'];
//Get error messages
$invoice->getErrors();
```

### callBackResponse

[](#callbackresponse)

This method is used to retrieve gatewaycallback response.it gets jwt token as it's input parameter. By default, callback response input name is `token` but you can change it if source callback is different. if token is not set in request status will set to 'cancel'

#### Working with calBackResponse

[](#working-with-calbackresponse)

```
$payment= ZainCash::callBackResponse();
```

`$payment` includes following parameters

- `amount`: transaction cash amount
- `status;`: success,failed,cancel,repetitious,invalid\_token
- `orderId`: orderId of transaction
- `payment`: payload data
- `operationId`: operation id
- `config`: default config settings
- `extras`: whole extras set in Invoice
- `serviceType`: service type
- `initDate`: transaction time in timestamp format
- `backButtonText`: back button text
- `backButtonLink`: back buttonLink
- `errorMessage`: error messages if any
- `transaction`: this parameter returns when eloquent storage is set to true

you could also use getter methods for each of these parameters like below:

```
$payment= ZainCash::callBackResponse();
$payment->getStatus();
//when you're using getExtra method remember to pass default value as second parameter even tough it is optional
$response->getExtra("user_id" , -1);
```

#### PaymentReceivedEvent

[](#paymentreceivedevent)

You could also use zaincash internal Event to receive payment info. Make a new event and define`PaymentReceivedEvent::class` in your EventListener. In your event, use it like the below:

```
   public function handle($event)
    {
        $event->getPayment();
        //Logic
    }
```

Credits
-------

[](#credits)

- [Mohammad Foroughi](https://github.com/foroughi1380/)
- [Erfan Rahbari](https://github.com/erfanrhb)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1652d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22e39ca20b507d0ec44f54c5f4472da819c1116b3a6afc4a0ae2594ebc9cfe59?d=identicon)[sindibad](/maintainers/sindibad)

---

Top Contributors

[![erfanrhb](https://avatars.githubusercontent.com/u/60898556?v=4)](https://github.com/erfanrhb "erfanrhb (8 commits)")[![foroughi1380](https://avatars.githubusercontent.com/u/55579143?v=4)](https://github.com/foroughi1380 "foroughi1380 (2 commits)")[![sindibad-git](https://avatars.githubusercontent.com/u/93590825?v=4)](https://github.com/sindibad-git "sindibad-git (2 commits)")

---

Tags

configgithub-config

### Embed Badge

![Health badge](/badges/sindibad-zaincash/health.svg)

```
[![Health](https://phpackages.com/badges/sindibad-zaincash/health.svg)](https://phpackages.com/packages/sindibad-zaincash)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
