'application/json', 'Accept-Encoding' => 'UTF-8', 'Content-Type' => 'application/json;charset=utf-8', ]; $client = new Client(); $response = $client->post( $url, [ 'headers' => $headers, 'body' => Json::encode($privat), ] ); if ($response->getStatusCode() == 200) { $str = (string) $response->getBody() ->getContents(); $data = Json::decode($str); if ($data[ 'token' ]) { header( 'Location: https://payparts2.privatbank.ua/ipp/v2/payment?token=' . $data[ 'token' ] ); // перенаправление на нужную страницу exit(); } } } public function beforeAction($action) { if ($action->id == 'callback') { $this->enableCsrfValidation = false; } return parent::beforeAction($action); } public function actionCallback() { if ($_SERVER[ 'REQUEST_METHOD' ] === 'POST') { $data = file_get_contents('php://input'); $file = \Yii::getAlias('@storage/callback.log'); $myFile = fopen($file, 'a') or die('Unable to open file!'); fwrite($myFile, "\n" . $data); fclose($myFile); print_r($data); die(); } else { print_r(Url::to('/ru/order/callback', true)); print_r(\Yii::$app->session->get('data')); } } }