File tree Expand file tree Collapse file tree 2 files changed +22
-17
lines changed Expand file tree Collapse file tree 2 files changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -124,8 +124,23 @@ public function getProductsArray(): array
124124 return $ productsArray ;
125125 }
126126
127- /** @inheritDoc */
128- public function jsonSerialize ()
127+ /** @inheritdoc */
128+ public function sumProductsAmount () : int
129+ {
130+ $ sum = 0 ;
131+ foreach ($ this ->getProducts () as $ product ) {
132+ if (null === $ product ->getAmount () && (null === $ product ->getUnitPrice ())) {
133+ throw new PaymentException ('Опишите цены позиций к оплате ' );
134+ }
135+
136+ $ sum += $ product ->getAmount () ?? ($ product ->getUnitPrice () * $ product ->getQuantity ());
137+ }
138+
139+ return $ sum ;
140+ }
141+
142+ #[\ReturnTypeWillChange]
143+ public function jsonSerialize (): string |bool
129144 {
130145 //TODO: проверка необходимых параметров
131146 $ requestData = [
@@ -141,19 +156,4 @@ public function jsonSerialize()
141156
142157 return json_encode ($ requestData , JSON_UNESCAPED_SLASHES |JSON_PRETTY_PRINT |JSON_UNESCAPED_UNICODE |JSON_UNESCAPED_LINE_TERMINATORS );
143158 }
144-
145- /** @inheritdoc */
146- public function sumProductsAmount () : int
147- {
148- $ sum = 0 ;
149- foreach ($ this ->getProducts () as $ product ) {
150- if (null === $ product ->getAmount () && (null === $ product ->getUnitPrice ())) {
151- throw new PaymentException ('Опишите цены позиций к оплате ' );
152- }
153-
154- $ sum += $ product ->getAmount () ?? ($ product ->getUnitPrice () * $ product ->getQuantity ());
155- }
156-
157- return $ sum ;
158- }
159159}
Original file line number Diff line number Diff line change @@ -106,4 +106,9 @@ public function getProductsArray() : array;
106106 * @throws PaymentException Ошибка оплаты
107107 */
108108 public function sumProductsAmount () : int ;
109+
110+ /**
111+ * @return string|bool
112+ */
113+ public function jsonSerialize () : string |bool ;
109114}
You can’t perform that action at this time.
0 commit comments