diff --git a/app/app/Models/LegalEntity.php b/app/app/Models/LegalEntity.php new file mode 100644 index 00000000..4c2cb2fd --- /dev/null +++ b/app/app/Models/LegalEntity.php @@ -0,0 +1,24 @@ + 'boolean', + 'accepts_methods' => 'array', + 'min_amount_rub' => 'decimal:2', + 'max_amount_rub' => 'decimal:2', + ]; + } + + /** Расшифрованные креденшелы шлюза; [] если config пустой/битый. */ + public function credentials(): array + { + if ($this->config === null || $this->config === '') { + return []; + } + + try { + $decoded = Crypt::decrypt($this->config); + } catch (\Throwable) { + return []; + } + + return is_array($decoded) ? $decoded : []; + } +} diff --git a/app/app/Models/SaasTransaction.php b/app/app/Models/SaasTransaction.php new file mode 100644 index 00000000..56f06ea6 --- /dev/null +++ b/app/app/Models/SaasTransaction.php @@ -0,0 +1,45 @@ + 'decimal:2', + 'balance_rub_after' => 'decimal:2', + 'created_at' => 'datetime', + 'completed_at' => 'datetime', + ]; + } +} diff --git a/app/tests/Unit/Billing/PaymentGatewayModelTest.php b/app/tests/Unit/Billing/PaymentGatewayModelTest.php new file mode 100644 index 00000000..3292d431 --- /dev/null +++ b/app/tests/Unit/Billing/PaymentGatewayModelTest.php @@ -0,0 +1,22 @@ +config = Crypt::encrypt(['shop_id' => '123', 'secret_key' => 'test_secret']); + + expect($gw->credentials())->toBe(['shop_id' => '123', 'secret_key' => 'test_secret']); +}); + +it('возвращает пустой массив если config пустой', function () { + $gw = new PaymentGateway; + $gw->config = ''; + + expect($gw->credentials())->toBe([]); +});