Skip to content

Commit 3814376

Browse files
authored
Merge pull request #8 from yourpayments/YP-291__sdelat-zanovo-grafiki-v-cpanel
fix debug chart response
2 parents 829a255 + 899490a commit 3814376

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

example_header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<li class="list-group-item"><a target="_blank" href="https://YPMN.ru/ru/">Наш сайт</a></li>
7474
<li class="list-group-item"><a target="_blank" href="https://github.com/yourpayments/">Github</a></li>
7575
<li class="list-group-item"><a target="_blank" href="https://dev.payu.ru/ru/documents/rest-api/testing/">Тестовые карты</a></li>
76-
<li class="list-group-item"><a target="_blank" href="https://dev.ypmn.ru/ru/documents/kak-eto-rabotaet/">Документация</a></li>
76+
<li class="list-group-item"><a target="_blank" href="https://ypmn.ru/ru/documentation/">Документация</a></li>
7777
<li class="list-group-item"><a target="_blank" href="https://dev.ypmn.ru/ru/faq/">Частые вопросы</a></li>
7878
<li class="list-group-item"><a target="_blank" href="mailto:[email protected]?subject=YPMN_Integration">[email protected]</a></li>
7979
<li class="list-group-item"><a target="_blank" href="https://t.me/YPMN_bot">@YPMN_bot</a></li>

src/ApiRequest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class ApiRequest implements ApiRequestInterface
3838
/** @var bool Режим Отладки (вывод системных сообщений) */
3939
private bool $debugModeIsOn = false;
4040

41+
/** @var bool Формат результата в режиме отладки */
42+
private bool $jsonDebugResponse = true;
43+
4144
/** @inheritdoc */
4245
public function __construct(MerchantInterface $merchant)
4346
{
@@ -211,7 +214,11 @@ private function sendGetRequest(string $api): array
211214
$this->echoDebugMessage('GET-Запрос к серверу Ypmn:');
212215
$this->echoDebugMessage($this->getHost() . $api);
213216
$this->echoDebugMessage('Ответ от сервера Ypmn:');
214-
$this->echoDebugMessage(json_encode(json_decode($response), JSON_PRETTY_PRINT));
217+
if ($this->getJsonDebugResponse()) {
218+
$this->echoDebugMessage(json_encode(json_decode($response), JSON_PRETTY_PRINT));
219+
} else {
220+
$this->echoDebugMessage($response);
221+
}
215222

216223
if (mb_strlen($err) > 0) {
217224
$this->echoDebugMessage('Ошибка');
@@ -497,6 +504,19 @@ public function setDebugMode(bool $debugModeIsOn = true): self
497504
return $this;
498505
}
499506

507+
/** @inheritdoc */
508+
public function setJsonDebugResponse(bool $jsonDebugResponse): self
509+
{
510+
$this->jsonDebugResponse = $jsonDebugResponse;
511+
return $this;
512+
}
513+
514+
/** @inheritdoc */
515+
public function getJsonDebugResponse(): bool
516+
{
517+
return $this->jsonDebugResponse;
518+
}
519+
500520
/**
501521
* Вывод отладочного сообщения
502522
* @param $mixedInput

src/ApiRequestInterface.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ public function setDebugMode(bool $debugModeIsOn): self;
7474
*/
7575
public function getDebugMode(): bool;
7676

77+
/**
78+
* Установить тип позвращаемого значения в режиме отладки
79+
* @return $this
80+
*/
81+
public function setJsonDebugResponse(bool $jsonDebugResponse): self;
82+
83+
/**
84+
* Получить тип позвращаемого значения в режиме отладки
85+
* @return bool
86+
*/
87+
public function getJsonDebugResponse(): bool;
88+
7789
/**
7890
* Отправить Запрос на Токенизацию
7991
* @param PaymentReference $payuPaymentReference Оплата

src/Examples/getReportChart.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
$apiRequest = new ApiRequest($merchant);
1414
// Включить режим отладки (закомментируйте или удалите в рабочей программе!)
1515
$apiRequest->setDebugMode();
16+
// Принимать ответ строкой в режиме отладки (закомментируйте или удалите в рабочей программе!)
17+
$apiRequest->setJsonDebugResponse(false);
1618
// Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!)
1719
$apiRequest->setSandboxMode();
1820

0 commit comments

Comments
 (0)