Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Controllers\User\Payments;
- use Controllers\Controller;
- use Models\UserModel;
- use Service\CoinsCalculator;
- use Respect\Validation\Validator as v;
- class HotPayController extends Controller
- {
- public function pscListAction($request, $response)
- {
- return $this->view->render($response, 'paysafecard.html.twig');
- }
- public function pscReceiveAction($request, $response)
- {
- if (!empty($_POST["KWOTA"]) &&
- !empty($_POST["ID_PLATNOSCI"]) &&
- !empty($_POST["ID_ZAMOWIENIA"]) &&
- !empty($_POST["STATUS"]) &&
- !empty($_POST["SEKRET"]) &&
- !empty($_POST["HASH"])
- ) {
- if (hash("sha256", $this->settings['payments']['hotpay']['paysafecardPassword'] . ";" . $_POST["KWOTA"] . ";" . $_POST["ID_PLATNOSCI"] . ";" . $_POST["ID_ZAMOWIENIA"] . ";" . $_POST["STATUS"] . ";" . $_POST["SEKRET"]) == $_POST["HASH"]) {
- if ($_POST["STATUS"] == "SUCCESS") {
- $amount = $_POST['KWOTA'];
- $userId = $_POST['ID_ZAMOWIENIA'];
- UserModel::grantCoins($userId, CoinsCalculator::calculate($amount));
- return json_encode([
- 'success' => true
- ]);
- } else if ($_POST["STATUS"] == "FAILURE") {
- return json_encode([
- 'success' => false
- ]);
- }
- }
- }
- return json_encode([
- 'success' => false
- ]);
- }
- public function transferListAction($request, $response)
- {
- return $this->view->render($response, 'transfer.html.twig');
- }
- public function transferReceiveAction($request, $response)
- {
- if (!empty($_POST["KWOTA"]) &&
- !empty($_POST["ID_PLATNOSCI"]) &&
- !empty($_POST["ID_ZAMOWIENIA"]) &&
- !empty($_POST["STATUS"]) &&
- !empty($_POST["SEKRET"]) &&
- !empty($_POST["HASH"])
- ) {
- if (hash("sha256", $this->settings['payments']['hotpay']['transferPassword'] . ";" . $_POST["KWOTA"] . ";" . $_POST["ID_PLATNOSCI"] . ";" . $_POST["ID_ZAMOWIENIA"] . ";" . $_POST["STATUS"] . ";" . $_POST["SEKRET"]) == $_POST["HASH"]) {
- if ($_POST["STATUS"] == "SUCCESS") {
- $amount = $_POST['KWOTA'];
- $userId = $_POST['ID_ZAMOWIENIA'];
- UserModel::grantCoins($userId, CoinsCalculator::calculate($amount));
- return json_encode([
- 'success' => true
- ]);
- } else if ($_POST["STATUS"] == "FAILURE") {
- return json_encode([
- 'success' => false
- ]);
- }
- }
- }
- return json_encode([
- 'success' => false
- ]);
- }
- public function smsListAction($request, $response)
- {
- if ($request->isPost()) {
- $_sms = $request->getParsedBody()['sms'];
- $validation = $this->validator->validate($request, [
- 'sms' => v::notEmpty(),
- ]);
- if (!$validation->isValid()) {
- return $response->withRedirect($this->router->pathFor('payments.hotpay.sms'));
- }
- foreach ($this->settings['payments']['hotpay']['sms'] as $sms) {
- $hotPayresponse = json_decode(file_get_contents('https://api.hotpay.pl/check_sms.php?sekret=' . $sms[4] . '&kod_sms=' . $_sms));
- if ($hotPayresponse->status === 'ERROR') continue;
- if ($hotPayresponse->status === 'SUKCESS') {
- if (intval($hotPayresponse->aktywacja) === 1) {
- UserModel::grantCoins($_SESSION['user']['id'], $sms[3]);
- $this->flash->addMessage('success', 'Kod został użyty pomyślnie. Doładowano: ' . $sms[3] . ' SM.');
- } else {
- $this->flash->addMessage('alert', 'Podany przez Ciebie kod zostal juz wykorzystany.');
- }
- return $response->withRedirect($this->router->pathFor('payments.hotpay.sms'));
- }
- }
- $this->flash->addMessage('alert', 'Podano nieprawidlowy kod.');
- return $response->withRedirect($this->router->pathFor('payments.hotpay.sms'));
- }
- return $this->view->render($response, 'sms.html.twig');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement