Файл: online_copayco.php
Строк: 119
<?
$full_home_path = dirname(__FILE__);
require_once($full_home_path."/_rootload.php");
# request_type Тип запроса
# status Состояние транзакции
# ta_id Идентификатор заказа
# cpс_ta_id Идентификатор заказа в CoPAYCo
# amount Сумма платежа
# currency Валюта платежа
# payment_mode Способ оплаты
# date_time Дата/время
# signature MAC-подпись
$input = '';
foreach ($_POST as $field=>$value) {
$input .= $field." ".$value."n";
}
$input = "Входящие параметры:nn$input";
if (getenv("REQUEST_METHOD") != "POST") {
mconnect();
$manager_email=GetSetting('manager_email');
$msg = "С IP-адреса $ip произошло обращение к скрипту online_copayco.php по GET-протоколу.nnБудьте внимательны, т.к. возможно кто-то пытается взломать систему.nn$inputnn--nRootPanel";
$subject = "Возможная попытка взлома билинга [CoPAYCo]";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$msg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$msg);
}
mclose();
exit;
}
if ($request_type == "check" or $request_type == "perform") {
mconnect();
EnableLanguages();
$bill = GetBillById($ta_id);
$payy = GetPaymentSystemById($bill->paymentSystemId);
$copayco_secret=decodePwd($payy->pass1);
###
$merchantCurrency = $payy->currency; if (!$merchantCurrency) {$merchantCurrency="UAH";}
$bill->merchantmoney = ($bill->money_host+$bill->money_domain+$bill->money_addons+$bill->money_shop+$bill->money) * GetCurrencyKoeficientByCode($merchantCurrency);
$bill->merchantmoney = $bill->merchantmoney + ($bill->merchantmoney/100)*$payy->small1; $bill->merchantmoney = round($bill->merchantmoney,2);
###
$bill->merchantmoney = $bill->merchantmoney*100;
$string = $bill->id.$amount.$currency.$date_time.$random.$copayco_secret;
if (!$ta_id) { $error_msg = "1. Отсутствует идентификатор заказа."; }
else if (!$bill->id) { $error_msg = "2. Счет # $bill_id не найден."; }
else if ($amount < $bill->merchantmoney) { $error_msg = "3. Неправильная сумма оплаты ($amount). Сумма счета в биллинге $bill->merchantmoney."; }
else if (strtoupper(md5($string)) != strtoupper($signature)) { $error_msg = "4. Неправильная контрольная подпись."; }
else if ($request_type == "perform" and $status != "finished") { $error_msg = "5. Неправильный статус платежа ($status)."; }
else {
print "ok";
if ($request_type == "perform") {
MakeBillPayed($bill->id,1,"CoPAYCo Merchant ($payment_mode)");
}
mclose();
exit;
}
print "$error_msg";
if ($request_type == "perform") {
$manager_email=GetSetting('manager_email');
$msg = "Автоматическая оплата через CoPAYCo Merchant [$request_type] отклонена биллинг-системой по причине:nn$error_msgnn$inputnnMD5 by RootPanel: ".strtoupper(md5($string))."nnIP: $ipnn--nRootPanel";
$subject = "Ошибка автоматической оплаты [CoPAYCo]";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$msg);
}
while (list($i,$em) = @each($admEmails)) {
sendmail($em,'',$manager_email,$subject,$msg);
}
}
mclose();
}
?>