File tree Expand file tree Collapse file tree 4 files changed +7
-31
lines changed
Expand file tree Collapse file tree 4 files changed +7
-31
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments