From 7fb9e345a24fc3f5fdc0bbc4a98e4b61c047c8e4 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Wed, 29 Apr 2026 14:34:01 +0330 Subject: [PATCH] create all FTB services --- backend/Dockerfile | 2 +- .../Services/FIB/AuthorizationService.php | 62 ++++++++++++++++ .../Services/FIB/CancelPaymentService.php | 62 ++++++++++++++++ .../FIB/CheckPaymentStatusService.php | 51 +++++++++++++ .../Services/FIB/CreatePaymentService.php | 73 +++++++++++++++++++ .../app/User/Services/FIB/RefundService.php | 62 ++++++++++++++++ backend/bootstrap/cache/.gitignore | 0 backend/storage/app/.gitignore | 0 backend/storage/app/private/.gitignore | 0 backend/storage/app/public/.gitignore | 0 backend/storage/framework/.gitignore | 0 backend/storage/framework/cache/.gitignore | 0 .../storage/framework/cache/data/.gitignore | 0 backend/storage/framework/sessions/.gitignore | 0 backend/storage/framework/testing/.gitignore | 0 backend/storage/framework/views/.gitignore | 0 backend/storage/logs/.gitignore | 0 nginx/payment.conf | 2 +- 18 files changed, 312 insertions(+), 2 deletions(-) create mode 100644 backend/app/User/Services/FIB/AuthorizationService.php create mode 100644 backend/app/User/Services/FIB/CancelPaymentService.php create mode 100644 backend/app/User/Services/FIB/CheckPaymentStatusService.php create mode 100644 backend/app/User/Services/FIB/CreatePaymentService.php create mode 100644 backend/app/User/Services/FIB/RefundService.php mode change 100644 => 100755 backend/bootstrap/cache/.gitignore mode change 100644 => 100755 backend/storage/app/.gitignore mode change 100644 => 100755 backend/storage/app/private/.gitignore mode change 100644 => 100755 backend/storage/app/public/.gitignore mode change 100644 => 100755 backend/storage/framework/.gitignore mode change 100644 => 100755 backend/storage/framework/cache/.gitignore mode change 100644 => 100755 backend/storage/framework/cache/data/.gitignore mode change 100644 => 100755 backend/storage/framework/sessions/.gitignore mode change 100644 => 100755 backend/storage/framework/testing/.gitignore mode change 100644 => 100755 backend/storage/framework/views/.gitignore mode change 100644 => 100755 backend/storage/logs/.gitignore diff --git a/backend/Dockerfile b/backend/Dockerfile index 7a70c044..3a24367a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -21,7 +21,7 @@ WORKDIR /var/www/payment COPY . . -RUN chmod -R 665 /var/www/payment/storage /var/www/payment/bootstrap/cache +RUN chmod -R 775 /var/www/payment/storage /var/www/payment/bootstrap/cache # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer diff --git a/backend/app/User/Services/FIB/AuthorizationService.php b/backend/app/User/Services/FIB/AuthorizationService.php new file mode 100644 index 00000000..03a3ce9e --- /dev/null +++ b/backend/app/User/Services/FIB/AuthorizationService.php @@ -0,0 +1,62 @@ +url = config(''); + $this->channelName = ''; + } + + public function setInputParameters(): void + { + $this->inputParameters = [ + 'client_id' => config('fib.authorization.client_id'), + 'client_secret' => config('fib.authorization.client_secret'), + 'grant_type' => 'client_credentials', + ]; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::withHeaders(['Content-Type' => 'application/json']) + ->throw() + ->withoutVerifying() + ->post($this->url, $this->inputParameters) + ->json(); + } +} diff --git a/backend/app/User/Services/FIB/CancelPaymentService.php b/backend/app/User/Services/FIB/CancelPaymentService.php new file mode 100644 index 00000000..dd46aee0 --- /dev/null +++ b/backend/app/User/Services/FIB/CancelPaymentService.php @@ -0,0 +1,62 @@ +url = config(''); + $this->channelName = ''; + } + + public function setHeaders(): void + { + $this->headers = [ + 'Authorization' => 'Bearer ' . $this->accessToken, + 'Content-Type' => 'application/json', + ]; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::withHeaders($this->headers) + ->throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } +} diff --git a/backend/app/User/Services/FIB/CheckPaymentStatusService.php b/backend/app/User/Services/FIB/CheckPaymentStatusService.php new file mode 100644 index 00000000..a956dda1 --- /dev/null +++ b/backend/app/User/Services/FIB/CheckPaymentStatusService.php @@ -0,0 +1,51 @@ +url = config(''); + $this->channelName = ''; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } +} diff --git a/backend/app/User/Services/FIB/CreatePaymentService.php b/backend/app/User/Services/FIB/CreatePaymentService.php new file mode 100644 index 00000000..6b744503 --- /dev/null +++ b/backend/app/User/Services/FIB/CreatePaymentService.php @@ -0,0 +1,73 @@ +url = config(''); + $this->channelName = ''; + } + + public function setAccessToken(string $accessToken): void + { + $this->accessToken = $accessToken; + } + + public function setHeaders(): void + { + $this->headers = [ + 'Authorization' => 'Bearer ' . $this->accessToken, + 'Content-Type' => 'application/json', + ]; + } + + public function setInputParameters(array $inputParameters): void + { + $this->inputParameters = $inputParameters; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::withHeaders($this->headers) + ->throw() + ->withoutVerifying() + ->post($this->url, $this->inputParameters) + ->json(); + } +} diff --git a/backend/app/User/Services/FIB/RefundService.php b/backend/app/User/Services/FIB/RefundService.php new file mode 100644 index 00000000..e0cf197f --- /dev/null +++ b/backend/app/User/Services/FIB/RefundService.php @@ -0,0 +1,62 @@ +url = config(''); + $this->channelName = ''; + } + + public function setHeaders(): void + { + $this->headers = [ + 'Authorization' => 'Bearer ' . $this->accessToken, + 'Content-Type' => 'application/json', + ]; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::withHeaders($this->headers) + ->throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } +} diff --git a/backend/bootstrap/cache/.gitignore b/backend/bootstrap/cache/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/app/.gitignore b/backend/storage/app/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/app/private/.gitignore b/backend/storage/app/private/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/app/public/.gitignore b/backend/storage/app/public/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/.gitignore b/backend/storage/framework/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/cache/.gitignore b/backend/storage/framework/cache/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/cache/data/.gitignore b/backend/storage/framework/cache/data/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/sessions/.gitignore b/backend/storage/framework/sessions/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/testing/.gitignore b/backend/storage/framework/testing/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/views/.gitignore b/backend/storage/framework/views/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/logs/.gitignore b/backend/storage/logs/.gitignore old mode 100644 new mode 100755 diff --git a/nginx/payment.conf b/nginx/payment.conf index afcf76bb..beee1ff4 100644 --- a/nginx/payment.conf +++ b/nginx/payment.conf @@ -12,7 +12,7 @@ server { fastcgi_pass laravel:9000; fastcgi_index index.php; fastcgi_hide_header X-Powered-By; - fastcgi_param SCRIPT_FILENAME /var/www/payment/backend/public/index.php; + fastcgi_param SCRIPT_FILENAME /var/www/payment/public/index.php; } location ~ /\.(?!well-known).* {