<?php
require_once '../../wcore/core.php';
// $yandexSecretKey = 'Skm6eEZrtxr45MP1YnaxxJcm';
$yandexSecretKey = 'OAdtCMyWoeOz7qgtjY40UooK';
if (empty($_POST['sha1_hash']))
{
// header('Location:/');
logPayment('Error: Пустые данные');
}
else
{
$httpData = (object) $_POST;
$sha1 = sha1( $httpData->notification_type . '&'. $httpData->operation_id . '&' . $httpData->amount . '&643&' . $httpData->datetime . '&'. $httpData->sender . '&' . $httpData->codepro . '&' . $yandexSecretKey. '&' . $httpData->label );
if ($sha1 != $httpData->sha1_hash ) {
logPayment('Error: Hash не совпал');
}
else
{
$bill_id = (int) $httpData->label;
$checkBill = mysqli_fetch_object(mysqli_query($mysqli, 'SELECT * FROM `bill_pays` WHERE `id` = '.$bill_id.' LIMIT 1'));
if (!$checkBill)
{
logPayment('Error: Счет #'.$bill_id.' не найден');
}
else
{
if (mysqli_query($mysqli, 'UPDATE `bill_pays` SET `time_pay` = '.time().', `payment` = "yandex" WHERE `user_id` = '.$checkBill->user_id) && mysqli_query($mysqli, 'UPDATE `users` SET `bits` = `bits` +'.$checkBill->amount.' WHERE `id` = '.$checkBill->user_id))
{
logPayment('Success: Счет найден и оплачен, user_id: '.$checkBill->user_id);
}
else
{
logPayment('Error: '.mysqli_error($mysqli));
}
}
}
$logData = json_encode($checkBill);
logPayment($logData);
}