From 923a66491b2a1499bcd0675e73aebea6b00e7a3a Mon Sep 17 00:00:00 2001 From: stes Date: Wed, 17 Jan 2018 12:13:39 +0200 Subject: [PATCH] test privat for extrem --- frontend/controllers/PrivatController.php | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+), 0 deletions(-) create mode 100644 frontend/controllers/PrivatController.php diff --git a/frontend/controllers/PrivatController.php b/frontend/controllers/PrivatController.php new file mode 100644 index 0000000..0015ec4 --- /dev/null +++ b/frontend/controllers/PrivatController.php @@ -0,0 +1,99 @@ + '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 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); + } else { + print_r(Url::to('/ru/order/callback', true)); + print_r(\Yii::$app->session->get('data')); + } + + + + } + } \ No newline at end of file -- libgit2 0.21.4