From 5ea986db40b22e85cfcafcb2c240614d69c42a54 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Mon, 18 May 2026 14:34:28 +0330 Subject: [PATCH] separate any gateways --- .../{GatewayCategory.php => BusinessType.php} | 6 +-- backend/app/Models/FibTransaction.php | 12 +++++ backend/app/Models/FibTransactionStatus.php | 12 +++++ .../Models/{Gateway.php => Transaction.php} | 6 +-- backend/app/Models/UserGateway.php | 15 +++++++ ...oryFactory.php => BusinessTypeFactory.php} | 6 +-- .../factories/FibTransactionFactory.php | 24 ++++++++++ .../factories/FibTransactionStatusFactory.php | 24 ++++++++++ ...ewayFactory.php => TransactionFactory.php} | 6 +-- .../database/factories/UserGatewayFactory.php | 24 ++++++++++ ...17_053831_create_business_types_table.php} | 4 +- ..._17_053832_create_user_gateways_table.php} | 8 ++-- ...026_05_17_053833_create_payments_table.php | 2 +- ...05_18_095610_create_transactions_table.php | 37 +++++++++++++++ ..._create_fib_transaction_statuses_table.php | 28 ++++++++++++ ...8_104524_create_fib_transactions_table.php | 45 +++++++++++++++++++ ...egorySeeder.php => BusinessTypeSeeder.php} | 2 +- .../database/seeders/FibTransactionSeeder.php | 17 +++++++ .../seeders/FibTransactionStatusSeeder.php | 17 +++++++ ...atewaySeeder.php => TransactionSeeder.php} | 2 +- .../database/seeders/UserGatewaySeeder.php | 17 +++++++ 21 files changed, 293 insertions(+), 21 deletions(-) rename backend/app/Models/{GatewayCategory.php => BusinessType.php} (57%) create mode 100644 backend/app/Models/FibTransaction.php create mode 100644 backend/app/Models/FibTransactionStatus.php rename backend/app/Models/{Gateway.php => Transaction.php} (60%) create mode 100644 backend/app/Models/UserGateway.php rename backend/database/factories/{GatewayCategoryFactory.php => BusinessTypeFactory.php} (72%) create mode 100644 backend/database/factories/FibTransactionFactory.php create mode 100644 backend/database/factories/FibTransactionStatusFactory.php rename backend/database/factories/{GatewayFactory.php => TransactionFactory.php} (74%) create mode 100644 backend/database/factories/UserGatewayFactory.php rename backend/database/migrations/{2026_05_17_053831_create_gateway_categories_table.php => 2026_05_17_053831_create_business_types_table.php} (78%) rename backend/database/migrations/{2026_05_17_053832_create_gateways_table.php => 2026_05_17_053832_create_user_gateways_table.php} (76%) create mode 100644 backend/database/migrations/2026_05_18_095610_create_transactions_table.php create mode 100644 backend/database/migrations/2026_05_18_104523_create_fib_transaction_statuses_table.php create mode 100644 backend/database/migrations/2026_05_18_104524_create_fib_transactions_table.php rename backend/database/seeders/{GatewayCategorySeeder.php => BusinessTypeSeeder.php} (84%) create mode 100644 backend/database/seeders/FibTransactionSeeder.php create mode 100644 backend/database/seeders/FibTransactionStatusSeeder.php rename backend/database/seeders/{GatewaySeeder.php => TransactionSeeder.php} (85%) create mode 100644 backend/database/seeders/UserGatewaySeeder.php diff --git a/backend/app/Models/GatewayCategory.php b/backend/app/Models/BusinessType.php similarity index 57% rename from backend/app/Models/GatewayCategory.php rename to backend/app/Models/BusinessType.php index dd1e29df..c5b42f2e 100644 --- a/backend/app/Models/GatewayCategory.php +++ b/backend/app/Models/BusinessType.php @@ -2,13 +2,13 @@ namespace App\Models; -use Database\Factories\GatewayCategoryFactory; +use Database\Factories\BusinessTypeFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -class GatewayCategory extends Model +class BusinessType extends Model { - /** @use HasFactory */ + /** @use HasFactory */ use HasFactory; protected $guarded = ['id']; diff --git a/backend/app/Models/FibTransaction.php b/backend/app/Models/FibTransaction.php new file mode 100644 index 00000000..23c37102 --- /dev/null +++ b/backend/app/Models/FibTransaction.php @@ -0,0 +1,12 @@ + */ + use HasFactory; +} diff --git a/backend/app/Models/FibTransactionStatus.php b/backend/app/Models/FibTransactionStatus.php new file mode 100644 index 00000000..1f7d4125 --- /dev/null +++ b/backend/app/Models/FibTransactionStatus.php @@ -0,0 +1,12 @@ + */ + use HasFactory; +} diff --git a/backend/app/Models/Gateway.php b/backend/app/Models/Transaction.php similarity index 60% rename from backend/app/Models/Gateway.php rename to backend/app/Models/Transaction.php index d7b58f9c..a685ed3d 100644 --- a/backend/app/Models/Gateway.php +++ b/backend/app/Models/Transaction.php @@ -2,13 +2,13 @@ namespace App\Models; -use Database\Factories\GatewayFactory; +use Database\Factories\TransactionFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -class Gateway extends Model +class Transaction extends Model { - /** @use HasFactory */ + /** @use HasFactory */ use HasFactory; protected $guarded = ['id']; diff --git a/backend/app/Models/UserGateway.php b/backend/app/Models/UserGateway.php new file mode 100644 index 00000000..c1bd6f5e --- /dev/null +++ b/backend/app/Models/UserGateway.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/database/factories/GatewayCategoryFactory.php b/backend/database/factories/BusinessTypeFactory.php similarity index 72% rename from backend/database/factories/GatewayCategoryFactory.php rename to backend/database/factories/BusinessTypeFactory.php index facefb5e..e4f420cb 100644 --- a/backend/database/factories/GatewayCategoryFactory.php +++ b/backend/database/factories/BusinessTypeFactory.php @@ -2,13 +2,13 @@ namespace Database\Factories; -use App\Models\GatewayCategory; +use App\Models\BusinessType; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends Factory + * @extends Factory */ -class GatewayCategoryFactory extends Factory +class BusinessTypeFactory extends Factory { /** * Define the model's default state. diff --git a/backend/database/factories/FibTransactionFactory.php b/backend/database/factories/FibTransactionFactory.php new file mode 100644 index 00000000..5fc97df6 --- /dev/null +++ b/backend/database/factories/FibTransactionFactory.php @@ -0,0 +1,24 @@ + + */ +class FibTransactionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/FibTransactionStatusFactory.php b/backend/database/factories/FibTransactionStatusFactory.php new file mode 100644 index 00000000..94676e04 --- /dev/null +++ b/backend/database/factories/FibTransactionStatusFactory.php @@ -0,0 +1,24 @@ + + */ +class FibTransactionStatusFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/GatewayFactory.php b/backend/database/factories/TransactionFactory.php similarity index 74% rename from backend/database/factories/GatewayFactory.php rename to backend/database/factories/TransactionFactory.php index f8029ab5..9f46bf36 100644 --- a/backend/database/factories/GatewayFactory.php +++ b/backend/database/factories/TransactionFactory.php @@ -2,13 +2,13 @@ namespace Database\Factories; -use App\Models\Gateway; +use App\Models\Transaction; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends Factory + * @extends Factory */ -class GatewayFactory extends Factory +class TransactionFactory extends Factory { /** * Define the model's default state. diff --git a/backend/database/factories/UserGatewayFactory.php b/backend/database/factories/UserGatewayFactory.php new file mode 100644 index 00000000..46062b0f --- /dev/null +++ b/backend/database/factories/UserGatewayFactory.php @@ -0,0 +1,24 @@ + + */ +class UserGatewayFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/migrations/2026_05_17_053831_create_gateway_categories_table.php b/backend/database/migrations/2026_05_17_053831_create_business_types_table.php similarity index 78% rename from backend/database/migrations/2026_05_17_053831_create_gateway_categories_table.php rename to backend/database/migrations/2026_05_17_053831_create_business_types_table.php index 16ee53ea..61e834f5 100644 --- a/backend/database/migrations/2026_05_17_053831_create_gateway_categories_table.php +++ b/backend/database/migrations/2026_05_17_053831_create_business_types_table.php @@ -11,7 +11,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gateway_categories', function (Blueprint $table) { + Schema::create('business_types', function (Blueprint $table) { $table->id(); $table->string('name'); $table->timestamps(); @@ -23,6 +23,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('gateway_categories'); + Schema::dropIfExists('business_types'); } }; diff --git a/backend/database/migrations/2026_05_17_053832_create_gateways_table.php b/backend/database/migrations/2026_05_17_053832_create_user_gateways_table.php similarity index 76% rename from backend/database/migrations/2026_05_17_053832_create_gateways_table.php rename to backend/database/migrations/2026_05_17_053832_create_user_gateways_table.php index faab5d50..d72d530b 100644 --- a/backend/database/migrations/2026_05_17_053832_create_gateways_table.php +++ b/backend/database/migrations/2026_05_17_053832_create_user_gateways_table.php @@ -11,7 +11,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gateways', function (Blueprint $table) { + Schema::create('user_gateways', function (Blueprint $table) { $table->id(); $table->foreignId('user_id')->constrained('users'); $table->string('username'); @@ -22,8 +22,8 @@ return new class extends Migration $table->string('account_holder'); $table->string('logo')->nullable(); $table->string('iban'); - $table->foreignId('category_id')->constrained('gateway_categories'); - $table->string('category_name'); + $table->foreignId('business_type_id')->constrained('business_types'); + $table->string('business_type_name'); $table->timestamps(); }); } @@ -33,6 +33,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('gateways'); + Schema::dropIfExists('user_gateways'); } }; diff --git a/backend/database/migrations/2026_05_17_053833_create_payments_table.php b/backend/database/migrations/2026_05_17_053833_create_payments_table.php index 0bf5cc2e..815bfa82 100644 --- a/backend/database/migrations/2026_05_17_053833_create_payments_table.php +++ b/backend/database/migrations/2026_05_17_053833_create_payments_table.php @@ -23,7 +23,7 @@ return new class extends Migration $table->foreignId('status_id')->constrained('payment_statuses'); $table->string('status_name'); $table->ipAddress('ip'); - $table->foreignId('gateway_id')->constrained('gateways'); + $table->foreignId('user_gateway_id')->constrained('user_gateways'); $table->timestamps(); }); } diff --git a/backend/database/migrations/2026_05_18_095610_create_transactions_table.php b/backend/database/migrations/2026_05_18_095610_create_transactions_table.php new file mode 100644 index 00000000..7176a51f --- /dev/null +++ b/backend/database/migrations/2026_05_18_095610_create_transactions_table.php @@ -0,0 +1,37 @@ +id(); + $table->foreignId('user_id')->constrained('users'); + $table->string('amount'); + $table->string('currency'); + $table->string('callback_url'); + $table->string('description'); + $table->dateTime('expires_in'); + $table->foreignId('payment_id')->constrained('payments'); + $table->string('payment_track_id'); + $table->foreignId('gateway_id')->constrained('gateways'); + $table->integer('status'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('transactions'); + } +}; diff --git a/backend/database/migrations/2026_05_18_104523_create_fib_transaction_statuses_table.php b/backend/database/migrations/2026_05_18_104523_create_fib_transaction_statuses_table.php new file mode 100644 index 00000000..f984ce18 --- /dev/null +++ b/backend/database/migrations/2026_05_18_104523_create_fib_transaction_statuses_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('fib_transaction_statuses'); + } +}; diff --git a/backend/database/migrations/2026_05_18_104524_create_fib_transactions_table.php b/backend/database/migrations/2026_05_18_104524_create_fib_transactions_table.php new file mode 100644 index 00000000..3e914953 --- /dev/null +++ b/backend/database/migrations/2026_05_18_104524_create_fib_transactions_table.php @@ -0,0 +1,45 @@ +id(); + $table->foreignId('transaction_id')->constrained('transactions'); + $table->text('qrcode'); + $table->string('readable_code'); + $table->string('personalAppLink'); + $table->string('businessAppLink'); + $table->string('corporateAppLink'); + $table->string('paymentId'); + $table->string('paymentMethod'); + $table->timestamp('validUntil'); + $table->foreignId('status_id')->constrained('fib_transaction_statuses'); + $table->string('status_name'); + $table->timestamp('paidAt'); + $table->string('paidAmount'); + $table->string('paidCurrency'); + $table->string('decliningReason'); + $table->timestamp('declinedAt'); + $table->string('paidByName'); + $table->string('paidByIban'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('fib_transactions'); + } +}; diff --git a/backend/database/seeders/GatewayCategorySeeder.php b/backend/database/seeders/BusinessTypeSeeder.php similarity index 84% rename from backend/database/seeders/GatewayCategorySeeder.php rename to backend/database/seeders/BusinessTypeSeeder.php index 6e41f3b8..d73d8340 100644 --- a/backend/database/seeders/GatewayCategorySeeder.php +++ b/backend/database/seeders/BusinessTypeSeeder.php @@ -5,7 +5,7 @@ namespace Database\Seeders; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; -class GatewayCategorySeeder extends Seeder +class BusinessTypeSeeder extends Seeder { /** * Run the database seeds. diff --git a/backend/database/seeders/FibTransactionSeeder.php b/backend/database/seeders/FibTransactionSeeder.php new file mode 100644 index 00000000..f7749949 --- /dev/null +++ b/backend/database/seeders/FibTransactionSeeder.php @@ -0,0 +1,17 @@ +