<?php
require_once ('../system/func.php');
auth();

if (isset($_GET['almaz'])){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://api.xsolla.com/merchant/merchants/23775/token');
    $h = array("Content-Type: application/json");
    curl_setopt($curl, CURLOPT_HTTPHEADER, $h);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, '23775:KhlODRtQ93mvkAzm');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl, CURLOPT_POST, true);
    $json = array("user" => array("id" => array("value" => $user['id'], "hidden" => true)), "settings" => array("project_id" => 16248/*, "mode" => "sandbox"*/));
    $json = json_encode($json);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
    $token = json_decode(curl_exec($curl))->token;
    curl_close($curl);
    if (isset($token)) {
//         header("Location:https://sandbox-secure.xsolla.com/paystation2/?access_token=$token");
        header("Location:https://secure.xsolla.com/paystation2/?access_token=$token");
        exit;
    } else {
        $_SESSION['msg'] = 'Ошибка платежной системы - обратитесь к администратору';
        header("Location:/xsolla/");
        exit;
    }
}
$title = 'Покупка Алмазов';
require_once ('../system/header.php');
echo "<div class='block'>";
//echo ico('icons','arrow.png')." Купить золото | <a href='/pay'>Обменник</a> ";
if($user[koll_gold] > 0)echo "<font color='green'>(+)</font>";
echo "</div>";
echo "<div class='block'>";
echo "<div class='center'><a href='?almaz' class='btn2'>Перейти к оплате</a></div><br>";

echo "<a href='https://secure.xsolla.com/paystation2/?theme=100&project=16248&marketplace=mobile&action=directpayment&v1=$user[id]&pid=1738'><img src='/images/pay/sms.png'> Мобильный платеж</a>";



echo "</div>";
require_once ('../system/footer.php');
?>

