Ejemplo n.º 1
0
function trade_payurl($pay, $trade, $tradelog)
{
    global $_G;
    $key = DISCUZ_TENPAY_OPENTRANS_KEY;
    $chnid = DISCUZ_TENPAY_OPENTRANS_CHNID;
    $seller = $trade['tenpayaccount'];
    $mch_desc = $trade['subject'];
    $mch_name = $trade['subject'];
    $mch_price = $tradelog['baseprice'] * $tradelog['number'] * 100;
    $mch_returl = $_G['siteurl'] . 'api/trade/notify_trade.php';
    $mch_vno = $tradelog['orderid'];
    $show_url = $_G['siteurl'] . 'api/trade/notify_trade.php';
    $transport_desc = $pay['logistics_type'];
    $transport_fee = $tradelog['transportfee'] * 100;
    if (strtolower(CHARSET) == 'gbk') {
        $encode_type = '1';
    } else {
        $encode_type = '2';
    }
    $mch_type = '1';
    $need_buyerinfo = '1';
    if ($pay['logistics_type'] == 'VIRTUAL') {
        $mch_type = '2';
        $need_buyerinfo = '2';
    }
    $reqHandler = new MediPayRequestHandler();
    $reqHandler->init();
    $reqHandler->setKey($key);
    $reqHandler->setParameter("chnid", $chnid);
    $reqHandler->setParameter("encode_type", $encode_type);
    $reqHandler->setParameter("mch_desc", $mch_desc);
    $reqHandler->setParameter("mch_name", $mch_name);
    $reqHandler->setParameter("mch_price", $mch_price);
    $reqHandler->setParameter("mch_returl", $mch_returl);
    $reqHandler->setParameter("mch_type", $mch_type);
    $reqHandler->setParameter("mch_vno", $mch_vno);
    $reqHandler->setParameter("need_buyerinfo", $need_buyerinfo);
    $reqHandler->setParameter("seller", $seller);
    $reqHandler->setParameter("show_url", $show_url);
    $reqHandler->setParameter("transport_desc", $transport_desc);
    $reqHandler->setParameter("transport_fee", $transport_fee);
    $reqHandler->setParameter('attach', 'tenpay');
    $reqUrl = $reqHandler->getRequestURL();
    return $reqUrl;
}
Ejemplo n.º 2
0
function invite_payurl($amount, $price, &$orderid)
{
    include_once DISCUZ_ROOT . './source/class/class_chinese.php';
    global $_G;
    $date = dgmdate(TIMESTAMP, 'Ymd');
    $suffix = dgmdate(TIMESTAMP, 'His') . rand(1000, 9999);
    $transaction_id = DISCUZ_PARTNER . $date . $suffix;
    $orderid = dgmdate(TIMESTAMP, 'YmdHis') . random(14);
    if (!DISCUZ_TENPAY_DIRECT) {
        $reqHandler = new MediPayRequestHandler();
        $reqHandler->init();
        $reqHandler->setKey(DISCUZ_TENPAY_OPENTRANS_KEY);
        $encode_type = '1';
        if (strtolower(CHARSET) == 'utf-8') {
            $encode_type = '2';
        }
        $reqHandler->setParameter("chnid", DISCUZ_TENPAY_OPENTRANS_CHNID);
        $reqHandler->setParameter("encode_type", $encode_type);
        $reqHandler->setParameter("mch_desc", lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit') . '_(' . $_G['clientip'] . ')');
        $reqHandler->setParameter("mch_name", lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit'));
        $reqHandler->setParameter("mch_price", $price * 100);
        $reqHandler->setParameter("mch_returl", $_G['siteurl'] . 'api/trade/notify_invite.php');
        $reqHandler->setParameter("mch_type", '2');
        $reqHandler->setParameter("mch_vno", $orderid);
        $reqHandler->setParameter("need_buyerinfo", '2');
        $reqHandler->setParameter("seller", DISCUZ_TENPAY_OPENTRANS_CHNID);
        $reqHandler->setParameter("show_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
        $reqHandler->setParameter("transport_desc", '');
        $reqHandler->setParameter("transport_fee", 0);
        $reqHandler->setParameter('attach', 'tenpay');
        $reqUrl = $reqHandler->getRequestURL();
        return $reqUrl;
    }
    $reqHandler = new RequestHandler();
    $reqHandler->setGateURL("https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi");
    $reqHandler->init();
    $reqHandler->setKey(DISCUZ_SECURITYCODE);
    $reqHandler->setParameter("bargainor_id", DISCUZ_PARTNER);
    $reqHandler->setParameter("sp_billno", $orderid);
    $reqHandler->setParameter("transaction_id", $transaction_id);
    $reqHandler->setParameter("total_fee", $price * 100);
    $reqHandler->setParameter("return_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
    $chinese = new Chinese(strtoupper(CHARSET), 'GBK');
    $reqHandler->setParameter("desc", $chinese->Convert(lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit') . '_(' . $_G['clientip'] . ')'));
    $reqHandler->setParameter("cmdno", "1");
    $reqHandler->setParameter("date", $date);
    $reqHandler->setParameter("fee_type", "1");
    $reqHandler->setParameter("attach", "tenpay");
    $reqHandler->setParameter("bank_type", "0");
    $reqHandler->setParameter("agentid", DISCUZ_AGENTID);
    $reqHandler->setParameter("key_index", "1");
    $reqHandler->setParameter("verify_relation_flag", "1");
    $reqHandler->setParameter("ver", "3");
    $reqHandler->setParameter("spbill_create_ip", $_G['clientip']);
    $reqUrl = $reqHandler->getRequestURL();
    return $reqUrl;
}
Ejemplo n.º 3
0
function pay_team_tenpay($total_money, $order)
{
    global $INI;
    if ($total_money <= 0 || !$order) {
        return null;
    }
    $team = Table::Fetch('team', $order['team_id']);
    $order_id = $order['id'];
    $guarantee = strtoupper($INI['tenpay']['guarantee']) == 'Y';
    $v_mid = $INI['tenpay']['mid'];
    $v_url = $INI['system']['wwwprefix'] . '/order/tenpay/return.php';
    $key = $INI['tenpay']['sec'];
    $v_oid = $order['pay_id'];
    $v_amount = strval($total_money * 100);
    $v_moneytype = $INI['system']['currencyname'];
    $text = $v_amount . $v_moneytype . $v_oid . $v_mid . $v_url . $key;
    /* must */
    $sp_billno = $v_oid;
    $transaction_id = $v_mid . date('Ymd') . date('His') . rand(1000, 9999);
    $desc = mb_convert_encoding($team['product'], 'GBK', 'UTF-8');
    if (strlen($desc) > 32) {
        $desc = substr($desc, 0, 30);
    }
    /* end */
    if ($guarantee) {
        $medi_url = $INI['system']['wwwprefix'] . '/order/tenpay/medi_return.php';
        $show_url = $INI['system']['wwwprefix'] . '/order/tenpay/show.php';
        /* 物流公司或物流方式说明 */
        $transport_desc = "";
        /* 需买方另支付的物流费用,以分为单位 */
        $transport_fee = "";
        $reqHandler = new MediPayRequestHandler();
        $reqHandler->init();
        $reqHandler->setKey($key);
        $reqHandler->setParameter("chnid", $v_mid);
        $reqHandler->setParameter("encode_type", "1");
        $reqHandler->setParameter("mch_desc", $desc);
        $reqHandler->setParameter("mch_name", $desc);
        $reqHandler->setParameter("mch_price", $v_amount);
        $reqHandler->setParameter("mch_returl", $medi_url);
        $reqHandler->setParameter("mch_type", '1');
        $reqHandler->setParameter("mch_vno", $sp_billno);
        $reqHandler->setParameter("need_buyerinfo", "2");
        $reqHandler->setParameter("seller", $v_mid);
        $reqHandler->setParameter("show_url", $show_url);
        $reqHandler->setParameter("transport_desc", $transport_desc);
        $reqHandler->setParameter("transport_fee", $transport_fee);
        $reqUrl = $reqHandler->getRequestURL();
    } else {
        $reqHandler = new PayRequestHandler();
        $reqHandler->init();
        $reqHandler->setKey($key);
        $reqHandler->setParameter("bargainor_id", $v_mid);
        $reqHandler->setParameter("cs", "GBK");
        $reqHandler->setParameter("sp_billno", $sp_billno);
        $reqHandler->setParameter("transaction_id", $transaction_id);
        $reqHandler->setParameter("total_fee", $v_amount);
        $reqHandler->setParameter("return_url", $v_url);
        $reqHandler->setParameter("desc", $desc);
        $reqHandler->setParameter("spbill_create_ip", Utility::GetRemoteIp());
        $reqUrl = $reqHandler->getRequestURL();
    }
    if (is_post() && $_POST['paytype'] != 'tenpay') {
        $reqHandler->setParameter('bank_type', pay_getqqbank($_POST['paytype']));
        $reqUrl = $reqHandler->getRequestURL();
        redirect($reqUrl);
    }
    return render('block_pay_tenpay', array('order_id' => $order_id, 'reqUrl' => $reqUrl));
}
Ejemplo n.º 4
0
 private function mediPay($data = array())
 {
     require_once "tenpay_class/MediPayRequestHandler.class.php";
     //date_default_timezone_set(PRC);
     $curDateTime = date("YmdHis");
     $randNum = rand(1000, 9999);
     /* 平台商密钥 */
     $key = $data['key'];
     /* 平台商帐号 */
     $chnid = $data['chnid'];
     /* 卖家 */
     $seller = $data['seller'];
     /* 交易说明 */
     $mch_desc = $data['store'] . ", 订单号:" . $data['order_id'];
     /* 商品名称 */
     $mch_name = $data['store'] . "订单号:" . $data['order_id'];
     /* 商品总价,单位为分 */
     $mch_price = $data['total_fee'];
     /* 回调通知URL */
     $mch_returl = $data['callback'];
     /* 商家的定单号 */
     $mch_vno = $curDateTime . $randNum;
     /* 支付后的商户支付结果展示页面 */
     $show_url = $data['return'];
     /* 物流公司或物流方式说明 */
     $transport_desc = "";
     /* 需买方另支付的物流费用,以分为单位 */
     $transport_fee = "";
     /* 创建支付请求对象 */
     $reqHandler = new MediPayRequestHandler();
     $reqHandler->init();
     $reqHandler->setKey($key);
     //----------------------------------------
     //设置支付参数
     //----------------------------------------
     $reqHandler->setParameter("chnid", $chnid);
     //平台商帐号
     $reqHandler->setParameter("encode_type", "2");
     //编码类型 1:gbk 2:utf-8
     $reqHandler->setParameter("mch_desc", $mch_desc);
     //交易说明
     $reqHandler->setParameter("mch_name", $mch_name);
     //商品名称
     $reqHandler->setParameter("mch_price", $mch_price);
     //商品总价,单位为分
     $reqHandler->setParameter("mch_returl", $mch_returl);
     //回调通知URL
     $reqHandler->setParameter("mch_type", "1");
     //交易类型:1、实物交易,2、虚拟交易
     $reqHandler->setParameter("mch_vno", $mch_vno);
     //商家的定单号
     $reqHandler->setParameter("need_buyerinfo", "2");
     //是否需要在财付通填定物流信息,1:需要,2:不需要。
     $reqHandler->setParameter("seller", $seller);
     //卖家财付通帐号
     $reqHandler->setParameter("show_url", $show_url);
     //支付后的商户支付结果展示页面
     $reqHandler->setParameter("transport_desc", $transport_desc);
     //物流公司或物流方式说明
     $reqHandler->setParameter("transport_fee", $transport_fee);
     //需买方另支付的物流费用
     //请求的URL
     $reqUrl = $reqHandler->getRequestURL();
     return $reqUrl;
 }