58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Services\PanjarehVahed;
|
|
|
|
use Exception;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class SendPaymentInfoService
|
|
{
|
|
protected string $url;
|
|
protected string $channelName;
|
|
protected string $inputParameters;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->url = config('harim_web_services.Reject.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;
|
|
}
|
|
}
|
|
|
|
private function sendRequest(): array
|
|
{
|
|
return Http::withHeaders(['Content-Type' => 'application/json'])
|
|
->withBody($this->inputParameters)
|
|
->throw()
|
|
->withoutVerifying()
|
|
->post($this->url)
|
|
->json();
|
|
}
|
|
|
|
public function makeInputParameters($input): void
|
|
{
|
|
$key = config('harim_web_services.Harim_Info.key');
|
|
$iv = config('harim_web_services.Harim_Info.iv');
|
|
|
|
$this->inputParameters = openssl_encrypt(json_encode($input), 'aes-256-cbc', $key, false, $iv);
|
|
}
|
|
} |