40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
||
|
||
class СancelTransmitting
|
||
{
|
||
private int $marketPlace;
|
||
private string $secretKey;
|
||
private $jsonString;
|
||
private $request_url;
|
||
|
||
public function __construct($jsonString)
|
||
{
|
||
$this->jsonString = $jsonString;
|
||
|
||
$this->secretKey = $this->jsonString['secretKey'] ?? null;;
|
||
$this->request_url = $this->jsonString['domain'] ?? null;
|
||
}
|
||
|
||
public function rejectPayment()
|
||
{
|
||
$messageTxt = json_encode($this->jsonString);
|
||
$signature = hash('sha256', $messageTxt . $this->secretKey);
|
||
|
||
$ch = curl_init();
|
||
curl_setopt_array($ch, [
|
||
CURLOPT_URL => "https://" .$this->request_url. "/merchantApi/rejectPayment",
|
||
CURLOPT_RETURNTRANSFER => true,
|
||
CURLOPT_POST => true,
|
||
CURLOPT_POSTFIELDS => $messageTxt,
|
||
CURLOPT_HTTPHEADER => [
|
||
"Signature: $signature",
|
||
"Content-Type: application/json"
|
||
]
|
||
]);
|
||
|
||
$res = curl_exec($ch);
|
||
|
||
return $res;
|
||
}
|
||
}
|
||
?>
|