<?php
require ($_SERVER['DOCUMENT_ROOT'].'/core/sys.php');
$id = abs(intval($_GET['id']));
$pay = $db->prepare('SELECT * FROM `pay` WHERE `id` = ?');
$pay -> execute([$id]);
$pay = $pay -> fetch(PDO :: FETCH_ASSOC);
$client = $db->prepare('SELECT * FROM `platform` WHERE `id` = ?');
$client -> execute([$pay['platform']]);
$client = $client -> fetch(PDO :: FETCH_ASSOC);
$out_summ = $pay['summa']+$pay['summa']*0.05; // сумма
/*Обработчик QIWI*/
$phone = file_get_contents('https://wordpay.ru/moduls/output/qiwimobile.php?phone='.$_GET['phone']);
if($phone == 0){
$_SESSION['message'] = 'Произошла ошибка, не верно указан номер телефона.';
header('Location: /payment/pay/qiwi/?id='.$pay['id']);
exit;
}
$_SESSION['qiwi'] = $pay['id'];

$data = CBR_XML_Daily_Ru();
$amount_usd = ($out_summ / $data->Valute->USD->Value);
$amount_usd = number_format($amount_usd, 2, '.', '');

#if(isset($_GET['usd'])) $usd = '&usd='.$amount_usd.'&';
$num = file_get_contents('https://wordpay.ru/payment/pay/qiwi/qiwisdk.php?money='.$out_summ.'&phone='.$_GET['phone'].'&id='.$pay['id']);
header('location: '.$num);
