PHPackages                             asciisd/knet - 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. asciisd/knet

ActiveLibrary[Payment Processing](/categories/payments)

asciisd/knet
============

Knet package is provides an expressive, fluent interface to KNet's payment services.

v7.2.0(1mo ago)141.1k7[5 PRs](https://github.com/asciisd/knet/pulls)MITPHPPHP ^8.3CI failing

Since Nov 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/asciisd/knet)[ Packagist](https://packagist.org/packages/asciisd/knet)[ RSS](/packages/asciisd-knet/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (19)Versions (47)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3a2ec0cc2621402f644c3f5246334cacf0ea51138f487a5892d0b58499214d88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617363696973642f6b6e65742e7376673f7374796c653d666c6174)](https://packagist.org/packages/asciisd/knet)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/297581da1f3ea0a0b404027fa12c05990065a5700b283121deedc5421db3f18f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617363696973642f6b6e65742e7376673f7374796c653d666c6174)](https://packagist.org/packages/asciisd/knet)

Laravel KNET Payment Integration
================================

[](#laravel-knet-payment-integration)

A robust Laravel package for integrating KNET payment gateway services in your applications. This package provides a clean and elegant way to handle payment processing, refunds, and transaction management with KNET.

Features
--------

[](#features)

- 🔒 Secure payment processing
- 💳 Transaction management
- 🔄 Payment status inquiries
- ↩️ Refund processing
- 🎯 Event-driven architecture
- 📝 Detailed transaction logging
- 🛡️ Error handling
- 🔍 Transaction tracking

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

[](#installation)

You can install the package via composer:

```
composer require asciisd/knet
```

After installation, publish the configuration file:

```
php artisan knet:publish"
```

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

[](#configuration)

Configure your KNET credentials in your `.env` file:

```
KNET_TRANSPORT_ID=your_transport_id
KNET_TRANSPORT_PASSWORD=your_transport_password
KNET_RESOURCE_KEY=your_resource_key

# URLs Optional
KNET_RESPONSE_URL=/knet/response
KNET_REDIRECT_URL=/dashboard
KNET_DEBUG=false
```

Basic Usage
-----------

[](#basic-usage)

### Creating a Payment

[](#creating-a-payment)

```
use Asciisd\Knet\Services\KnetPaymentService;

class PaymentController extends Controller
{
    public function createPayment(
        Request $request,
        KnetPaymentService $paymentService
    ) {
        $transaction = $paymentService->createPayment(
            user: $request->user(),
            amount: 10.000,
            options: [
                'udf1' => 'custom_data_1',
                'udf2' => 'custom_data_2',
            ]
        );

        return redirect($transaction->url);
    }
}
```

### Manual Handling Payment Response

[](#manual-handling-payment-response)

```
public function handleResponse(
    Request $request,
    KnetPaymentService $paymentService
) {
    $transaction = $paymentService->handlePaymentResponse($request->all());

    if ($transaction->paid) {
        return redirect()->route('payment.success');
    }

    return redirect()->route('payment.failed');
}
```

### Processing Refunds

[](#processing-refunds)

```
public function refund(
    KnetTransaction $transaction,
    KnetPaymentService $paymentService
) {
    // Full refund
    $result = $paymentService->refundPayment($transaction);

    // Partial refund
    $result = $paymentService->refundPayment($transaction, 5.000);

    return $result;
}
```

### Checking Transaction Status

[](#checking-transaction-status)

```
public function checkStatus(
    KnetTransaction $transaction,
    KnetPaymentService $paymentService
) {
    $updatedTransaction = $paymentService->inquireAndUpdateTransaction($transaction);
    return $updatedTransaction;
}
```

Events
------

[](#events)

The package dispatches several events that you can listen to:

- `KnetResponseReceived`: Fired when a payment response is received
- `KnetResponsehandled`: Fired when a payment response is handled

### Event Listeners Example

[](#event-listeners-example)

```
use Asciisd\Knet\Events\KnetResponseReceived;

class PaymentReceivedListener
{
    public function handle(KnetResponseReceived $event)
    {
        $transactionArray = $event->payload;
        // Handle payload
    }
}
```

Transaction Model
-----------------

[](#transaction-model)

The `KnetTransaction` model provides several helpful methods:

```
$transaction->rawAmount(); // Get the raw amount
$transaction->isPaid(); // Check if transaction is paid
$transaction->isRefunded(); // Check if transaction is refunded
$transaction->isRefundable(); // Check if transaction can be refunded
```

Error Handling
--------------

[](#error-handling)

The package includes comprehensive error handling:

```
try {
    $result = $paymentService->refundPayment($transaction);
} catch (\Exception $e) {
    Log::error('Refund failed', [
        'message' => $e->getMessage(),
        'transaction_id' => $transaction->id
    ]);
}
```

Database Schema
---------------

[](#database-schema)

The package includes migrations for the `knet_transactions` table with the following fields:

- `id`: Primary key
- `user_id`: Foreign key to users table
- `trackid`: KNET tracking ID
- `amt`: Transaction amount
- `paymentid`: KNET payment ID
- `tranid`: KNET transaction ID
- `ref`: Reference number
- `result`: Transaction result
- `auth`: Authorization code
- `avr`: AVR value
- `postdate`: Posting date
- `paid`: Payment status
- `error_text`: Error message if any
- `url`: Payment URL
- `livemode`: Production/Test mode flag
- Various UDF fields (udf1 to udf5)
- Refund-related fields
- Timestamps

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Amr Emad](https://github.com/aemaddin)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 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 ~56 days

Recently: every ~92 days

Total

42

Last Release

58d ago

Major Versions

v2.6.0 → v3.0.02023-04-15

v3.2.0 → v4.0.02024-11-12

v4.0.0 → v5.0.02025-01-13

v5.0.0 → v6.0.02025-03-16

v6.0.1 → v7.0.02026-03-09

PHP version history (8 changes)v1.0.0PHP ^7.1.3

v2.0.0PHP ^7.2

v2.1.0PHP ^7.3

v2.4.0PHP ^7.2.5|^8.0

v2.5.0PHP ^7.0|^8.0

v2.6.0PHP ^7.1|^8.0

v3.0.0PHP ^8.1|^8.2

v4.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77636067?v=4)[ASCII SD](/maintainers/asciisd)[@asciisd](https://github.com/asciisd)

---

Top Contributors

[![aemaddin](https://avatars.githubusercontent.com/u/11630742?v=4)](https://github.com/aemaddin "aemaddin (125 commits)")

---

Tags

knetkuwaitlaravelphplaravelbillingknetknet payment

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/asciisd-knet/health.svg)

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[lanos/laravel-cashier-stripe-connect

Adds Stripe Connect functionality to Laravel's main billing package, Cashier.

84138.9k](/packages/lanos-laravel-cashier-stripe-connect)

PHPackages © 2026

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