D
D
Dmitry Nosikov2017-08-10 00:54:19
PHP
Dmitry Nosikov, 2017-08-10 00:54:19

How to change document type in browser?

Good night, colleagues! Please tell me, I'm integrating the site with YandexKassa, I ran into the following problem: The fact is that for Yandex, at one of the payment steps, it is necessary to give an XML response after checking the payment data.
The code of the file that generates the answer for Yandex:

<?php
  $responce = getResponse('checkOrder', $_REQUEST['invoiceId'], 0, 'Тест заказа');

  sendResponse($responce);
  
  //Функция, формирующая ответ для Яндекса в форме, указанной в документации
  function getResponse($functionName, $invoiceId, $result_code, $message = null)
  {
    try
    {
      // $performedDatetime = new DateTime()->format($performedDatetime::W3C);
      $performedDatetime = date( 'c' );
      $response = '<?xml version="1.0" encoding="UTF-8"?><'.$functionName.'Response performedDatetime="'.$performedDatetime.
                '" code="'.$result_code.'" '.($message != null ? 'message="' . $message . '"' : "").' invoiceId="'.$invoiceId.'" shopId="150634"/>';	
      return $response;
      
    } catch(\Exception $e) {
                      return null;
    }

    return null;
  }
  
  function sendResponse($responseBody) {
        header("HTTP/1.0 200");
        header("Content-Type: application/xml");
        echo $responseBody;
        exit;
    }
?>

I pass all the necessary headers, and chrome still swears that the file type is a document, and application/xml is passed in the headers. please tell me how to solve this issue?
4e5850aec7214e678cf892684d007a7e.pngd29a405d56cd40548590342ba7c8815b.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Mosyukov, 2017-08-10
@deimon260993

Is everything OK. There is no error. Chrome just says that there are no appropriate styles (xslt) to transform XML into a readable form and that you see the bare data, exactly what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question