Beispiel #1
0
        public static string QuickPayBegin(string sOrderID, string sAccount, decimal dPrice, string sGame, string gatewayId, string cardTypeCombine)
        {
            string privateField = string.Format("{0}|{1}", sAccount, sGame);
            string sGameName    = PayAll.GetGameName(sGame.Split('|')[0]);
            string itemName     = string.Format("{0}{1}元游戏币充值", sGameName, dPrice.ToString());

            return(PayDirect(sOrderID, dPrice, privateField, itemName, gatewayId, cardTypeCombine));
        }
Beispiel #2
0
        private const string key          = "a2990e2986ef3b21a5400414216c089a"; //密钥

        public static string PayDirect(string sOrderID, string sAccount, decimal dPrice, string PayType, HttpContext Context, string return_url)
        {
            string sPayUrl   = "https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi";
            string date      = DateTime.Now.ToString("yyyyMMdd");
            string strReq    = "" + DateTime.Now.ToString("HHmmss") + TenpayUtil.BuildRandomStr(4);
            string sp_billno = sOrderID.Substring(0, 32);
            //财付通订单号,10位商户号+8位日期+10位序列号,需保证全局唯一
            string transaction_id = bargainor_id + date + strReq;
            //创建PayRequestHandler实例
            PayRequestHandler reqHandler = new PayRequestHandler(Context);

            reqHandler.setKey(key);
            reqHandler.setGateUrl(sPayUrl);
            string  attach = string.Format("{0}|{1}|{2}", sOrderID.Substring(32), sAccount, PayType);
            decimal price  = Convert.ToInt32(dPrice * 100);

            //初始化
            reqHandler.init();
            string desc = string.Empty;

            if (PayType == "wlb")
            {
                desc = string.Format("到武林{0}元武林币充值", dPrice.ToString());
            }
            else
            {
                string sGameAbbre = PayType.Split('|')[0];
                string sGameName  = PayAll.GetGameName(sGameAbbre);
                desc = string.Format("到武林{0}元{1}游戏直冲", dPrice.ToString(), sGameName);
            }
            //-----------------------------
            //设置支付参数
            //-----------------------------
            reqHandler.setParameter("bargainor_id", bargainor_id);     //商户号
            reqHandler.setParameter("sp_billno", sp_billno);           //商家订单号
            reqHandler.setParameter("transaction_id", transaction_id); //财付通交易单号
            reqHandler.setParameter("return_url", return_url);         //支付通知url
            reqHandler.setParameter("desc", desc);                     //商品名称
            reqHandler.setParameter("total_fee", price.ToString());    //商品金额,以分为单位
            reqHandler.setParameter("attach", attach);                 //商家数据包,原样返回
            reqHandler.setParameter("cs", "utf-8");
            //用户ip,测试环境时不要加这个ip参数,正式环境再加此参数
            string UserIP = ProvideCommon.GetRealIP();

            reqHandler.setParameter("spbill_create_ip", UserIP);
            //post实现方式
            reqHandler.getRequestURL();
            StringBuilder sbText = new StringBuilder();

            sbText.AppendFormat("<form id='tenpaysubmit' name='tenpaysubmit' method=\"post\" action=\"{0}\">", reqHandler.getGateUrl());
            Hashtable ht = reqHandler.getAllParameters();

            foreach (DictionaryEntry de in ht)
            {
                sbText.AppendFormat("<input type=\"hidden\" name=\"{0}\" value=\"{1}\" >", de.Key, de.Value);
            }
            sbText.Append("<input type='submit' value='submit' style='display:none;'></form>");
            sbText.Append("<script>document.forms['tenpaysubmit'].submit();</script>");
            FirstOfPayPointBLL.Add(sOrderID, UserIP, sbText.ToString());
            return(sbText.ToString());
        }