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 6, 2016
1 parent c402399 commit 95056a7
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/GatewayResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __call($name, $arguments)
*/
function getTable()
{
return DB::table($this->config->get('gateway.db_tables.transactions'));
return DB::table($this->config->get('gateway.table'));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/JahanPay/JahanPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Larabookir\Gateway\JahanPay;

use Illuminate\Support\Facades\Input;
use Larabookir\Gateway\Enum;
use SoapClient;
use Larabookir\Gateway\PortAbstract;
Expand Down Expand Up @@ -133,7 +134,7 @@ protected function sendPayRequest()
*/
protected function userPayment()
{
$refId = @$_GET['au'];
$refId = Input::get('au');

if ($this->refId() != $refId) {
$this->transactionFailed();
Expand Down
9 changes: 5 additions & 4 deletions src/Mellat/Mellat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Larabookir\Gateway\Mellat;

use DateTime;
use Illuminate\Support\Facades\Input;
use Larabookir\Gateway\Enum;
use SoapClient;
use Larabookir\Gateway\PortAbstract;
Expand Down Expand Up @@ -139,10 +140,10 @@ protected function sendPayRequest()
*/
protected function userPayment()
{
$this->refId = @$_POST['RefId'];
$this->trackingCode = @$_POST['SaleReferenceId'];
$this->cardNumber = @$_POST['CardHolderPan'];
$payRequestResCode = @$_POST['ResCode'];
$this->refId = Input::get('RefId');
$this->trackingCode = Input::get('SaleReferenceId');
$this->cardNumber = Input::get('CardHolderPan');
$payRequestResCode = Input::get('ResCode');

if ($payRequestResCode == '0') {
return true;
Expand Down
7 changes: 4 additions & 3 deletions src/Parsian/Parsian.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Larabookir\Gateway\Parsian;

use Illuminate\Support\Facades\Input;
use SoapClient;
use Larabookir\Gateway\PortAbstract;
use Larabookir\Gateway\PortInterface;
Expand Down Expand Up @@ -144,11 +145,11 @@ protected function sendPayRequest()
*/
protected function verifyPayment()
{
if (!isset($_REQUEST['au']) && !isset($_REQUEST['rs']))
if (!isset(Input::get('au')) && !isset(Input::get('rs')))
throw new ParsianErrorException('درخواست غیر معتبر', -1);

$authority = $_REQUEST['au'];
$status = $_REQUEST['rs'];
$authority = Input::get('au');
$status = Input::get('rs');

if ($status != 0) {
$errorMessage = ParsianResult::errorMessage($status);
Expand Down
5 changes: 3 additions & 2 deletions src/Payline/Payline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Larabookir\Gateway\Payline;

use Illuminate\Support\Facades\Input;
use Larabookir\Gateway\Enum;
use Larabookir\Gateway\PortAbstract;
use Larabookir\Gateway\PortInterface;
Expand Down Expand Up @@ -140,8 +141,8 @@ protected function sendPayRequest()
*/
protected function userPayment()
{
$this->refIf = @$_POST['id_get'];
$trackingCode = @$_POST['trans_id'];
$this->refIf = Input::get('id_get');
$trackingCode = Input::get('trans_id');

if (is_numeric($trackingCode) && $trackingCode > 0) {
$this->trackingCode = $trackingCode;
Expand Down
26 changes: 15 additions & 11 deletions src/PortAbstract.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace Larabookir\Gateway;

use Illuminate\Support\Facades\Request;
use Larabookir\Gateway\Enum;
use Carbon\Carbon;

abstract class PortAbstract
{
Expand Down Expand Up @@ -86,15 +88,15 @@ function setConfig($config)
*/
function getTable()
{
return $this->db->table($this->config->get('gateway.db_tables.transactions'));
return $this->db->table($this->config->get('gateway.table'));
}

/**
* @return mixed
*/
function getLogTable()
{
return $this->db->table($this->config->get('gateway.db_tables.logs'));
return $this->db->table($this->config->get('gateway.table') . '_logs');
}

/**
Expand All @@ -114,7 +116,7 @@ function getPortName()
*/
function setPortName($name)
{
$this->portName=$name;
$this->portName = $name;
}

/**
Expand Down Expand Up @@ -158,7 +160,8 @@ function refId()
* @param $price
* @return mixed
*/
function price($price){
function price($price)
{
return $this->set($price);
}

Expand Down Expand Up @@ -191,8 +194,9 @@ protected function newTransaction()
'port' => $this->getPortName(),
'price' => $this->amount,
'status' => Enum::TRANSACTION_INIT,
'created_at' => time(),
'updated_at' => time(),
'ip' => Request::getClientIp(),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]);

return $this->transactionId;
Expand All @@ -210,8 +214,8 @@ protected function transactionSucceed()
'status' => Enum::TRANSACTION_SUCCEED,
'tracking_code' => $this->trackingCode,
'card_number' => $this->cardNumber,
'payment_date' => time(),
'updated_at' => time(),
'payment_date' => Carbon::now(),
'updated_at' => Carbon::now(),
]);
}

Expand All @@ -225,7 +229,7 @@ protected function transactionFailed()
{
return $this->getTable()->whereId($this->transactionId)->update([
'status' => Enum::TRANSACTION_FAILED,
'updated_at' => time(),
'updated_at' => Carbon::now(),
]);
}

Expand All @@ -238,7 +242,7 @@ protected function transactionSetRefId()
{
return $this->getTable()->whereId($this->transactionId)->update([
'ref_id' => $this->refId,
'updated_at' => time(),
'updated_at' => Carbon::now(),
]);

}
Expand All @@ -255,7 +259,7 @@ protected function newLog($statusCode, $statusMessage)
'transaction_id' => $this->transactionId,
'result_code' => $statusCode,
'result_message' => $statusMessage,
'log_date' => time(),
'log_date' => Carbon::now(),
]);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Zarinpal/Zarinpal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Larabookir\Gateway\Zarinpal;

use DateTime;
use Illuminate\Support\Facades\Input;
use Larabookir\Gateway\Enum;
use SoapClient;
use Larabookir\Gateway\PortAbstract;
Expand Down Expand Up @@ -173,8 +174,8 @@ protected function sendPayRequest()
*/
protected function userPayment()
{
$this->authority = @$_GET['Authority'];
$status = @$_GET['Status'];
$this->authority = Input::get('Authority');
$status = Input::get('Status');

if ($status == 'OK') {
return true;
Expand Down
5 changes: 1 addition & 4 deletions src/config/gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,5 @@
//-------------------------------
// Tables names
//--------------------------------
'db_tables' => [
'transactions' => 'gateway_transactions',
'logs' => 'gateway_status_log',
],
'table'=>=> 'gateway_transactions',
];
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

class CreateGatewayTransactionsTable extends Migration
{
private $table = 'gateway_transactions';

function getTable()
{
return config('gateway.db_tables.transactions', $this->table);
return config('gateway.table', 'gateway_transactions');
}

/**
Expand Down Expand Up @@ -42,8 +40,8 @@ public function up()
Enum::TRANSACTION_SUCCEED,
Enum::TRANSACTION_FAILED,
])->default(Enum::TRANSACTION_INIT);
$table->string('ip', 20)->nullable();
$table->timestamp('payment_date')->nullable();

$table->timestamps();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

class CreateGatewayStatusLogTable extends Migration
{
private $table = 'gateway_status_log';

function getTable()
{
return config('gateway.db_tables.logs',$this->table);
return config('gateway.table','gateway_transactions').'_logs';
}
/**
* Run the migrations.
Expand Down

0 comments on commit 95056a7

Please sign in to comment.