From 60ec8bb94f9d6e5b44c00d254e5ac0bd45735753 Mon Sep 17 00:00:00 2001 From: Mahdi Jedari Date: Sun, 30 Jan 2022 20:58:21 +0330 Subject: [PATCH 1/2] remove unused imports $ add import Schema facade in migrations --- .../2016_05_02_193213_create_gateway_transactions_table.php | 3 +-- .../2016_05_02_193229_create_gateway_status_log_table.php | 2 +- .../2017_04_05_103357_alter_id_in_transactions_table.php | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/migrations/2016_05_02_193213_create_gateway_transactions_table.php b/migrations/2016_05_02_193213_create_gateway_transactions_table.php index f87a50d6..f35cec9f 100644 --- a/migrations/2016_05_02_193213_create_gateway_transactions_table.php +++ b/migrations/2016_05_02_193213_create_gateway_transactions_table.php @@ -2,8 +2,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -use Larabookir\Gateway\PortAbstract; -use Larabookir\Gateway\GatewayResolver; +use Illuminate\Support\Facades\Schema; use Larabookir\Gateway\Enum; class CreateGatewayTransactionsTable extends Migration diff --git a/migrations/2016_05_02_193229_create_gateway_status_log_table.php b/migrations/2016_05_02_193229_create_gateway_status_log_table.php index 0607bca1..d437bf19 100644 --- a/migrations/2016_05_02_193229_create_gateway_status_log_table.php +++ b/migrations/2016_05_02_193229_create_gateway_status_log_table.php @@ -2,7 +2,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; - +use Illuminate\Support\Facades\Schema; class CreateGatewayStatusLogTable extends Migration { diff --git a/migrations/2017_04_05_103357_alter_id_in_transactions_table.php b/migrations/2017_04_05_103357_alter_id_in_transactions_table.php index 7928593b..3ceb0fa8 100644 --- a/migrations/2017_04_05_103357_alter_id_in_transactions_table.php +++ b/migrations/2017_04_05_103357_alter_id_in_transactions_table.php @@ -1,8 +1,6 @@ Date: Mon, 31 Jan 2022 18:29:52 +0330 Subject: [PATCH 2/2] add wallet --- ...3213_create_gateway_transactions_table.php | 2 + ...193229_create_gateway_status_log_table.php | 1 + ...dd_description_to_gateway_transactions.php | 37 ------------------- src/Mellat/Mellat.php | 10 +++++ src/PortAbstract.php | 14 +++++++ 5 files changed, 27 insertions(+), 37 deletions(-) delete mode 100644 migrations/2018_03_04_224213_add_description_to_gateway_transactions.php diff --git a/migrations/2016_05_02_193213_create_gateway_transactions_table.php b/migrations/2016_05_02_193213_create_gateway_transactions_table.php index f35cec9f..e7998a52 100644 --- a/migrations/2016_05_02_193213_create_gateway_transactions_table.php +++ b/migrations/2016_05_02_193213_create_gateway_transactions_table.php @@ -24,6 +24,7 @@ public function up() Schema::create($this->getTable(), function (Blueprint $table) { $table->engine = "innoDB"; $table->unsignedBigInteger('id', true); + $table->unsignedBigInteger('wallet_id'); $table->enum('port', (array) Enum::getIPGs()); $table->decimal('price', 15, 2); $table->string('ref_id', 100)->nullable(); @@ -35,6 +36,7 @@ public function up() Enum::TRANSACTION_FAILED, ])->default(Enum::TRANSACTION_INIT); $table->string('ip', 20)->nullable(); + $table->text('description')->nullable(); $table->timestamp('payment_date')->nullable(); $table->nullableTimestamps(); $table->softDeletes(); diff --git a/migrations/2016_05_02_193229_create_gateway_status_log_table.php b/migrations/2016_05_02_193229_create_gateway_status_log_table.php index d437bf19..c26c5f59 100644 --- a/migrations/2016_05_02_193229_create_gateway_status_log_table.php +++ b/migrations/2016_05_02_193229_create_gateway_status_log_table.php @@ -3,6 +3,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\Schema; + class CreateGatewayStatusLogTable extends Migration { diff --git a/migrations/2018_03_04_224213_add_description_to_gateway_transactions.php b/migrations/2018_03_04_224213_add_description_to_gateway_transactions.php deleted file mode 100644 index e8a427e2..00000000 --- a/migrations/2018_03_04_224213_add_description_to_gateway_transactions.php +++ /dev/null @@ -1,37 +0,0 @@ -getTable(), function (Blueprint $table) { - $table->text('description')->after('ip')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table($this->getTable(), function (Blueprint $table) { - $table->dropColumn('description'); - }); - } -} diff --git a/src/Mellat/Mellat.php b/src/Mellat/Mellat.php index 341c534b..50b8e06d 100644 --- a/src/Mellat/Mellat.php +++ b/src/Mellat/Mellat.php @@ -28,6 +28,16 @@ public function set($amount) return $this; } + /** + * {@inheritdoc} + */ + public function setWallet($id) + { + $this->walletId = $id; + + return $this; + } + /** * {@inheritdoc} */ diff --git a/src/PortAbstract.php b/src/PortAbstract.php index bccbf060..62db661d 100644 --- a/src/PortAbstract.php +++ b/src/PortAbstract.php @@ -45,6 +45,13 @@ abstract class PortAbstract */ protected $refId; + /** + * wallet id + * + * @var string + */ + protected $walletId; + /** * Amount in Rial * @@ -228,6 +235,11 @@ function price($price) return $this->set($price); } + function wallet($id) + { + return $this->setWallet($id); + } + /** * get price */ @@ -250,6 +262,7 @@ function verify($transaction) { $this->transaction = $transaction; $this->transactionId = $transaction->id; + $this->walletId = $transaction->walletId; $this->amount = intval($transaction->price); $this->refId = $transaction->ref_id; } @@ -276,6 +289,7 @@ protected function newTransaction() $this->transactionId = $this->getTable()->insert([ 'id' => $uid, + 'wallet_id' => $this->walletId, 'port' => $this->getPortName(), 'price' => $this->amount, 'status' => Enum::TRANSACTION_INIT,