From e53a89016f3130d2e60504e27017e2da7eb22d6a Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 17 May 2026 13:57:39 +0330 Subject: [PATCH 1/2] create payment and gateway resources --- backend/app/Models/Gateway.php | 15 ++++++++ backend/app/Models/GatewayCategory.php | 12 ++++++ backend/app/Models/Payment.php | 15 ++++++++ backend/app/Models/PaymentStatus.php | 12 ++++++ .../Services/FIB/AuthorizationService.php | 2 +- .../Services/FIB/CancelPaymentService.php | 2 +- .../FIB/CheckPaymentStatusService.php | 2 +- .../Services/FIB/CreatePaymentService.php | 2 +- .../{User => }/Services/FIB/RefundService.php | 2 +- .../factories/GatewayCategoryFactory.php | 24 ++++++++++++ backend/database/factories/GatewayFactory.php | 24 ++++++++++++ backend/database/factories/PaymentFactory.php | 24 ++++++++++++ .../factories/PaymentStatusFactory.php | 24 ++++++++++++ ...7_053830_create_payment_statuses_table.php | 28 ++++++++++++++ ...053831_create_gateway_categories_table.php | 28 ++++++++++++++ ...026_05_17_053832_create_gateways_table.php | 38 +++++++++++++++++++ ...026_05_17_053833_create_payments_table.php | 38 +++++++++++++++++++ .../seeders/GatewayCategorySeeder.php | 17 +++++++++ backend/database/seeders/GatewaySeeder.php | 17 +++++++++ backend/database/seeders/PaymentSeeder.php | 17 +++++++++ .../database/seeders/PaymentStatusSeeder.php | 17 +++++++++ 21 files changed, 355 insertions(+), 5 deletions(-) create mode 100644 backend/app/Models/Gateway.php create mode 100644 backend/app/Models/GatewayCategory.php create mode 100644 backend/app/Models/Payment.php create mode 100644 backend/app/Models/PaymentStatus.php rename backend/app/{User => }/Services/FIB/AuthorizationService.php (97%) rename backend/app/{User => }/Services/FIB/CancelPaymentService.php (97%) rename backend/app/{User => }/Services/FIB/CheckPaymentStatusService.php (96%) rename backend/app/{User => }/Services/FIB/CreatePaymentService.php (98%) rename backend/app/{User => }/Services/FIB/RefundService.php (97%) create mode 100644 backend/database/factories/GatewayCategoryFactory.php create mode 100644 backend/database/factories/GatewayFactory.php create mode 100644 backend/database/factories/PaymentFactory.php create mode 100644 backend/database/factories/PaymentStatusFactory.php create mode 100644 backend/database/migrations/2026_05_17_053830_create_payment_statuses_table.php create mode 100644 backend/database/migrations/2026_05_17_053831_create_gateway_categories_table.php create mode 100644 backend/database/migrations/2026_05_17_053832_create_gateways_table.php create mode 100644 backend/database/migrations/2026_05_17_053833_create_payments_table.php create mode 100644 backend/database/seeders/GatewayCategorySeeder.php create mode 100644 backend/database/seeders/GatewaySeeder.php create mode 100644 backend/database/seeders/PaymentSeeder.php create mode 100644 backend/database/seeders/PaymentStatusSeeder.php diff --git a/backend/app/Models/Gateway.php b/backend/app/Models/Gateway.php new file mode 100644 index 00000000..d7b58f9c --- /dev/null +++ b/backend/app/Models/Gateway.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/GatewayCategory.php b/backend/app/Models/GatewayCategory.php new file mode 100644 index 00000000..a6e44afe --- /dev/null +++ b/backend/app/Models/GatewayCategory.php @@ -0,0 +1,12 @@ + */ + use HasFactory; +} diff --git a/backend/app/Models/Payment.php b/backend/app/Models/Payment.php new file mode 100644 index 00000000..f4d1f85a --- /dev/null +++ b/backend/app/Models/Payment.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/PaymentStatus.php b/backend/app/Models/PaymentStatus.php new file mode 100644 index 00000000..c222ee0e --- /dev/null +++ b/backend/app/Models/PaymentStatus.php @@ -0,0 +1,12 @@ + */ + use HasFactory; +} diff --git a/backend/app/User/Services/FIB/AuthorizationService.php b/backend/app/Services/FIB/AuthorizationService.php similarity index 97% rename from backend/app/User/Services/FIB/AuthorizationService.php rename to backend/app/Services/FIB/AuthorizationService.php index 9e67d55d..9867133f 100755 --- a/backend/app/User/Services/FIB/AuthorizationService.php +++ b/backend/app/Services/FIB/AuthorizationService.php @@ -1,6 +1,6 @@ + */ +class GatewayCategoryFactory 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/GatewayFactory.php new file mode 100644 index 00000000..f8029ab5 --- /dev/null +++ b/backend/database/factories/GatewayFactory.php @@ -0,0 +1,24 @@ + + */ +class GatewayFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/PaymentFactory.php b/backend/database/factories/PaymentFactory.php new file mode 100644 index 00000000..8bfd4911 --- /dev/null +++ b/backend/database/factories/PaymentFactory.php @@ -0,0 +1,24 @@ + + */ +class PaymentFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/PaymentStatusFactory.php b/backend/database/factories/PaymentStatusFactory.php new file mode 100644 index 00000000..390010db --- /dev/null +++ b/backend/database/factories/PaymentStatusFactory.php @@ -0,0 +1,24 @@ + + */ +class PaymentStatusFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/migrations/2026_05_17_053830_create_payment_statuses_table.php b/backend/database/migrations/2026_05_17_053830_create_payment_statuses_table.php new file mode 100644 index 00000000..754a8790 --- /dev/null +++ b/backend/database/migrations/2026_05_17_053830_create_payment_statuses_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('payment_statuses'); + } +}; diff --git a/backend/database/migrations/2026_05_17_053831_create_gateway_categories_table.php b/backend/database/migrations/2026_05_17_053831_create_gateway_categories_table.php new file mode 100644 index 00000000..16ee53ea --- /dev/null +++ b/backend/database/migrations/2026_05_17_053831_create_gateway_categories_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('gateway_categories'); + } +}; diff --git a/backend/database/migrations/2026_05_17_053832_create_gateways_table.php b/backend/database/migrations/2026_05_17_053832_create_gateways_table.php new file mode 100644 index 00000000..faab5d50 --- /dev/null +++ b/backend/database/migrations/2026_05_17_053832_create_gateways_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('user_id')->constrained('users'); + $table->string('username'); + $table->string('name'); + $table->string('domain'); + $table->string('tax_id'); + $table->string('bank_name'); + $table->string('account_holder'); + $table->string('logo')->nullable(); + $table->string('iban'); + $table->foreignId('category_id')->constrained('gateway_categories'); + $table->string('category_name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('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 new file mode 100644 index 00000000..0bf5cc2e --- /dev/null +++ b/backend/database/migrations/2026_05_17_053833_create_payments_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('user_id')->constrained('users'); + $table->string('username'); + $table->uuid('track_id'); + $table->string('amount'); + $table->string('currency'); + $table->string('callback_url'); + $table->dateTime('expires_at'); + $table->foreignId('status_id')->constrained('payment_statuses'); + $table->string('status_name'); + $table->ipAddress('ip'); + $table->foreignId('gateway_id')->constrained('gateways'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('payments'); + } +}; diff --git a/backend/database/seeders/GatewayCategorySeeder.php b/backend/database/seeders/GatewayCategorySeeder.php new file mode 100644 index 00000000..6e41f3b8 --- /dev/null +++ b/backend/database/seeders/GatewayCategorySeeder.php @@ -0,0 +1,17 @@ + Date: Sun, 17 May 2026 14:00:33 +0330 Subject: [PATCH 2/2] add gaurded values --- backend/app/Models/GatewayCategory.php | 5 ++++- backend/app/Models/PaymentStatus.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/app/Models/GatewayCategory.php b/backend/app/Models/GatewayCategory.php index a6e44afe..dd1e29df 100644 --- a/backend/app/Models/GatewayCategory.php +++ b/backend/app/Models/GatewayCategory.php @@ -2,11 +2,14 @@ namespace App\Models; +use Database\Factories\GatewayCategoryFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class GatewayCategory extends Model { - /** @use HasFactory<\Database\Factories\GatewayCategoryFactory> */ + /** @use HasFactory */ use HasFactory; + + protected $guarded = ['id']; } diff --git a/backend/app/Models/PaymentStatus.php b/backend/app/Models/PaymentStatus.php index c222ee0e..b173c343 100644 --- a/backend/app/Models/PaymentStatus.php +++ b/backend/app/Models/PaymentStatus.php @@ -2,11 +2,14 @@ namespace App\Models; +use Database\Factories\PaymentStatusFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class PaymentStatus extends Model { - /** @use HasFactory<\Database\Factories\PaymentStatusFactory> */ + /** @use HasFactory */ use HasFactory; + + protected $guarded = ['id']; }