Skip to content

Commit

Permalink
Added files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
hpakdaman committed May 7, 2016
1 parent 89f4bf3 commit c4f7006
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 37 deletions.
72 changes: 72 additions & 0 deletions config/gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

return [

//-------------------------------
// Timezone for insert dates in database
// If you want Gateway not set timezone, just leave it empty
//--------------------------------
'timezone' => 'Asia/Tehran',

//--------------------------------
// Zarinpal gateway
//--------------------------------
'zarinpal' => [
'merchant-id' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'type' => 'zarin-gate', // Types: [zarin-gate || normal]
'callback-url' => '/',
'server' => 'germany', // Servers: [germany || iran]
'email' => '[email protected]',
'mobile' => '09xxxxxxxxx',
'description' => 'description',
],

//--------------------------------
// Mellat gateway
//--------------------------------
'mellat' => [
'username' => '',
'password' => '',
'terminalId' => 0000000,
'callback-url' => '/'
],

//--------------------------------
// Payline gateway
//--------------------------------
'payline' => [
'api' => 'xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'callback-url' => '/'
],

//--------------------------------
// Sadad gateway
//--------------------------------
'sadad' => [
'merchant' => '',
'transactionKey'=> '',
'terminalId' => 000000000,
'callback-url' => '/'
],

//--------------------------------
// JahanPay gateway
//--------------------------------
'jahanpay' => [
'api' => 'xxxxxxxxxxx',
'callback-url' => '/'
],

//--------------------------------
// Parsian gateway
//--------------------------------
'parsian' => [
'pin' => 'xxxxxxxxxxxxxxxxxxxx',
'callback-url' => '/'
],

//-------------------------------
// Tables names
//--------------------------------
'table'=>=> 'gateway_transactions',
];
58 changes: 58 additions & 0 deletions migrations/2016_05_02_193213_create_gateway_transactions_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Larabookir\Gateway\PortAbstract;
use Larabookir\Gateway\GatewayResolver;
use Larabookir\Gateway\Enum;

class CreateGatewayTransactionsTable extends Migration
{
function getTable()
{
return config('gateway.table', 'gateway_transactions');
}

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create($this->getTable(), function (Blueprint $table) {
$table->engine = "innoDB";
$table->increments('id');
$table->enum('port', [
Enum::MELLAT,
Enum::JAHANPAY,
Enum::PARSIAN,
Enum::PAYLINE,
Enum::SADAD,
Enum::ZARINPAL,
]);
$table->decimal('price', 15, 2);
$table->string('ref_id', 100);
$table->string('tracking_code', 50)->nullable();
$table->string('card_number', 50)->nullable();
$table->enum('status', [
Enum::TRANSACTION_INIT,
Enum::TRANSACTION_SUCCEED,
Enum::TRANSACTION_FAILED,
])->default(Enum::TRANSACTION_INIT);
$table->string('ip', 20)->nullable();
$table->timestamp('payment_date')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop($this->getTable());
}
}
50 changes: 50 additions & 0 deletions migrations/2016_05_02_193229_create_gateway_status_log_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGatewayStatusLogTable extends Migration
{

function getTable()
{
return config('gateway.table','gateway_transactions');
}

function getLogTable()
{
return $this->getTable().'_logs';
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create($this->getLogTable(), function (Blueprint $table) {
$table->engine="innoDB";
$table->increments('id');
$table->unsignedInteger('transaction_id');
$table->string('result_code', 10)->nullable();
$table->string('result_message', 255)->nullable();
$table->timestamp('log_date')->nullable();

$table
->foreign('transaction_id')
->references('id')
->on($this->getTable())
->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop($this->getLogTable());
}
}
88 changes: 51 additions & 37 deletions src/GatewayServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,55 @@

class GatewayServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=config
$this->publishes([
__DIR__ . '/config/gateway.php' => config_path('gateway.php'),
],'config');

// php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=migrations
$this->publishes([
__DIR__.'/migrations/' => database_path('/migrations')
],'migrations');

$this->loadViewsFrom(__DIR__.'/views', 'gateway');

// php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=views
$this->publishes([
__DIR__.'/views/' => base_path('resources/views/vendor/gateway'),
],'views');
}

/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('gateway',function() {
return new GatewayResolver();
});

}
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;

/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$config = __DIR__ . '/../config/gateway.php';
$migrations = __DIR__ . '/../migrations/';
$views = __DIR__ . '/../views/';

//php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=config
$this->publishes([
$config => config_path('gateway.php'),
], 'config');

// php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=migrations
$this->publishes([
$migrations => database_path('/migrations')
], 'migrations');


$this->loadViewsFrom($views, 'gateway');

// php artisan vendor:publish --provider=Larabookir\Gateway\GatewayServiceProvider --tag=views
$this->publishes([
$views => base_path('resources/views/vendor/gateway'),
], 'views');

//$this->mergeConfigFrom( $config,'gateway')
}

/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('gateway', function () {
return new GatewayResolver();
});

}
}
20 changes: 20 additions & 0 deletions views/mellat-redirector.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<body>
<script>
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", "https://bpm.shaparak.ir/pgwchannel/startpay.mellat");
form.setAttribute("target", "_self");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "RefId");
hiddenField.setAttribute("value", "{{$refId}}");
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
</script>
</body>
</html>
6 changes: 6 additions & 0 deletions views/parsian-redirector.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<form action="{!! $url !!}" method="post" id="parsian_gateway"></form>

<script type="text/javascript">
var f=document.getElementById('parsian_gateway');
f.submit();
</script>
10 changes: 10 additions & 0 deletions views/sadad-redirector.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<body>
{!! $form !!}
<br />
<script type="text/javascript">
document.getElementById('paymentUTLfrm').submit();
</script>
</form>
</body>
</html>

0 comments on commit c4f7006

Please sign in to comment.