Использую на страничке
<script>
$(document).ready(function() {
$("form").submit(function(event) {
event.preventDefault();
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(result) {
json = jQuery.parseJSON(result);
if (json.url) setTimeout(redirect, 2000, json.url);
swal({
title: json.header,
text: json.message,
icon: json.status,
});
}
});
});
});
function redirect(url) {
window.location.href = url;
}
</script>
case 'donate':{
if(isset($_POST['donate']) && !empty($_POST['donate'])){
require_once ENGINE_DIR.'/classes/payment.class.php';
$acc = $_POST['donat_id'];
$val = $_POST['donat_value'];
$server = $_POST['server'];
if(!empty($acc) && !empty($val)){
if($server == null || empty($server) || is_array($server) || $func->servers[ucfirst($server)] == null){
$func->setPopUp("error","Ошибка","Вы не выбрали сервер!");
}else{
$payment = new payment();
$payment->createPayment($acc,$val,$server);
$payid = $payment->payid;
$sign = hash('sha256', "ID_{$payid}{up}TEST+|+{$server}{up}{$server}{up}{$cost}{up}{$tableconf['unitpay']['secret_key']}");
exit(header("Location: https://unitpay.ru/pay/{$tableconf['unitpay']['shop_id']}?sum={$val}&account={$payid}&server={$server}&desc=Grand+RolePlay+|+{$server}&signature={$sign}"));
break;
}
}else{
$func->setPopUp("error","Ошибка","Вы указали не все данные!");
}
}
$footscripts = array(
"https://unpkg.com/sweetalert@2.1.2/dist/sweetalert.min.js"
);
$title = "#";
$page = PUBLIC_DIR.'/pages/donate.php';
break;
}