Skip to content

Commit 0d131b6

Browse files
authored
Merge pull request #16 from yourpayments/YP-713__dobavit-potranzakczionnyj-otchet-v-sdk
YP-713__dobavit-potranzakczionnyj-otchet-v-sdk
2 parents 6f2dbd4 + c25e3e9 commit 0d131b6

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ composer require yourpayments/php-api-client
3333
18. [Безопасные поля (Secure fields)](src/Examples/secureFields.php)
3434
19. [Запрос отчёта в формате Json](src/Examples/getReportGeneral.php)
3535
20. [Запрос отчёта в виде графика](src/Examples/getReportChart.php)
36+
21. [Запрос отчёта по заказам](src/Examples/getReportOrder.php)
3637

3738
## Ссылки
3839
- [НКО «Твои платежи»](https://YPMN.ru/)

example.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
case 'secureFields':
4949
case 'getReportGeneral':
5050
case 'getReportChart':
51+
case 'getReportOrder':
5152
case 'getFasterPayment':
5253
case 'getBindingFasterPayment':
5354
case 'paymentByFasterBinding':

src/ApiRequest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ApiRequest implements ApiRequestInterface
2121
const SESSION_API = '/api/v4/payments/sessions';
2222
const REPORT_CHART_API = '/api/v4/reports/chart';
2323
const REPORT_GENERAL_API = '/api/v4/reports/general';
24+
const REPORT_ORDERS_API_V4 = '/api/v4/reports/orders';
2425
const PODELI_MERCHANT_REGISTRATION_API = '/api/v4/registration/merchant/podeli';
2526
const HOST = 'https://secure.ypmn.ru';
2627
const SANDBOX_HOST = 'https://sandbox.ypmn.ru';
@@ -460,6 +461,11 @@ public function sendReportGeneralRequest(array $params): array
460461
return $this->sendGetRequest(self::REPORT_GENERAL_API . '/?' . http_build_query($params));
461462
}
462463

464+
public function sendReportOrderRequest(array $params): array
465+
{
466+
return $this->sendGetRequest(self::REPORT_ORDERS_API_V4 . '/?' . http_build_query($params));
467+
}
468+
463469
/**
464470
* Подпись запроса
465471
* @param MerchantInterface $merchant Мерчант

src/Examples/getReportOrder.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Ypmn\ApiRequest;
6+
7+
// Подключим файл, в котором заданы параметры мерчанта
8+
include_once 'start.php';
9+
10+
// Получение отчета в формате JSON
11+
12+
// Создадим HTTP-запрос к API
13+
$apiRequest = new ApiRequest($merchant);
14+
// Включить режим отладки (закомментируйте или удалите в рабочей программе!)
15+
$apiRequest->setDebugMode();
16+
// Переключиться на тестовый сервер (закомментируйте или удалите в рабочей программе!)
17+
$apiRequest->setSandboxMode();
18+
19+
// Подготовим диапазон дат для отчета
20+
$endDate = (new DateTime('now'))->format('c');
21+
22+
$startDate = (new DateTime($endDate))
23+
->modify('-14 day')
24+
->format('c');
25+
26+
$data = [
27+
'startDate' => $startDate,
28+
'endDate' => $endDate,
29+
'byConfirmation' => 'YES',
30+
'statuses' => [
31+
'pending' => 'YES',
32+
'authorized' => 'YES'
33+
]
34+
];
35+
36+
// Отправим запрос
37+
$responseData = $apiRequest->sendReportOrderRequest($data);

0 commit comments

Comments
 (0)