74 lines
2.0 KiB
PHP
74 lines
2.0 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($data): void
|
|
{
|
|
$arrayData = json_decode($data, true);
|
|
|
|
$inputParameters = [
|
|
'data' => [
|
|
'actionId' => $arrayData['actionId'],
|
|
'ruleId' => $arrayData['ruleId'],
|
|
'activityId' => $arrayData['activityId'],
|
|
'requestId' => $arrayData['requestId'],
|
|
'taskId' => $arrayData['taskId'],
|
|
'code' => $arrayData['code'],
|
|
'warrantStatus' => $arrayData['warrantStatus'],
|
|
'amountPaid' => $arrayData['amountPaid'],
|
|
],
|
|
'token' => $arrayData['token'],
|
|
];
|
|
|
|
$key = config('harim_web_services.Harim_Info.key');
|
|
$iv = config('harim_web_services.Harim_Info.iv');
|
|
|
|
$this->inputParameters = openssl_encrypt(json_encode($inputParameters), 'aes-256-cbc', $key, false, $iv);
|
|
}
|
|
} |