@alexmixaylov

Как вытянуть тела ответа яндекс кассы в симфони контроллере?

пытаюсь сделать интеграцию яндекс кассы с помощью яндекс апи
сформировал секретный ключ
отправил успешно тестовую оплату но никак не получается вытянуть тела ответа с сервера яндекс кассы
чего то там все пусто
завис:) , какие могут быть варианты?
ответ приходит от сервера в json, может из за этого
5ad7a81692df5414904183.png
контроллеры
public function newYandexPayAction(Request $request)
    {
        $config_ym = self::configYM();
        $client = new Client();
        $client->setAuth($config_ym->shopId, $config_ym->yandexKey);
        $response = $client->createPayment(array(
                'amount' => array(
                    'value' => '20.00',
                    'currency' => 'RUB',
                ),
                'payment_method_data' => array(
                    'type' => 'bank_card',
                ),
                'confirmation' => array(
                    'type' => 'redirect',
                    'return_url' => 'http://127.0.0.1:8000/ym/response',
                ),
                'description' => 'описание платежа'
            )
        );

        $redirectToYandexForPayment = $response->confirmation->confirmationUrl;

        return $this->render('@App/Pay/without_session.html.twig',
            array(
                'yandex_client' => $redirectToYandexForPayment
            )
        );
    }

public function checkUrlAction(Request $request)
    {
        $response = $request->getContent();
        return $this->render('@App/Yandex/ym_return.twig', array('data' => $response));
    }
  • Вопрос задан
  • 285 просмотров
Пригласить эксперта
Ответы на вопрос 1
voronkovich
@voronkovich
Из документации (в точности ваш случай):

Finally, the raw data sent with the request body can be accessed using getContent():

$content = $request->getContent();

For instance, this may be useful to process a JSON string sent to the application by a remote service using the HTTP POST method.

См. https://symfony.com/doc/current/components/http_fo...
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы