PHPackages                             srustamov/laravel-azericard - 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. srustamov/laravel-azericard

ActiveLibrary[Payment Processing](/categories/payments)

srustamov/laravel-azericard
===========================

Azericard for laravel framework

v3.1.0(9mo ago)147907MITPHPPHP &gt;=8.0CI failing

Since Jun 10Pushed 9mo agoCompare

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

READMEChangelog (2)Dependencies (3)Versions (14)Used By (0)

Azericard Payment Package for Laravel
=====================================

[](#azericard-payment-package-for-laravel)

[![GitHub license](https://camo.githubusercontent.com/00a8b3cd4cd675957b00f371b69606e25cce3a17644326313877aedabf1ec9f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7372757374616d6f762f6c61726176656c2d617a657269636172642e737667)](https://github.com/srustamov/laravel-azericard/blob/master/LICENSE.md)[![Latest Stable Version](https://camo.githubusercontent.com/6526be9c2c1d1b2b3e92e84e7bf9532a5d3ef2d65362f169930cbd897cdd64d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7372757374616d6f762f6c61726176656c2d617a65726963617264)](https://packagist.org/packages/srustamov/laravel-azericard)

Requirements
------------

[](#requirements)

- Laravel **^8|^9**
- PHP **^8.0**

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

[](#installation)

You can install the package via composer:

```
composer require srustamov/laravel-azericard
```

### For Laravel &lt; 8 and PHP &lt; 8

[](#for-laravel--8-and-php--8)

```
composer require srustamov/laravel-azericard:^1.0.1
```

### Publish config file

[](#publish-config-file)

```
php artisan vendor:publish --provider="Srustamov\Azericard\AzericardServiceProvider" --tag="config"
```

Credits
-------

[](#credits)

- [Samir Rustamov](https://github.com/srustamov)
- [Azericard](https://developer.azericard.com/)

Example
-------

[](#example)

### Routes

[](#routes)

```
// routes
Route::prefix('azericard')->group(function () {
    Route::get('/create-order',[\App\Http\Controllers\AzericardController::class,'createOrder']);
    Route::post('/callback',[\App\Http\Controllers\AzericardController::class,'callback']);
    Route::get('/result/{orderId}',[\App\Http\Controllers\AzericardController::class,'result']);
});
```

### Controller

[](#controller)

```
use App\Models\Payment\Transaction;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use Srustamov\Azericard\Azericard;
use Srustamov\Azericard\DataProviders\RefundData;
use Srustamov\Azericard\Events\OrderCompleted;
use Srustamov\Azericard\Exceptions\AzericardException;
use Srustamov\Azericard\Exceptions\FailedTransactionException;
use Srustamov\Azericard\Options;

class AzericardController extends Controller
{
    public function __construct()
    {
        Event::listen(OrderCompleted::class, function (OrderCompleted $event) {
            // do something
            //example
            logger()->info('Order completed', ['request' => $event->request]);
        });
    }

    public function createOrder(Azericard $azericard, Request $request)
    {
        $order = auth()->user()->transactions()->create([
            'amount'         => $request->post('amount'),
            'currency'       => 'AZN',
            'status'         => Transaction::PENDING,
            'type'           => Transaction::TYPE_PAYMENT,
            'payment_method' => Transaction::PAYMENT_METHOD_AZERICARD,
        ]);

        $formParams = $azericard->setOrder($order->id)
            ->setAmount($order->amount)
            ->setMerchantUrl(route('azericard.result',['order' => $order])
            //->debug($request->has('test'))
            ->createOrder();

        return response()->json($formParams);
    }

    public function callback(Azericard $azericard, Request $request)
    {
       $transaction = Trasaction::findByAzericard($request->get(Options::ORDER));

       if(!$transaction->isPending()){
           return response()->json(['message' => 'Order already processed'], 409);
       }

       DB::beginTransaction();

        try
        {
            if ($azericard->completeOrder($request->all()))
            {
                $transaction->update([
                    'status'     => Trasaction::SUCCESS,
                    'rrn'        => $request->get(Options::RRN),
                    'int_ref'    => $request->get(Options::INT_REF),
                    'process_at' => now(),
                ]);

                $transaction->user->increment('balance', $transaction->amount);

                DB::commit();

                $transaction->user->notify(new TransactionSuccess($transaction));

                return response()->json(['message' => 'Order processed successfully'], 200);
            }
            else
            {
                $transaction->update([
                    'status' => Trasaction::FAILED,
                    'process_at' => now(),
                ]);

                DB::commit();

                logger()->error('Azericard payment failed', $request->all());

                return response()->json(['message' => 'Order processed failed'], 500);
            }
        }
        catch (FailedTransactionException $e) {
            DB::rollBack();

            logger()->error('Azericard | Message: '.$e->getMessage(), $request->all());
            //do something
        }
        catch (AzericardException $e) {
            DB::rollBack();
            //do something
        }
        catch (Exception $e) {
            DB::rollBack();
        }
        finally {
            info('Azericard payment callback called', $request->all());
        }
    }

    public function refund(Request $request,Azericard $azericard)
    {
        $transaction = Trasaction::findOrFail($request->post('transaction_id'));

        try
        {
            $order = Transaction::createForRefund(
                amount : $amount = $request->post('amount'),
                parent_id: $transaction->id
            );

            $data = new RefundData(
                rrn: $transaction->rrn,
                int_ref: $transaction->int_ref,
                created_at: $transaction->process_at
            );

            if ($azericard->setAmount($amount)->setOrder($order->id)->refund($data)) {
                // refund success
            } else {
                // fail
            }
        }
        catch (FailedTransactionException $e) {
            //info($e->getMessage(),$e->getParams());
        }
        catch (AzericardException $e) {
            // payment fail
        }
        catch (Exception $e) {
            // payment fail
        }
    }

    public function result($orderId)
    {
        $transaction = Transaction::findByAzericard($orderId);

        if($transaction->isSuccess()){
            return view('payment.success');
        } elseif ($transaction->isPending()){
            return view('payment.pending');
        }

        return view('payment.failed');
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance56

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 97.4% 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 ~155 days

Recently: every ~250 days

Total

13

Last Release

295d ago

Major Versions

v0.0.1 → v1.0.02021-02-28

v1.0.1 → v2.0.02022-07-04

v2.0.6 → v3.0.02022-11-20

PHP version history (5 changes)v0.0.1PHP ^7.2.5

v2.0.0PHP ^7|^8

v2.0.1PHP ^8.1

v3.0.0PHP ^8.0

v3.0.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fabbc5f4675b2f2ee074685c20574794e0422294695c66f3926b59948b1b02f2?d=identicon)[srustamov](/maintainers/srustamov)

---

Top Contributors

[![srustamov](https://avatars.githubusercontent.com/u/22997563?v=4)](https://github.com/srustamov "srustamov (38 commits)")[![bbeycanov](https://avatars.githubusercontent.com/u/25961635?v=4)](https://github.com/bbeycanov "bbeycanov (1 commits)")

---

Tags

azericardlaravelpaymentphplaravelpaymentpayment gatewayazericard

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/srustamov-laravel-azericard/health.svg)

```
[![Health](https://phpackages.com/badges/srustamov-laravel-azericard/health.svg)](https://phpackages.com/packages/srustamov-laravel-azericard)
```

###  Alternatives

[victorybiz/laravel-crypto-payment-gateway

GoUrl.io Crypto Payment Gateway for Laravel

642.5k](/packages/victorybiz-laravel-crypto-payment-gateway)[tsaiyihua/laravel-linepay

linepay library for laravel

102.9k](/packages/tsaiyihua-laravel-linepay)

PHPackages © 2026

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