Merge pull request 'feature/AuthorizationFIB' (#3) from feature/AuthorizationFIB into develop
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -21,7 +21,7 @@ WORKDIR /var/www/payment
|
|||||||
|
|
||||||
COPY . .
|
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
|
# Install Composer
|
||||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|||||||
62
backend/app/User/Services/FIB/AuthorizationService.php
Normal file
62
backend/app/User/Services/FIB/AuthorizationService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class AuthorizationService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected array $inputParameters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.authorization.url');
|
||||||
|
$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();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
backend/app/User/Services/FIB/CancelPaymentService.php
Normal file
62
backend/app/User/Services/FIB/CancelPaymentService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CancelPaymentService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.cancelPayment.url');
|
||||||
|
$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();
|
||||||
|
}
|
||||||
|
}
|
||||||
51
backend/app/User/Services/FIB/CheckPaymentStatusService.php
Normal file
51
backend/app/User/Services/FIB/CheckPaymentStatusService.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CheckPaymentStatusService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.checkPaymentStatus.url');
|
||||||
|
$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();
|
||||||
|
}
|
||||||
|
}
|
||||||
73
backend/app/User/Services/FIB/CreatePaymentService.php
Normal file
73
backend/app/User/Services/FIB/CreatePaymentService.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CreatePaymentService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
protected array $inputParameters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.createPayment.url');
|
||||||
|
$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();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
backend/app/User/Services/FIB/RefundService.php
Normal file
62
backend/app/User/Services/FIB/RefundService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class RefundService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.refund.url');
|
||||||
|
$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();
|
||||||
|
}
|
||||||
|
}
|
||||||
0
backend/bootstrap/cache/.gitignore
vendored
Normal file → Executable file
0
backend/bootstrap/cache/.gitignore
vendored
Normal file → Executable file
25
backend/config/fib.php
Normal file
25
backend/config/fib.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'authorization' => [
|
||||||
|
'url' => env('FIB_AUTHORIZATION_URL'),
|
||||||
|
'client_id' => env('FIB_CLIENT_ID'),
|
||||||
|
'client_secret' => env('FIB_CLIENT_SECRET'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'createPayment' => [
|
||||||
|
'url' => env('FIB_CREATE_PAYMENT_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'checkPaymentStatus' => [
|
||||||
|
'url' => env('FIB_CHECK_PAYMENT_STATUS_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cancelPayment' => [
|
||||||
|
'url' => env('FIB_CANCEL_PAYMENT_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'refund' => [
|
||||||
|
'url' => env('FIB_REFUND_URL'),
|
||||||
|
],
|
||||||
|
];
|
||||||
0
backend/storage/app/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
backend/storage/logs/.gitignore
vendored
Normal file → Executable file
0
backend/storage/logs/.gitignore
vendored
Normal file → Executable file
@@ -12,7 +12,7 @@ server {
|
|||||||
fastcgi_pass laravel:9000;
|
fastcgi_pass laravel:9000;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
fastcgi_hide_header X-Powered-By;
|
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).* {
|
location ~ /\.(?!well-known).* {
|
||||||
|
|||||||
Reference in New Issue
Block a user