- Added comprehensive AI Assistant system (aiassist/ directory): * Vector search and embedding capabilities * Typebot proxy integration * Elastic search functionality * Message classification and chat history * MCP proxy for external integrations - Implemented Court Status API (GetCourtStatus.php): * Real-time court document status checking * Integration with external court systems * Comprehensive error handling and logging - Enhanced S3 integration: * Improved file backup system with metadata * Batch processing capabilities * Enhanced error logging and recovery * Copy operations with URL fixing - Added Telegram contact creation API - Improved error logging across all modules - Enhanced callback system for AI responses - Extensive backup file storage with timestamps - Updated documentation and README files - File storage improvements: * Thousands of backup files with proper metadata * Fix operations for broken file references * Project-specific backup and recovery systems * Comprehensive file integrity checking Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
111 lines
5.4 KiB
PHP
111 lines
5.4 KiB
PHP
<?php
|
||
|
||
echo 'OK';
|
||
|
||
include_once 'modules/Users/Users.php';
|
||
require_once('include/Webservices/Utils.php');
|
||
require_once 'include/Webservices/Create.php';
|
||
require_once 'include/Webservices/Revise.php';
|
||
require_once 'includes/Loader.php';
|
||
require_once 'include/utils/WhatsApp.php';
|
||
vimport ('includes.runtime.Globals');
|
||
vimport ('includes.runtime.BaseModel');
|
||
vimport ('includes.runtime.LanguageHandler');
|
||
|
||
$str = file_get_contents('php://input'); //Вынимаем пришедшие данные вот таким оригинальным образом
|
||
//$str = "{\"TerminalKey\":\"1672416715624DEMO\",\"OrderId\":\"3000730\",\"Success\":true,\"Status\":\"CONFIRMED\",\"PaymentId\":2575646055,\"ErrorCode\":\"0\",\"Amount\":150000,\"CardId\":267010528,\"Pan\":\"430000******0777\",\"ExpDate\":\"1122\",\"Token\":\"c74eefb2b1113c89d428e178d6ca9690348d46e9e6665cbf6d3bf14139c3de06\",\"Data\":{\"Email\":\"ilya@rudenko.expert\",\"has_lied_browser\":\"false\",\"connection_type\":\"PF\",\"has_lied_resolution\":\"false\",\"timezone_offset\":\"-180\",\"real_timezone\":\"+180\",\"Source\":\"cards\",\"accept\":\"application\/json, text\/plain, *\/*\",\"canvasRisk\":\"1e80a0c3a40d7f7178aa5451138acb2f\",\"has_lied_languages\":\"false\",\"navigator_platform\":\"Win32\",\"SEND_EMAIL\":\"N\",\"has_lied_os\":\"false\",\"javaEnabled\":\"false\",\"dmpid\":\"94dcad65-32e3-4b78-a17a-93d621e7c50e\",\"local_storage\":\"1\",\"payAction\":\"3DS\",\"canvasMasterpass\":\"857608266\",\"pixel_ratio\":\"1\",\"guid\":\"3b21483c-77fd-6897-4676-b62d75084fbd\",\"colorDepth\":\"24\",\"user_agent\":\"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko\/20100101 Firefox\/111.0\",\"REDIRECT\":\"false\"}}";
|
||
$str = str_replace('\"', '"', $str); //Т.к. данные почему-то приходят экранированными (см выше), избавляемся от экранов, чтобы массив корректно собирался из json-а
|
||
$data = json_decode($str, true); // Формируем массив
|
||
|
||
$logstring = date('Y-m-d H:i:s').' '.json_encode($data).PHP_EOL; // Пишем в лог то, что будем обрабатывать (после удаления экранированных символов)
|
||
file_put_contents('logs/paid.log', $logstring, FILE_APPEND);
|
||
|
||
$status = $data['Status'];
|
||
$logstring = date('Y-m-d H:i:s').' Статус: '.$status.PHP_EOL;
|
||
file_put_contents('logs/paid.log', $logstring, FILE_APPEND);
|
||
|
||
if ($status == 'CONFIRMED') {
|
||
$amount = $data['Amount'] / 100;
|
||
$logstring = date('Y-m-d H:i:s').' Добыли сумму в рублях: '.$amount.PHP_EOL;
|
||
file_put_contents('logs/paid.log', $logstring, FILE_APPEND);
|
||
|
||
$email = $data['Data']['Email'];
|
||
$phone = '7'.$data['Data']['Phone'];
|
||
$logstring = date('Y-m-d H:i:s').' Добыли e-mail: '.$email.', и телефон: '.$phone.PHP_EOL;
|
||
file_put_contents('logs/paid.log', $logstring, FILE_APPEND);
|
||
|
||
global $adb;
|
||
|
||
// Сначала поищем плательщика по телефону - более верный вариант
|
||
$query = "select c.contactid
|
||
from vtiger_contactdetails c
|
||
left join vtiger_crmentity e on e.crmid = c.contactid
|
||
where e.deleted = 0 and c.mobile = '".$phone."'";
|
||
$qresult = $adb->pquery($query);
|
||
|
||
if($adb->num_rows($qresult) == 0) {
|
||
// Если не нашлось - попробуем по емейлу
|
||
$query = "select c.contactid
|
||
from vtiger_contactdetails c
|
||
left join vtiger_crmentity e on e.crmid = c.contactid
|
||
where e.deleted = 0 and c.email = '".$email."'";
|
||
$qresult = $adb->pquery($query);
|
||
}
|
||
|
||
if($adb->num_rows($qresult) > 0) {
|
||
$contactid = $adb->query_result($qresult, 0, 'contactid');
|
||
$logstring = date("Y-m-d H:i:s").' Найден Контакт с ID = '.$contactid;
|
||
file_put_contents('logs/paid.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
|
||
$user = Users::getActiveAdminUser(); // Получаем пользователя, под которым будем создавать платеж
|
||
/*
|
||
switch ($amount) {
|
||
case 1000:
|
||
$income = 'Подписка на 1 месяц';
|
||
break;
|
||
case 1800:
|
||
$income = 'Подписка на 2 месяца';
|
||
break;
|
||
case 2700:
|
||
$income = 'Подписка на 2 месяца';
|
||
break;
|
||
default:
|
||
$income = 'Донат';
|
||
}
|
||
*/
|
||
try {
|
||
$params = array (
|
||
'pay_date' => date('Y-m-d'),
|
||
'pay_type' => 'Receipt',
|
||
'payer' => '12x'.$contactid,
|
||
'type_payment' => 'Cashless Transfer',
|
||
'amount' => $amount,
|
||
'spstatus' => 'Executed',
|
||
'spcompany' => 'МОО "Клиентправ"',
|
||
'assigned_user_id' => vtws_getWebserviceEntityId('Users', $user->id)
|
||
);
|
||
|
||
$payment = vtws_create('SPPayments', $params, $user);
|
||
$output = 'Платеж создан: '.$payment['id'];
|
||
} catch (WebServiceException $ex) {
|
||
$output = $ex->getMessage();
|
||
}
|
||
|
||
$logstring = date("Y-m-d H:i:s").' '.$output;
|
||
file_put_contents('logs/paid.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
} else {
|
||
$logstring = date("Y-m-d H:i:s").' Контакт НЕ найден - ни по телефону, ни по емейлу';
|
||
file_put_contents('logs/paid.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
}
|
||
}
|
||
|
||
$logstring = date("Y-m-d H:i:s").' А теперь мы будем отдавать ответ наружу';
|
||
file_put_contents('logs/paid.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
|
||
// http_response_code(200);
|
||
// echo "OK";
|
||
|
||
$logstring = date("Y-m-d H:i:s").' И вот мы его 100% отдали';
|
||
file_put_contents('logs/paid.log', $logstring.PHP_EOL, FILE_APPEND);
|
||
|
||
?>
|