<?php
/**
 * 跳转中转
 */
require_once("../includes/fun.global.php");
$pay_row = pay::create_order($_QET); //构建参数
$scriptpath = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']);
$sitepath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
$siteurl = ($_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $sitepath . '/';
if (!isset($_SERVER['HTTP_USER_AGENT'])) $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 10.0) Safari/537.36';
switch ($pay_row['mode']) {
    case 'epay': #易支付
        require_once("epay/epay.config.php");
        require_once("epay/epay_submit.class.php");
        global $alipay_config;
        $notify_url = is_https(false) . $_SERVER['HTTP_HOST'] . "/other/notify_url.php";
        $return_url = is_https(false) . $_SERVER['HTTP_HOST'] . "/other/return_url.php";
        $parameter = array(
            "pid" => trim($alipay_config['partner']),
            "type" => $pay_row['data']['type'],
            "notify_url" => $siteurl . 'epay/epay.notify_url.php',
            "return_url" => $siteurl . 'epay/epay.return_url.php',
            "out_trade_no" => $pay_row['data']['order'],
            "name" => $pay_row['data']['name'],
            "money" => $pay_row['data']['money'],
            "sitename" => $conf['sitename']
        );
        //建立请求
        $alipaySubmit = new AlipaySubmit($alipay_config);
        $html_text = $alipaySubmit->buildRequestForm($parameter);
        echo $html_text;
        break;
    case 'cpay': #码支付
        require_once("cpay/cpay.config.php");
        require_once("cpay/cpay.submit.class.php");
        $url = cpay::cpay_sgin($pay_row, $cpay_array, $siteurl);
        echo "<script>window.location.href='{$url}';</script>";
        break;
    case 'fpay': #当面付
        require_once("apay/config.php");
        require_once("apay/alipay.php");
        break;
}
?>
