@@ -19,6 +19,8 @@ class ApiRequest implements ApiRequestInterface
1919 const PAYOUT_CREATE_API = '/api/v4/payout ' ;
2020 const REPORTS_ORDERS_API = '/reports/orders ' ;
2121 const SESSION_API = '/api/v4/payments/sessions ' ;
22+ const REPORT_CHART_API = '/api/v4/reports/chart ' ;
23+ const REPORT_GENERAL_API = '/api/v4/reports/general ' ;
2224 const HOST = 'https://secure.ypmn.ru ' ;
2325 const SANDBOX_HOST = 'https://sandbox.ypmn.ru ' ;
2426 const LOCAL_HOST = 'http://localhost ' ;
@@ -239,14 +241,6 @@ private function sendGetRequest(string $api): array
239241 }
240242 }
241243
242- if (mb_strlen ($ err ) > 0 ) {
243- throw new PaymentException ($ err );
244- }
245-
246- if ($ response == null || strlen ($ response ) === 0 ) {
247- throw new PaymentException ('Вы можете попробовать другой способ оплаты, либо свяжитесь с продавцом. ' );
248- }
249-
250244 return ['response ' => $ response , 'error ' => $ err ];
251245 }
252246
@@ -372,7 +366,17 @@ public function sendRefundRequest(RefundInterface $refund): array
372366 /** @inheritdoc */
373367 public function sendStatusRequest (string $ merchantPaymentReference ): array
374368 {
375- return $ this ->sendGetRequest (self ::STATUS_API . '/ ' . $ merchantPaymentReference );
369+ $ responseData = $ this ->sendGetRequest (self ::STATUS_API . '/ ' . $ merchantPaymentReference );
370+
371+ if (mb_strlen ($ responseData ['error ' ]) > 0 ) {
372+ throw new PaymentException ($ responseData ['error ' ]);
373+ }
374+
375+ if ($ responseData ['response ' ] == null || strlen ($ responseData ['response ' ]) === 0 ) {
376+ throw new PaymentException ('Вы можете попробовать другой способ оплаты, либо свяжитесь с продавцом. ' );
377+ }
378+
379+ return $ responseData ;
376380 }
377381
378382 /** @inheritdoc */
@@ -393,6 +397,35 @@ public function sendPayoutCreateRequest(PayoutInterface $payout)
393397 return $ this ->sendPostRequest ($ payout , self ::PAYOUT_CREATE_API );
394398 }
395399
400+ /** @inheritdoc */
401+ public function sendReportChartRequest (array $ params ): array
402+ {
403+ return $ this ->sendGetRequest (self ::REPORT_CHART_API . '/? ' . http_build_query ($ params ));
404+ }
405+
406+ /** @inheritdoc */
407+ public function sendReportChartUpdateRequest (array $ params ): array
408+ {
409+ $ getParams = [
410+ 'startDate ' => $ _GET ['startDate ' ],
411+ 'endDate ' => $ _GET ['endDate ' ],
412+ 'status ' => $ _GET ['status ' ],
413+ 'type ' => $ _GET ['type ' ],
414+ 'periodLength ' => $ _GET ['periodLength ' ],
415+ 'jsonForUpdate ' => 'true '
416+ ];
417+
418+ $ params = array_merge ($ getParams , $ params );
419+
420+ return $ this ->sendGetRequest (self ::REPORT_CHART_API . '/? ' . http_build_query ($ params ));
421+ }
422+
423+ /** @inheritdoc */
424+ public function sendReportGeneralRequest (array $ params ): array
425+ {
426+ return $ this ->sendGetRequest (self ::REPORT_GENERAL_API . '/? ' . http_build_query ($ params ));
427+ }
428+
396429 /**
397430 * Подпись запроса
398431 * @param MerchantInterface $merchant Мерчант
0 commit comments