W
W
WebforSelf2021-05-08 14:56:08
PHP
WebforSelf, 2021-05-08 14:56:08

How to catch php request logs?

I send a request to Sberbank

function register_order($order_number, $amount, $return_url, $order_description, $order_bundle, $params = [])
    {
        $data = [
            'orderNumber' => $order_number,
            'amount' => $amount,
            'language' => 'ru',
            'currency' => '643',
            'jsonParams' => '{"phone":"+79277777777"}',
            'returnUrl' => $return_url,
            'description' => $order_description,
            'orderBundle' => $order_bundle
        ];

        // Запишем доп. параметры
        if (!empty($params)) {
            foreach ($params as $param_name => $val) {
                if($val !== false) {
                    $data[$param_name] = $val;
                }
            }
        }       

        $method = 'sbercredit/register.do';
        $response = $this->gateway($method, $data);
        return $response;
    }


const TEST_URL = 'https://3dsec.sberbank.ru/';

    private function gateway($method, $data)
    {
        $data['userName'] = $this->user_name;
        $data['password'] = $this->password;
        if ($this->test_mode) {
            $url = self::TEST_URL;
        } else {
            $url = self::PROD_URL;
        }

        $curl = curl_init();
        curl_setopt_array($curl, [
            CURLOPT_URL => $url . $method,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => http_build_query($data)
        ]);
        $response = curl_exec($curl);
        $response = json_decode($response, true);
        curl_close($curl);
        return $response;
    }


How can I log the full request that is sent to Sberbank?
so that I can see if it correctly generates a request by url.

It turns out that $data takes all parameters except the login password and url, then the function
$response = $this->gateway($method, $data); already adds a connection and all this is sent to the savings bank, so how exactly to intercept everything and see what is transmitted in the aggregate?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question