File tree 2 files changed +22
-17
lines changed
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
124
124
return $ productsArray ;
125
125
}
126
126
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
129
144
{
130
145
//TODO: проверка необходимых параметров
131
146
$ requestData = [
@@ -141,19 +156,4 @@ public function jsonSerialize()
141
156
142
157
return json_encode ($ requestData , JSON_UNESCAPED_SLASHES |JSON_PRETTY_PRINT |JSON_UNESCAPED_UNICODE |JSON_UNESCAPED_LINE_TERMINATORS );
143
158
}
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
- }
159
159
}
Original file line number Diff line number Diff line change @@ -106,4 +106,9 @@ public function getProductsArray() : array;
106
106
* @throws PaymentException Ошибка оплаты
107
107
*/
108
108
public function sumProductsAmount () : int ;
109
+
110
+ /**
111
+ * @return string|bool
112
+ */
113
+ public function jsonSerialize () : string |bool ;
109
114
}
You can’t perform that action at this time.
0 commit comments