# hyperpay-gateways/5.3.0/src/App/Http.php

HyperPay Payments, version 5.3.0. 43 lines.

- Page: https://pluginprobe.com/plugins/hyperpay-gateways/5.3.0/code/src/App/Http.php
- Raw: https://pluginprobe.com/plugins/hyperpay-gateways/5.3.0/raw/src/App/Http.php
- Modified: 2025-05-19T16:00:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/hyperpay-gateways/5.3.0/code/src/App/Http.php#L10-L20`.

```php
<?php

namespace Hyperpay\Gateways\App;
if ( ! defined( 'ABSPATH' ) ) exit;

use WP_Error;
use Hyperpay\Gateways\App\Log;

final class Http
{

    public static function post($url, $data = [])
    {
        $response = wp_remote_post($url, $data);
        return self::handelResponse($response);
    }

    public static function get($url, $options = [])
    {
        $response = wp_remote_get($url, $options);
        return self::handelResponse($response);
    }

    public static function handelResponse($response)
    {
        $result =  json_decode(wp_remote_retrieve_body($response), true);

        if (is_wp_error($response)) {
            $error = $response->get_error_message();
            Log::write(["error" => $error, "response" => $result]);

            return [
                "result" => [
                    "code" => wp_remote_retrieve_response_code($response),
                    "description" => $error
                ]
            ];
        }

        return $result;
    }
}

```
