Done !
Server IP : 162.0.217.223 / Your IP : 216.73.216.168 Web Server : LiteSpeed System : Linux premium269.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : mypckeys ( 1539) PHP Version : 8.1.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/mypckeys/www/wp-content/plugins/cryptomus/vendor/cryptomus/api-php-sdk/src/ |
Upload File : |
<?php namespace Cryptomus\Api; final class RequestBuilder { const API_URL = "https://api.cryptomus.com/"; /** * @var string */ private $secretKey; /** * @var string */ private $merchantUuid; /** * @param string $secretKey * @param string $merchantUuid */ public function __construct($secretKey, $merchantUuid) { $this->secretKey = $secretKey; $this->merchantUuid = $merchantUuid; } /** * @param $uri * @param array $data * @return bool|mixed * @throws RequestBuilderException */ public function sendRequest($uri, array $data = []) { $curl = curl_init(); $url = self::API_URL . $uri; $body = json_encode($data, JSON_UNESCAPED_UNICODE); $headers = [ 'Accept: application/json', 'Content-Type: application/json;charset=UTF-8', 'Content-Length: ' . strlen($body), 'merchant: ' . $this->merchantUuid, 'sign: ' . md5(base64_encode($body) . $this->secretKey) ]; curl_setopt_array( $curl, [ CURLOPT_URL => $url, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $body, CURLOPT_RETURNTRANSFER => 1, ] ); $response = curl_exec($curl); $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($response === false) { throw new RequestBuilderException(curl_error($curl), $responseCode, $uri); } if (false === empty($response)) { $json = json_decode($response, true); if (is_null($json)) { throw new RequestBuilderException(json_last_error_msg(), $responseCode, $uri); } if ($responseCode !== 200 || (!is_null($json['state']) && $json['state'] != 0)) { if (!empty($json['message'])) { throw new RequestBuilderException($json['message'], $responseCode, $uri); } if (!empty($json['errors'])) { throw new RequestBuilderException('Validation error', $responseCode, $uri, $json['errors']); } } if (!empty($json['result']) && !is_null($json['state']) && $json['state'] == 0) { return $json['result']; } } return true; } }