@@ -41,18 +41,30 @@ class ApiRequest implements ApiRequestInterface
4141 /** @var bool Формат результата в режиме отладки */
4242 private bool $ jsonDebugResponse = true ;
4343
44+ /** @var string Хост для отправки запросов */
45+ private string $ host = self ::HOST ;
46+
4447 /** @inheritdoc */
4548 public function __construct (MerchantInterface $ merchant )
4649 {
4750 $ this ->merchant = $ merchant ;
4851 }
4952
53+ /** @inheritdoc */
5054 public function getHost () : string
5155 {
52- if ($ this ->localModeIsOn ) {
53- return self ::LOCAL_HOST ;
56+ return $ this ->host ;
57+ }
58+
59+ /** @inheritdoc */
60+ public function setHost (string $ host ) : self
61+ {
62+ if (filter_var ($ host , FILTER_VALIDATE_URL )) {
63+ $ this ->host = $ host ;
64+
65+ return $ this ;
5466 } else {
55- return ( $ this -> getSandboxMode () ? self :: SANDBOX_HOST : self :: HOST );
67+ throw new PaymentException ( ' Некорректный URL для отправки запросов ' );
5668 }
5769 }
5870
@@ -162,6 +174,11 @@ private function buildReportsSourceString($parameters)
162174 return $ hashString ;
163175 }
164176
177+ /**
178+ * Расчет подписи для API v3
179+ * @param $parameters
180+ * @return string
181+ */
165182 private function reportsSign ($ parameters )
166183 {
167184 $ sourceString = $ this ->buildReportsSourceString ($ parameters );
@@ -471,6 +488,7 @@ public function setSandboxMode(bool $sandboxModeIsOn = true): self
471488 $ this ->setLocalMode (false );
472489 }
473490 $ this ->sandboxModeIsOn = $ sandboxModeIsOn ;
491+ $ this ->host = self ::SANDBOX_HOST ;
474492
475493 return $ this ;
476494 }
@@ -488,6 +506,7 @@ public function setLocalMode(bool $localModeIsOn = true): self
488506 $ this ->setSandboxMode (false );
489507 }
490508 $ this ->localModeIsOn = $ localModeIsOn ;
509+ $ this ->host = self ::LOCAL_HOST ;
491510
492511 return $ this ;
493512 }
0 commit comments