Skip to content

Commit c694fab

Browse files
author
Alexey Babak
committed
fixed serialization
1 parent 4802abf commit c694fab

File tree

4 files changed

+7
-31
lines changed

4 files changed

+7
-31
lines changed

src/Examples/paymentRefundMarketplace.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
$refund->setOriginalAmount(3700);
2222
// Cумма фактического списания
2323
$refund->setAmount(3700);
24+
2425
// Добавим Сабмерчантов
2526
$refund->addMarketPlaceSubmerchant('SUBMERCHANT_1', 3000);
2627
$refund->addMarketPlaceSubmerchant('SUBMERCHANT_2', 700);
28+
2729
// Установим валюту
2830
$refund->setCurrency('RUB');
2931
// Создадим HTTP-запрос к API

src/MarketplaceSubmerchant.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Это объект Сабмерчанта
1010
* (для маркетплейса/сплита/разделения платежа)
1111
*/
12-
class MarketplaceSubmerchant implements MarketplaceSubmerchantInterface, JsonSerializable
12+
class MarketplaceSubmerchant implements MarketplaceSubmerchantInterface
1313
{
1414
/** @var string Код Сабмерчанта (можно получить в личном кабинете) */
1515
private string $merchantCode;
@@ -59,27 +59,4 @@ public function getAmount(): float
5959
{
6060
return $this->amount;
6161
}
62-
63-
/** @inheritDoc */
64-
public function arraySerialize()
65-
{
66-
$resultArray = [
67-
'merchantCode' => $this->merchantCode,
68-
];
69-
70-
if ($this->amount > 0) {
71-
$resultArray['amount'] = $this->amount;
72-
}
73-
74-
return $resultArray;
75-
}
76-
77-
public function jsonSerialize(){
78-
$dto = (object) [
79-
'merchantCode' => $this->getMerchantCode(),
80-
'amount' => $this->getAmount(),
81-
];
82-
83-
return json_encode($dto, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_LINE_TERMINATORS);
84-
}
8562
}

src/MarketplaceSubmerchantInterface.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,4 @@ public function setAmount(float $amount) : self;
3232
* @return float
3333
*/
3434
public function getAmount() : float;
35-
36-
/**
37-
* Преобразовать в массив
38-
* @return mixed объект в виде массива
39-
*/
40-
public function arraySerialize();
4135
}

src/Refund.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ public function jsonSerialize()
156156

157157
if (count($this->marketplaceSubmerchants) > 0) {
158158
foreach ($this->marketplaceSubmerchants as $marketplaceSubmerchant) {
159-
$requestData['marketplaceV1'][] = $marketplaceSubmerchant;
159+
$requestData['marketplaceV1'][] = (object) [
160+
'amount' => $marketplaceSubmerchant->getAmount(),
161+
'merchant' => $marketplaceSubmerchant->getMerchantCode(),
162+
];
160163
}
161164
}
162165

0 commit comments

Comments
 (0)