PHPackages                             rhaima/larakonnect - 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. rhaima/larakonnect

ActiveLibrary[Payment Processing](/categories/payments)

rhaima/larakonnect
==================

Laravel package for Konnect.network payment gateway integration - Accept online payments in Tunisia (bank cards, e-DINAR, wallet)

v1.0.1(5mo ago)31MITPHPPHP ^8.1

Since Dec 20Pushed 5mo agoCompare

[ Source](https://github.com/Rhaima96/larakonnect)[ Packagist](https://packagist.org/packages/rhaima/larakonnect)[ Docs](https://github.com/Rhaima96/larakonnect)[ RSS](/packages/rhaima-larakonnect/feed)WikiDiscussions main Synced 1mo ago

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

LaraKonnect
===========

[](#larakonnect)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fd109135c70f55b84246d8e7645e84ddfedfd3d05ac4d5484648494b78c1ca4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726861696d612f6c6172616b6f6e6e6563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rhaima/larakonnect)[![Total Downloads](https://camo.githubusercontent.com/4404b06af5fa1999b12e464a8567ecc007f80aadbd7a0a8d2df2457e7dbc689b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726861696d612f6c6172616b6f6e6e6563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rhaima/larakonnect)[![License](https://camo.githubusercontent.com/2c35ed5f458771ff970f359f94d8d0e8d8f363aed5e977a6172c3c107f48ac06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726861696d612f6c6172616b6f6e6e6563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rhaima/larakonnect)

A Laravel package for integrating [Konnect.network](https://konnect.network) payment gateway. Accept online payments in Tunisia via bank cards, e-DINAR, and Konnect wallet.

Features
--------

[](#features)

- 🚀 Easy integration with Laravel 10, 11, and 12
- 💳 Support for bank cards, e-DINAR, and Konnect wallet
- 🔒 Secure payment processing with PCI-DSS compliance
- 📦 Eloquent model with polymorphic relations
- 🎯 Event-driven architecture for payment lifecycle
- 🛠 Artisan commands for installation and debugging
- 🧪 Sandbox mode for testing

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

[](#installation)

```
composer require rhaima/larakonnect
```

Run the installation command:

```
php artisan larakonnect:install
```

This will:

- Publish the configuration file
- Publish and run migrations (optional)
- Add environment variables to your `.env` file

Configuration
-------------

[](#configuration)

Add your Konnect credentials to `.env`:

```
KONNECT_SANDBOX=true
KONNECT_API_KEY=your_wallet_id:your_api_secret
KONNECT_WALLET_ID=your_wallet_id
```

Get your credentials from:

- **Sandbox**:
- **Production**:

### Exclude Webhook from CSRF

[](#exclude-webhook-from-csrf)

Add the webhook route to your CSRF exceptions in `app/Http/Middleware/VerifyCsrfToken.php`:

```
protected $except = [
    'konnect/webhook',
];
```

Usage
-----

[](#usage)

### Basic Usage with Facade

[](#basic-usage-with-facade)

```
use Rhaima\LaraKonnect\Facades\LaraKonnect;

// Create a payment link (amount in TND)
$result = LaraKonnect::createPaymentLink(
    amountTND: 150.500,
    orderId: 'ORDER-2024-001',
    description: 'iPhone repair service',
    customer: [
        'first_name' => 'Mohamed',
        'last_name' => 'Rhaima',
        'email' => 'client@example.com',
        'phone' => '22123456',
    ]
);

if ($result->success) {
    return redirect($result->payUrl);
}

// Handle error
return back()->with('error', $result->error);
```

### Advanced Usage

[](#advanced-usage)

```
use Rhaima\LaraKonnect\Facades\LaraKonnect;
use Rhaima\LaraKonnect\Services\KonnectClient;

// Convert TND to millimes (1 TND = 1000 millimes)
$amountMillimes = KonnectClient::toMillimes(150.500); // 150500

// Initialize payment with full options
$result = LaraKonnect::initPayment($amountMillimes, 'ORDER-123', [
    'description' => 'Payment description',
    'acceptedPaymentMethods' => ['bank_card', 'e-DINAR'],
    'lifespan' => 30, // minutes
    'theme' => 'dark',
    'firstName' => 'Mohamed',
    'lastName' => 'Rhaima',
    'email' => 'client@example.com',
    'phoneNumber' => '22123456',
    'successUrl' => 'https://yoursite.com/payment/success',
    'failUrl' => 'https://yoursite.com/payment/fail',
]);

// Check payment status
$payment = LaraKonnect::getPayment($paymentRef);

if ($payment->isCompleted()) {
    // Payment successful
}

// Quick status check
if (LaraKonnect::isCompleted($paymentRef)) {
    // ...
}
```

### Using the Model

[](#using-the-model)

```
use Rhaima\LaraKonnect\Models\KonnectPayment;

// Create and initiate payment with tracking
$result = KonnectPayment::createAndInitiate(
    amountTnd: 150.500,
    orderId: 'ORDER-123',
    payable: $order, // Your model (Order, Intervention, etc.)
    customerInfo: [
        'first_name' => 'Mohamed',
        'email' => 'client@example.com',
    ]
);

if ($result['success']) {
    return redirect($result['payUrl']);
}

// Query payments
$pendingPayments = KonnectPayment::pending()->get();
$completedPayments = KonnectPayment::completed()->get();
$orderPayments = KonnectPayment::forOrder('ORDER-123')->get();
```

### Using the Trait

[](#using-the-trait)

Add the trait to any model that can have payments:

```
use Rhaima\LaraKonnect\Traits\HasKonnectPayments;

class Intervention extends Model
{
    use HasKonnectPayments;

    // Optional: customize the order ID
    public function getKonnectOrderId(): string
    {
        return 'INT-' . $this->reference;
    }

    // Optional: auto-fill customer info
    public function getKonnectCustomerInfo(): array
    {
        return [
            'first_name' => $this->client->prenom,
            'last_name' => $this->client->nom,
            'phone' => $this->client->telephone,
        ];
    }
}
```

Then use it:

```
$intervention = Intervention::find(1);

// Initiate payment
$result = $intervention->initiateKonnectPayment(150.500);

// Check payment status
if ($intervention->isPaidViaKonnect()) {
    // Already paid
}

// Get payment history
$payments = $intervention->konnectPayments;
$latestPayment = $intervention->latestKonnectPayment;
```

### Handling Events

[](#handling-events)

Listen to payment events in your `EventServiceProvider`:

```
use Rhaima\LaraKonnect\Events\PaymentInitiated;
use Rhaima\LaraKonnect\Events\PaymentCompleted;
use Rhaima\LaraKonnect\Events\PaymentFailed;

protected $listen = [
    PaymentCompleted::class => [
        UpdateOrderStatus::class,
        SendPaymentConfirmation::class,
    ],
    PaymentFailed::class => [
        NotifyAdminOfFailedPayment::class,
    ],
];
```

Example listener:

```
class UpdateOrderStatus
{
    public function handle(PaymentCompleted $event): void
    {
        $order = Order::where('reference', $event->orderId)->first();

        if ($order) {
            $order->update([
                'payment_status' => 'paid',
                'paid_at' => now(),
            ]);

            // Send notification
            $order->client->notify(new PaymentReceived($order));
        }
    }
}
```

Available Methods
-----------------

[](#available-methods)

### Facade Methods

[](#facade-methods)

MethodDescription`createPaymentLink($amount, $orderId, $description?, $customer?)`Quick payment link creation`initPayment($amountMillimes, $orderId, $options?)`Full payment initialization`getPayment($paymentRef)`Get payment details`isCompleted($paymentRef)`Check if payment is completed`getStatus($paymentRef)`Get payment status enum`toMillimes($amountTND)`Convert TND to millimes`toTND($millimes)`Convert millimes to TND### Model Methods

[](#model-methods)

MethodDescription`createAndInitiate(...)`Create record and initiate payment`markAsCompleted()`Mark payment as completed`markAsFailed()`Mark payment as failed`refreshFromKonnect()`Sync status from Konnect API`isCompleted()`Check if completed`isPending()`Check if pendingArtisan Commands
----------------

[](#artisan-commands)

```
# Install the package
php artisan larakonnect:install

# Check configuration status
php artisan larakonnect:status

# Check specific payment
php artisan larakonnect:status PAYMENT_REF
```

Testing
-------

[](#testing)

Use sandbox mode and test cards:

Card TypeNumberCVVVisa4000000000000002Any 3 digitsMastercard5100000000000008Any 3 digits```
KONNECT_SANDBOX=true
```

Customization
-------------

[](#customization)

### Views

[](#views)

Publish and customize the views:

```
php artisan vendor:publish --tag=larakonnect-views
```

Views will be published to `resources/views/vendor/larakonnect/`.

### Configuration

[](#configuration-1)

Publish the configuration:

```
php artisan vendor:publish --tag=larakonnect-config
```

Security
--------

[](#security)

If you discover any security vulnerabilities, please email .

Credits
-------

[](#credits)

- [Rhaima](https://github.com/Rhaima96)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance73

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

150d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7bee28436ffa77414d849fc6030c74ff338b0d0927e18033ad2e3d2fd458cad7?d=identicon)[Rhaima96](/maintainers/Rhaima96)

---

Top Contributors

[![Rhaima96](https://avatars.githubusercontent.com/u/68730147?v=4)](https://github.com/Rhaima96 "Rhaima96 (2 commits)")

---

Tags

laravelpaymentgatewayfintechpaiementtunisiakonnecte-dinartunisie

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rhaima-larakonnect/health.svg)

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

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)[dena-a/iran-payment

a Laravel package to handle Internet Payment Gateways for Iran Banking System

312.4k1](/packages/dena-a-iran-payment)

PHPackages © 2026

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