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

ActiveLibrary[Payment Processing](/categories/payments)

alnazer/knet-payment
====================

We help you to develop your business by introducing the new add-on For payment through the K-Net portal, after it has been updated Expand your customers' circle by making the payment available via Knet

1.2.0(2y ago)31102GPL-2.0-onlyPHPPHP ^5.6 || ^7.0 || ^8.0.0

Since Jun 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/alnazer/knet-payment)[ Packagist](https://packagist.org/packages/alnazer/knet-payment)[ RSS](/packages/alnazer-knet-payment/feed)WikiDiscussions knet-payment Synced 1w ago

READMEChangelog (7)DependenciesVersions (9)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/9599d8b4e22365423eb306eebb616f590d046793639605463945cf79c17222d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c6e617a65722f6b6e65742d7061796d656e742e737667)](https://packagist.org/packages/alnazer/knet-payment)[![Total Downloads](https://camo.githubusercontent.com/b7c9d317039a2105a3432427a9219a1f2ef3020ab73f86bbf1d38d71d1461594/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c6e617a65722f6b6e65742d7061796d656e742e737667)](https://packagist.org/packages/alnazer/knet-payment)[![Build Status](https://camo.githubusercontent.com/9d9d19eb3c3a94aec1d3b9dfb9df4cda1a661db10e45ae4046df09d1853323b9/68747470733a2f2f7472617669732d63692e6f72672f616c6e617a65722f6b6e65742d7061796d656e742e7376673f6272616e63683d6b6e65742d7061796d656e74)](https://travis-ci.org/alnazer/knet-payment)[![License](https://camo.githubusercontent.com/f40de84008b229fdf679d43e0fd30fdc9e4afe429362df28ac7eea5a8b56e340/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616c6e617a65722f6b6e65742d7061796d656e74)](https://packagist.org/packages/alnazer/knet-payment)

knet-payment
============

[](#knet-payment)

to test payment choose KNET from banks list (بنك اختبار كنيت \[KNET1\])

```
Card Number : 8888880000000001

for Captured
Expiry Date : 09/25

for Not Captured
Expiry Date : Any

CVC : Any 4 digit

```

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

[](#installation)

```
composer require alnazer/knet-payment

```

usage
-----

[](#usage)

```
use Alnazer\KnetPayment\Knet;

$config = [
    "tranportal_id"=>"",
    "password"=>"",
    "resource_key"=>"",
    "response_url" => "https://yourdomain.com/result.php",
    "error_url" => "https://yourdomain.com/error.php",
    "amount"=> 1,
    "udf1"=> "",
    "udf2"=> "",
    "udf3"=> "",
    "udf4"=> "",
    "udf5"=> "",
];

$knet  = new Knet($config);

// **************  request from knet *************//
$request = $knet->request();

if($request["status"] == 1)
{
    // redirect to knet payment page using $request["data"]["url"];
}
else
{
    // display errors print_r($request["errors"]);
}

// ************** back from knet  *************//

$resutl = $knet->responce();

if($resutl["status"] == "success"){
    // get reult and update your database
}
else
{
    // print error $resutl["ErrorText"]
}
```

### For user Register after 4/9/2023

[](#for-user-register-after-492023)

if you register after 4/9/2023 and want active KNET new policy set this active

```
$is_redirection_mode = true;
```

to return redirect page using this function

```
//$redirect_url the link will redirect (your order page or confiremed payment)
//$payment_id : payment id return from KNET
print_redirect($redirect_url,$payment_id);
```

```
// ************** back from knet  *************//

$resutl = $knet->responce();

if($resutl["status"] == "success"){
  // get reult and update your database
  echo $knet->print_redirect("The page url will redirect to it",$resutl["paymentid"]);
}
else
{

  // get reult and update your database
  echo $knet->print_redirect("The error page url will redirect to it",$resutl["paymentid"]);
}
```

### require information

[](#require-information)

get this information knet account

```
$tranportal_id;
$password;
$resource_key;
```

if you want test payment

```
$is_test = true;
```

### return urls

[](#return-urls)

```
$response_url; // url bank will return after payment operation success
$error_url;// url bank will return if faveing error in payment operation
```

### call request using function

[](#call-request-using-function)

```
$this->request()
```

### call result using function

[](#call-result-using-function)

```
$this->responce()
```

### validate

[](#validate)

```
$this->validate();
```

### to add error

[](#to-add-error)

```
$this->addError("index_name","message");
```

Eventes
-------

[](#eventes)

\*\* Must implement this functions

#### before validate

[](#before-validate)

```
public function beforeValidate()
{
    parent::beforeValidate();

    //code here ....

    return true;
}
```

#### after validate

[](#after-validate)

```
public function afterValidate()
{
    parent::afterValidate();

    //code here ....

    return true;
}
```

#### before request

[](#before-request)

called before call knet url

```
public function beforeRequest()
{
    parent::beforeRequest();

    //code here ....

    return true;
}
```

#### after request

[](#after-request)

called after call knet url

```
public function afterRequest($trackid, $pay_url)
{
    parent::afterRequest($trackid, $pay_url);

    //code here ....

    return true;
}
```

#### before responce

[](#before-responce)

```
public function beforeResponce()
{
    parent::beforeResponce();

    //code here ....

    return true;
}
```

#### after responce

[](#after-responce)

```
public function afterResponce($payment_id, $trackid, $result)
{
    parent::afterResponce($payment_id, $trackid, $result);

    //code here ....

    return true;
}
```

Result
------

[](#result)

### request return

[](#request-return)

#### success

[](#success)

```
[
"status" => 1,
  "data"=>
    [
      "url"=>"https://knetpayment.com",
      "trackid"=>"23492375295"
    ],
  "errors"=>false
]
```

#### error

[](#error)

```
[
"status" => 0,
  "data"=>
    [
      "url"=>"",
      "trackid"=>"23492375295"
    ],
  "errors"=>
    [
      "index_error" = > "error message",
      "index_error2" = > "error message2",
    ]
]
```

### responce "result" return

[](#responce-result-return)

#### success

[](#success-1)

```
[
  "status" => "success",
  "paymentid" => "2423sdfsd723482582",
  "trackid" => "3424234234",
  "tranid" => "4234234234234",
  "ref" => "3523235252",
  "result" => "CAPTURED", //knet result CAPTURED,NOT CAPTURED,CANCELED ... ect
  "postdate" => "3234234",
  "auth" => "44445",
  "avr" => "4566",
  "amount" => "1.000",
  "udf1" => "", // you set this data in request function
  "udf2" => "",// you set this data in request function
  "udf3" => "",// you set this data in request function
  "udf4" => "",// you set this data in request function
  "udf5" => "",// you set this data in request function
  "data" => "", // all $_REQUEST data
  "ErrorText" => "",
  "Error" => "",
]
```

#### error

[](#error-1)

```
[
  "status" => "error",
  "paymentid" => "2423sdfsd723482582",
  "trackid" => "3424234234",
  "tranid" => "4234234234234",
  "ref" => "3523235252",
  "result" => "error",
  "postdate" => "3234234",
  "auth" => "44445",
  "avr" => "4566",
  "amount" => "1.000",
  "udf1" => "", // you set this data in request function
  "udf2" => "",// you set this data in request function
  "udf3" => "",// you set this data in request function
  "udf4" => "",// you set this data in request function
  "udf5" => "",// you set this data in request function
  "ErrorText" => "get from knet responce",
  "Error" => "get from knet responce",
]
```

Chnagelog
---------

[](#chnagelog)

\###version 1.1.0

- active redirection mode for KNET new policy

\###version 1.0.2

- fixed call array of string php version 8

###  Health Score

30

—

LowBetter than 61% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Recently: every ~219 days

Total

7

Last Release

846d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.4

1.0.1PHP ^5.6 || ^7.0 || ~8.0.0

1.2.0PHP ^5.6 || ^7.0 || ^8.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2820271?v=4)[alnazer](/maintainers/alnazer)[@alnazer](https://github.com/alnazer)

---

Top Contributors

[![alnazer](https://avatars.githubusercontent.com/u/2820271?v=4)](https://github.com/alnazer "alnazer (61 commits)")

---

Tags

paymentknetkuwait

### Embed Badge

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

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

###  Alternatives

[paymentsuite/stripe-bundle

Stripe PaymentSuite Component

115.0k](/packages/paymentsuite-stripe-bundle)

PHPackages © 2026

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