Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aemaddin committed Nov 27, 2019
0 parents commit cacb926
Show file tree
Hide file tree
Showing 34 changed files with 1,548 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor
composer.lock
/phpunit.xml
.phpunit.result.cache
.idea
.env
4 changes: 4 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
php:
preset: laravel
js: true
css: true
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: php

sudo: false

php:
- 7.1
- 7.2
- 7.3

env:
matrix:
- LARAVEL=5.8.*
- LARAVEL=^6.0
- LARAVEL=^7.0

matrix:
fast_finish: true
exclude:
- php: 7.1
env: LARAVEL=^6.0
- php: 7.1
env: LARAVEL=^7.0
allow_failures:
- env: LARAVEL=^7.0

before_install:
- phpenv config-rm xdebug.ini || true

install:
- travis_retry composer require "illuminate/contracts=${LARAVEL}" --prefer-dist --no-interaction --no-suggest

script: vendor/bin/phpunit --verbose
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# knet

General information about this package.

## Installation

Information about the installation procedure for this package.

## Using this package

Information about using this package

## Contributing

Information about contributing to this package.
53 changes: 53 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "asciisd/knet",
"description": "Knet package is provides an expressive, fluent interface to Knet's payment services.",
"keywords": [
"Laravel",
"billing",
"Knet",
"Knet Payment"
],
"authors": [
{
"name": "Amr Ahmed",
"email": "[email protected]"
}
],
"homepage": "https://github.com/asciisd/knet",
"require": {
"php": "^7.1.3",
"laravel/framework": "5.8.*",
"dompdf/dompdf": "^0.8.0",
"ext-openssl": "*",
"ext-json": "*"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.8|^4.0|^5.0",
"phpunit/phpunit": "^7.5|^8.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Asciisd\\Knet\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Asciisd\\Knet\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"Asciisd\\Knet\\Providers\\KnetServiceProvider"
]
}
},
"scripts": {
"test": "vendor/bin/phpunit -c ./phpunit.xml --colors=always",
"analysis": "vendor/bin/phpstan analyse"
},
"minimum-stability": "dev",
"prefer-stable": true
}
136 changes: 136 additions & 0 deletions config/knet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| KNet production and development urls
|--------------------------------------------------------------------------
|
| The KNet production url and development url give you access to Knet's
| API. The "production" url is typically used when interacting with
| production Api while the "development" url accesses testing API endpoints.
|
*/
'production_url' => env('KENT_PRODUCTION_URL', 'https://kpay.com.kw/kpg/PaymentHTTP.htm'),
'development_url' => env('KENT_PRODUCTION_URL', 'https://kpaytest.com.kw/kpg/PaymentHTTP.htm'),

/*
|--------------------------------------------------------------------------
| Knet Credentials
|--------------------------------------------------------------------------
|
| TranPortal Identification Number: The Payment Gateway Bank administrator
| issues the TranPortal ID to identify the merchant and terminal for transaction
| processing.
|
| TranPortal Password: The Payment Gateway Bank administrator issues the
| TranPortal password to authenticate the merchant and terminal. Merchant data
| will be encrypted and password securely hidden as long as the merchant is issuing
| an https post for transmitting the data to Payment Gateway.
|
*/
'transport' => [
'id' => env('KENT_TRANSPORT_ID'),
'password' => env('KENT_TRANSPORT_PASSWORD'),
],

'resource_key' => env('KENT_RESOURCE_KEY'),

/*
|--------------------------------------------------------------------------
| Knet Response url
|--------------------------------------------------------------------------
|
| The merchant URL where Payment Gateway send the authorization response
|
*/
'response_url' => env('KENT_RESPONSE_URL', '/knet/response'),

/*
|--------------------------------------------------------------------------
| Knet Error url
|--------------------------------------------------------------------------
|
| The merchant URL where Payment Gateway send the response in case any
| error while processing the transaction.
|
*/
'error_url' => env('KENT_ERROR_URL', '/knet/error'),

/*
|--------------------------------------------------------------------------
| Transaction Action Code
|--------------------------------------------------------------------------
|
| Transaction Action Type, "1" for Purchase.
| Transaction Action Type, "2" for Refund.
| Transaction Action Type, "3" for Void.
| Transaction Action Type, "8" for Inquiry.
|
*/
'action_code' => env('KENT_ACTION_CODE', 1),

/*
|--------------------------------------------------------------------------
| Language
|--------------------------------------------------------------------------
|
| The language in which Payment Page has to be presented.
|
| Supported languages: 'AR', 'EN'
|
*/
'language' => env('KENT_LANGUAGE', 'EN'),

/*
|--------------------------------------------------------------------------
| Knet Path
|--------------------------------------------------------------------------
|
| This is the base URI path where Knet's views, such as the payment
| verification screen, will be available from. You're free to tweak
| this path according to your preferences and application design.
|
*/
'path' => env('KNET_PATH', 'knet'),

/*
|--------------------------------------------------------------------------
| Knet Model
|--------------------------------------------------------------------------
|
| This is the model in your application that implements the HasKnet trait
| provided by Knet. It will serve as the primary model you use while
| interacting with Knet related methods, and so on.
|
*/
'model' => env('KNET_MODEL', App\User::class),

/*
|--------------------------------------------------------------------------
| Currency
|--------------------------------------------------------------------------
|
| This is the default currency that will be used when generating charges
| from your application. Of course, you are welcome to use any of the
| various world currencies that are currently supported via Knet.
|
*/
'currency' => env('KENT_CURRENCY', 414),
'decimals' => '3',

/*
|--------------------------------------------------------------------------
| Invoice Paper Size
|--------------------------------------------------------------------------
|
| This option is the default paper size for all invoices generated using
| Knet. You are free to customize this settings based on the usual
| paper size used by the customers using your Laravel applications.
|
| Supported sizes: 'letter', 'legal', 'A4'
|
*/
'paper' => env('KNET_PAPER', 'letter'),
];
2 changes: 2 additions & 0 deletions database/migrations/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 5
paths:
- src
- tests
2 changes: 2 additions & 0 deletions public/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions resources/lang/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions resources/views/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
22 changes: 22 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
|--------------------------------------------------------------------------
| knet Routes
|--------------------------------------------------------------------------
|
| Here is where you can register routes for your package.
|
*/

use Illuminate\Support\Facades\Route;

Route::prefix('knet')->group(function () {
Route::post('/response', 'KnetController@response')->name('knet.response');

Route::middleware('auth')->group(function() {
Route::get('/', 'KnetController@index')->name('knet');
Route::post('/', 'KnetController@charge')->name('knet.charge');
Route::post('/error', 'KnetController@error')->name('knet.error');
});
});
42 changes: 42 additions & 0 deletions src/Console/Commands/KnetCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Asciisd\Knet\Console\Commands;

use Illuminate\Console\Command;

class KnetCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'knet:command';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
28 changes: 28 additions & 0 deletions src/Events/KnetResponseHandled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Asciisd\Knet\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class KnetResponseHandled
{
use Dispatchable, SerializesModels;
/**
* The response payload.
*
* @var array
*/
public $payload;

/**
* Create a new event instance.
*
* @param array $payload
* @return void
*/
public function __construct(array $payload)
{
$this->payload = $payload;
}
}
Loading

0 comments on commit cacb926

Please sign in to comment.