Skip to content

Commit 13db51a

Browse files
committed
Merge branch 'YP-1173_dobavit_pole_details_v_dokumentacziyu_i_php-api-client' into 'main'
Added field "details" See merge request ypmn-public/php-api-client!11
2 parents 8018d0c + 091c3f1 commit 13db51a

2 files changed

Lines changed: 67 additions & 1 deletion

File tree

src/Details.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function toArray(): array
5656

5757
if (is_string($this->getReceipts())) {
5858
$array += [
59-
'receipts' => $this->getReceipts()
59+
'receipts' => json_decode($this->getReceipts())
6060
];
6161
} else {
6262
$array += ['receipts' => []];

src/Examples/getPaymentLink.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Ypmn\PaymentPageOptions;
1515
use Ypmn\Product;
1616
use Ypmn\Std;
17+
use Ypmn\Details;
1718

1819
// Подключим файл, в котором заданы параметры мерчанта
1920
include_once 'start.php';
@@ -72,6 +73,69 @@
7273
$delivery->setIdentityDocument(
7374
new IdentityDocument(123456, 'PERSONALID')
7475
);
76+
77+
// (необязательно) Опишем поля для чеков
78+
$details = new Details;
79+
$details->setReceipts(<<<DETAILS
80+
[
81+
{
82+
"merchantCode": "{$merchant->getCode()}",
83+
"receipt": {
84+
"client": {
85+
"email": "sales@romashka.ru"
86+
},
87+
"company": {
88+
"email": "chek@romashka.ru",
89+
"sno": "osn",
90+
"inn": "1234567890",
91+
"payment_address": "https://v4.online.atol.ru"
92+
},
93+
"items": [
94+
{
95+
"name": "колбаса Клинский Брауншвейгская с/к в/с ",
96+
"price": 1000.00,
97+
"quantity": 0.3,
98+
"sum": 300.00,
99+
"measurement_unit": "кг",
100+
"payment_method": "full_payment",
101+
"payment_object": "commodity",
102+
"vat": {
103+
"type": "vat120"
104+
}
105+
},
106+
{
107+
"name": "яйцо Окское куриное С0 белое",
108+
"price": 100.00,
109+
"quantity": 1.0,
110+
"sum": 100.00,
111+
"measurement_unit": "Упаковка 10 шт.",
112+
"payment_method": "full_payment",
113+
"payment_object": "commodity",
114+
"vat": {
115+
"type": "vat120"
116+
}
117+
}
118+
],
119+
"payments": [
120+
{
121+
"type": 1,
122+
"sum": 400.0
123+
}
124+
],
125+
"vats": [
126+
{
127+
"type": "vat120"
128+
},
129+
{
130+
"type": "vat120"
131+
}
132+
],
133+
"total": 400.0
134+
}
135+
}
136+
]
137+
DETAILS);
138+
75139
// Установим Код страны
76140
$delivery->setCountryCode('RU');
77141
// Установим Город
@@ -113,6 +177,8 @@
113177
$payment->addProduct($product2);
114178
// Установим валюту
115179
$payment->setCurrency('RUB');
180+
// Установим дополнительные поля
181+
$payment->setDetails($details);
116182

117183
// Создадим запрос на авторизацию платежа
118184
// Здесь первым параметром можно передать конкретный способ оплаты из справочника

0 commit comments

Comments
 (0)