Beispiel #1
0
        public Config(PayHistory order)
        {
            var company = CompanyType.支付宝WAP;

            #region 支付宝参数,必须按照以下值传递
            Req_url = "http://wappaygw.alipay.com/service/rest.htm";

            V = "2.0";
            Service_Create     = "alipay.wap.trade.create.direct";
            Service_Auth       = "alipay.wap.auth.authAndExecute";
            Sec_id             = "MD5";
            Format             = "xml";
            Input_charset_UTF8 = "utf-8";
            #endregion

            #region 商户需要手动配置
            Partner             = ChargeConfig.GetConfigKey(company, ChargeConfig.DataType.User);
            Key                 = ChargeConfig.GetConfigKey(company, ChargeConfig.DataType.Key);
            Seller_account_name = ChargeConfig.GetConfigKey(company, "卖家账户名称");

            Req_id       = Guid.NewGuid().ToString();
            Out_trade_no = order.OrderId;
            Subject      = order.Desc;
            Total_fee    = order.Amount.ToString();
            Out_user     = order.UserId.ToString();
            //Call_back_url = "";
            //Notify_url = "";
            Merchant_url = ChargeConfig.GetConfigKey(company, "返回商户产品URL");
            #endregion
        }
Beispiel #2
0
        public override void Submit(PayHistory order)
        {
            base.BaseSubmit(order);

            var tenpay = new RequestHandler(HttpContext.Current);

            tenpay.init();
            tenpay.setKey(key);
            tenpay.setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
            tenpay.setParameter("total_fee", ((int)(order.Amount * 100)).ToString());
            //用户的公网ip,测试时填写127.0.0.1,只能支持10分以下交易
            tenpay.setParameter("spbill_create_ip", ip);
            tenpay.setParameter("return_url", return_url);
            tenpay.setParameter("partner", bargainor_id);
            tenpay.setParameter("out_trade_no", order.OrderId);
            tenpay.setParameter("notify_url", notify_url);
            tenpay.setParameter("attach", order.UserId.ToString());
            tenpay.setParameter("body", order.Desc);
            tenpay.setParameter("bank_type", order.BankType);


            //系统可选参数
            tenpay.setParameter("sign_type", "MD5");
            tenpay.setParameter("service_version", "1.0");
            tenpay.setParameter("input_charset", ChargeConfig.Charset);
            tenpay.setParameter("sign_key_index", "1");



            string url = tenpay.getRequestURL();

            HttpContext.Current.Response.Redirect(url);
        }
Beispiel #3
0
 public override void Submit(PayHistory order)
 {
     BaseSubmit(order);
     var request = new ChargeRequest();
     request.merchantAcctId = merchantAcctId;
     request.payerName = "";
     request.payerContactType = "1";
     request.orderId = order.OrderId;
     request.orderAmount = (Convert.ToInt32(order.Amount) * 100).ToString();
     request.orderTime = DateTime.Now.ToString("yyyyMMddHHmmss");
     request.productName = "在线支付";
     request.productNum = "1";
     request.productDesc = "在线支付";
     request.payType = "00";
     request.ext1 = order.UserId.ToString();
     request.bgUrl = notify_url;
     request.MakeSign();
     var fields = request.GetType().GetProperties();
     //测试
     string html = "<form id='form1' name='form1' action='https://sandbox.99bill.com/gateway/recvMerchantInfoAction.htm' method='post'>\r\n";
     foreach (var item in fields)
     {
         html += string.Format("<input type='hidden' Name='{0}' value='{1}' />\r\n", item.Name, item.GetValue(request, null));
     }
     html += "</form>\r\n";
     html += "<script>form1.submit()</script>";
     //Log(html);
     HttpContext.Current.Response.Write(html);
 }
Beispiel #4
0
        /// <summary>
        /// WAP认证支付
        /// 首次需传入银行卡进行绑定
        /// 再次按绑定的银行卡进行支付
        /// </summary>
        /// <param name="order"></param>
        /// <param name="id_no"></param>
        /// <param name="acct_name"></param>
        /// <param name="card_no"></param>
        /// <param name="no_agree"></param>
        /// <param name="risk_item"></param>
        public void WapAuthSubmit(PayHistory order, string id_no, string acct_name, string card_no, string no_agree, string risk_item)
        {
            var request = new Message.WapAuth.PayRequest();

            request.version      = PartnerConfig.VERSION;
            request.oid_partner  = PartnerConfig.OID_PARTNER;
            request.user_id      = order.UserId.ToString();
            request.sign_type    = PartnerConfig.SIGN_TYPE;
            request.busi_partner = PartnerConfig.BUSI_PARTNER;
            request.no_order     = order.OrderId;
            request.dt_order     = YinTongUtil.getCurrentDateTimeStr();
            request.name_goods   = "在线充值";
            request.money_order  = order.Amount.ToString();
            request.notify_url   = CoreHelper.CustomSetting.GetConfigKey("lianlianWapAuthNotifyUrl");
            request.url_return   = CoreHelper.CustomSetting.GetConfigKey("lianlianWapAuthReturnUrl");
            request.id_type      = "0";
            request.id_no        = id_no;
            request.acct_name    = acct_name;
            request.card_no      = card_no;
            request.no_agree     = no_agree;
            request.risk_item    = risk_item;//风控参数
            request.SetSign();
            var           data   = CoreHelper.SerializeHelper.SerializerToJson(request, Encoding.UTF8);
            StringBuilder sbHtml = new StringBuilder();

            sbHtml.Append("<form id='payBillForm' action='" + request.InterFaceUrl + "' method='post'>");
            sbHtml.Append("<input name='req_data' value='" + data + "' /></form>");
            sbHtml.Append("<script>document.forms['payBillForm'].submit();</script>");
            System.Web.HttpContext.Current.Response.Write(sbHtml.ToString());
        }
Beispiel #5
0
        public override void Submit(PayHistory order)
        {
            base.BaseSubmit(order);
            var request = new Message.Web.PayRequest();
            request.version = PartnerConfig.VERSION;
            request.oid_partner = PartnerConfig.OID_PARTNER;
            request.user_id = order.UserId.ToString();
            request.timestamp = YinTongUtil.getCurrentDateTimeStr();
            request.sign_type = PartnerConfig.SIGN_TYPE;
            request.busi_partner = PartnerConfig.BUSI_PARTNER;
            request.no_order = order.OrderId;
            request.dt_order = YinTongUtil.getCurrentDateTimeStr();	
            request.name_goods = "在线充值";
            request.money_order = order.Amount.ToString();
            request.notify_url = notify_url;
            request.url_return = return_url;
            request.SetSign();
            var fields = request.GetType().GetFields();
            StringBuilder sbHtml = new StringBuilder();
            sbHtml.Append("<form id='payBillForm' action='" + request.InterFaceUrl + "' method='post'>");

            foreach (var temp in fields)
            {
                sbHtml.Append("<input type='hidden' name='" + temp.Name + "' value='" + temp.GetValue(request) + "'/>");
            }
            //submit按钮控件请不要含有name属性
            sbHtml.Append("<input type='submit' value='tijiao' style='display:none;'></form>");
            sbHtml.Append("<script>document.forms['payBillForm'].submit();</script>");
            HttpContext.Current.Response.Write(sbHtml.ToString());
        }
Beispiel #6
0
        public override void Submit(PayHistory order)
        {
            base.BaseSubmit(order);
            var request = new Message.Web.PayRequest();

            request.version      = PartnerConfig.VERSION;
            request.oid_partner  = PartnerConfig.OID_PARTNER;
            request.user_id      = order.UserId.ToString();
            request.timestamp    = YinTongUtil.getCurrentDateTimeStr();
            request.sign_type    = PartnerConfig.SIGN_TYPE;
            request.busi_partner = PartnerConfig.BUSI_PARTNER;
            request.no_order     = order.OrderId;
            request.dt_order     = YinTongUtil.getCurrentDateTimeStr();
            request.name_goods   = "在线充值";
            request.money_order  = order.Amount.ToString();
            request.notify_url   = notify_url;
            request.url_return   = return_url;
            request.SetSign();
            var           fields = request.GetType().GetFields();
            StringBuilder sbHtml = new StringBuilder();

            sbHtml.Append("<form id='payBillForm' action='" + request.InterFaceUrl + "' method='post'>");

            foreach (var temp in fields)
            {
                sbHtml.Append("<input type='hidden' name='" + temp.Name + "' value='" + temp.GetValue(request) + "'/>");
            }
            //submit按钮控件请不要含有name属性
            sbHtml.Append("<input type='submit' value='tijiao' style='display:none;'></form>");
            sbHtml.Append("<script>document.forms['payBillForm'].submit();</script>");
            HttpContext.Current.Response.Write(sbHtml.ToString());
        }
Beispiel #7
0
        public override void Submit(PayHistory order)
        {
            base.BaseSubmit(order);

            var tenpay = new RequestHandler(HttpContext.Current);
            tenpay.init();
            tenpay.setKey(key);
            tenpay.setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
            tenpay.setParameter("total_fee", ((int)(order.Amount * 100)).ToString());
            //用户的公网ip,测试时填写127.0.0.1,只能支持10分以下交易
            tenpay.setParameter("spbill_create_ip", ip);
            tenpay.setParameter("return_url", return_url);
            tenpay.setParameter("partner", bargainor_id);
            tenpay.setParameter("out_trade_no", order.OrderId);
            tenpay.setParameter("notify_url", notify_url);
            tenpay.setParameter("attach", order.UserId.ToString());
            tenpay.setParameter("body", order.Desc);
            tenpay.setParameter("bank_type", order.BankType);


            //系统可选参数
            tenpay.setParameter("sign_type", "MD5");
            tenpay.setParameter("service_version", "1.0");
            tenpay.setParameter("input_charset", ChargeConfig.Charset);
            tenpay.setParameter("sign_key_index", "1");



            string url= tenpay.getRequestURL();

            HttpContext.Current.Response.Redirect(url);

        }
Beispiel #8
0
 /// <summary>
 /// 转向页执行此方法
 /// 这里为了实现自定义转向
 /// </summary>
 /// <param name="order"></param>
 public void Redirect(PayHistory order)
 {
     if (!string.IsNullOrEmpty(order.RedirectUrl))
     {
         HttpContext.Current.Response.Redirect(order.RedirectUrl + "?amount=" + order.Amount + "&orderId=" + order.OrderId + "&companyType=" + (int)order.CompanyType + "&ProductOrderId=" + order.ProductOrderId);
     }
 }
Beispiel #9
0
        public Config(PayHistory order)
        {
            var company = CompanyType.支付宝WAP;
            #region 支付宝参数,必须按照以下值传递
            Req_url = "http://wappaygw.alipay.com/service/rest.htm";
            
            V = "2.0";
            Service_Create = "alipay.wap.trade.create.direct";
            Service_Auth = "alipay.wap.auth.authAndExecute";
            Sec_id = "MD5";
            Format = "xml";
            Input_charset_UTF8 = "utf-8";
            #endregion

            #region 商户需要手动配置
            Partner = ChargeConfig.GetConfigKey(company, ChargeConfig.DataType.User);
            Key = ChargeConfig.GetConfigKey(company, ChargeConfig.DataType.Key);
            Seller_account_name = ChargeConfig.GetConfigKey(company, "卖家账户名称");

            Req_id = Guid.NewGuid().ToString();
            Out_trade_no = order.OrderId;
            Subject = order.Desc;
            Total_fee = order.Amount.ToString();
            Out_user = order.UserId.ToString();
            //Call_back_url = "";
            //Notify_url = "";
            Merchant_url = ChargeConfig.GetConfigKey(company, "返回商户产品URL");
            #endregion
        }
Beispiel #10
0
        /**
         * 调用统一下单,获得下单结果
         * @return 统一下单结果
         * @失败时抛异常WxPayException
         */
        public WxPayData GetUnifiedOrderResult(PayHistory order)
        {
            //统一下单
            WxPayData data = new WxPayData();

            data.SetValue("body", "test");
            data.SetValue("attach", "test");
            data.SetValue("out_trade_no", order.OrderId);
            data.SetValue("total_fee", total_fee);
            data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
            data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
            data.SetValue("goods_tag", "test");
            data.SetValue("trade_type", "JSAPI");
            data.SetValue("openid", openid);

            WxPayData result = WxPayApi.UnifiedOrder(data);

            if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "")
            {
                Log.Error(this.GetType().ToString(), "UnifiedOrder response error!");
                throw new WxPayException("UnifiedOrder response error!");
            }

            unifiedOrderResult = result;
            return(result);
        }
Beispiel #11
0
        public override void Submit(PayHistory order)
        {
            BaseSubmit(order);
            var request = new ChargeRequest();

            request.merchantAcctId   = merchantAcctId;
            request.payerName        = "";
            request.payerContactType = "1";
            request.orderId          = order.OrderId;
            request.orderAmount      = (Convert.ToInt32(order.Amount) * 100).ToString();
            request.orderTime        = DateTime.Now.ToString("yyyyMMddHHmmss");
            request.productName      = "在线支付";
            request.productNum       = "1";
            request.productDesc      = "在线支付";
            request.payType          = "00";
            request.ext1             = order.UserId.ToString();
            request.bgUrl            = notify_url;
            request.MakeSign();
            var fields = request.GetType().GetProperties();
            //测试
            string html = "<form id='form1' name='form1' action='https://sandbox.99bill.com/gateway/recvMerchantInfoAction.htm' method='post'>\r\n";

            foreach (var item in fields)
            {
                html += string.Format("<input type='hidden' Name='{0}' value='{1}' />\r\n", item.Name, item.GetValue(request, null));
            }
            html += "</form>\r\n";
            html += "<script>form1.submit()</script>";
            //Log(html);
            HttpContext.Current.Response.Write(html);
        }
        /**
         * 调用统一下单,获得下单结果
         * @return 统一下单结果
         * @失败时抛异常WxPayException
         */
        public WxPayData GetUnifiedOrderResult(PayHistory order, string trade_type = "JSAPI")
        {
            //统一下单
            WxPayData data = new WxPayData();

            data.SetValue("body", order.Desc);
            data.SetValue("attach", order.TagData);
            data.SetValue("out_trade_no", order.OrderId);
            data.SetValue("total_fee", total_fee);
            data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
            data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
            data.SetValue("goods_tag", order.TagData);
            data.SetValue("trade_type", trade_type);
            data.SetValue("notify_url", WxPayConfig.NOTIFY_URL);//异步通知url
            if (trade_type == "JSAPI")
            {
                data.SetValue("openid", openid);
            }
            WxPayData result = WxPayApi.UnifiedOrder(data);

            if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "")
            {
                Log.Error(this.GetType().ToString(), "UnifiedOrder response error!");
                throw new WxPayException("UnifiedOrder response error!" + result.GetValue("return_msg"));
            }

            unifiedOrderResult = result;
            return(result);
        }
Beispiel #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            PayHistory payHistory = db.PayHistories.Find(id);

            db.PayHistories.Remove(payHistory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #14
0
 public override bool CheckOrder(PayHistory order, out string message)
 {
     var result = OrderQuery.Run("", order.OrderId, out message);//调用订单查询业务逻辑
     if (result)
     {
         Confirm(order, GetType(), order.Amount);
     }
     return result;
 }
Beispiel #15
0
		/// <summary>
		/// 提交到数据库+
		/// 对于代理,需查询OrderType为Charge的记录
		/// </summary>
		/// <param name="order"></param>
		protected void BaseSubmit(PayHistory order)
		{
            if (string.IsNullOrEmpty(order.OrderId))
            {
                throw new Exception("没有指定OrderId");
            }
            OnlinePayBusiness.Instance.Add(order);
            string log = string.Format("提交订单 {0} {1} {2} {3}", order.UserId, order.OrderId, order.Amount, order.OrderType);
            Log(log, false);
		}
Beispiel #16
0
 /// <summary>
 /// 订单退款方法
 /// </summary>
 /// <param name="order"></param>
 protected internal void BaseRefundOrder(PayHistory order)
 {
     ///未确认的订单不能退款
     if (order.Status != OrderStatus.已确认)
     {
         return;
     }
     OnlinePayBusiness.Instance.RefundOrder(order);
     Log("支付订单被退款:" + order.OrderId + " amount:" + order.Amount, true);
 }
Beispiel #17
0
        public override bool CheckOrder(PayHistory order, out string message)
        {
            var result = OrderQuery.Run("", order.OrderId, out message);//调用订单查询业务逻辑

            if (result)
            {
                Confirm(order, GetType(), order.Amount);
            }
            return(result);
        }
Beispiel #18
0
 public ActionResult Edit([Bind(Include = "Id,EmployeeId,SalaryBefore,SalaryAfter,HourlyBefore,HourlyAfter,DateApplied")] PayHistory payHistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payHistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.Users, "Id", "Email", payHistory.EmployeeId);
     return(View(payHistory));
 }
Beispiel #19
0
 /// <summary>
 /// 开始支付,输出到页面wxJsApiParam
 /// 页面执行脚本调用微信
 /// </summary>
 /// <param name="order"></param>
 /// <returns></returns>
 public string BeginPay(PayHistory order)
 {
     BaseSubmit(order);
     JsApiPay jsApiPay = new JsApiPay(System.Web.HttpContext.Current);
     jsApiPay.openid = order.TagData;//传入OPENID
     jsApiPay.total_fee = Convert.ToInt32(order.Amount * 100);
     //JSAPI支付预处理
     WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(order);
     var wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数                    
     return wxJsApiParam;
 }
Beispiel #20
0
        /// <summary>
        /// 开始支付,输出到页面wxJsApiParam
        /// 页面执行脚本调用微信
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public string BeginPay(PayHistory order)
        {
            BaseSubmit(order);
            JsApiPay jsApiPay = new JsApiPay(System.Web.HttpContext.Current);

            jsApiPay.openid    = order.TagData;//传入OPENID
            jsApiPay.total_fee = Convert.ToInt32(order.Amount * 100);
            //JSAPI支付预处理
            WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(order);
            var       wxJsApiParam       = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数

            return(wxJsApiParam);
        }
Beispiel #21
0
        protected override string OnNotify(System.Web.HttpContext context)
        {
            ResultNotify resultNotify = new ResultNotify(context);
            string       error;
            string       out_trade_no;
            var          a = resultNotify.ProcessNotify(out error, out out_trade_no);

            if (a)
            {
                PayHistory order = OnlinePayBusiness.Instance.GetOrder(out_trade_no, ThisCompanyType);
                Confirm(order, GetType(), order.Amount);
            }
            return("");
        }
Beispiel #22
0
        /// <summary>
        /// 扫码支付,返回二维码支付链接
        /// 按此链接生成二维码
        /// </summary>
        /// <param name="order"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        public string GetNativePayUrl(PayHistory order, string openId)
        {
            BaseSubmit(order);
            JsApiPay jsApiPay = new JsApiPay(System.Web.HttpContext.Current);

            jsApiPay.openid    = openId;
            jsApiPay.total_fee = Convert.ToInt32(order.Amount * 100);
            //JSAPI支付预处理
            WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(order);

            //var wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数
            //return wxJsApiParam;
            return(unifiedOrderResult.GetValue("code_url").ToString());
        }
Beispiel #23
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PayHistory payHistory = db.PayHistories.Find(id);

            if (payHistory == null)
            {
                return(HttpNotFound());
            }
            return(View(payHistory));
        }
Beispiel #24
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PayHistory payHistory = db.PayHistories.Find(id);

            if (payHistory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId = new SelectList(db.Users, "Id", "Email", payHistory.EmployeeId);
            return(View(payHistory));
        }
Beispiel #25
0
        protected override string OnNotify(System.Web.HttpContext context)
        {
            ResultNotify resultNotify = new ResultNotify(context);

            var result = resultNotify.ProcessNotify();
            var a      = result.GetValue("return_code").ToString() == "SUCCESS";

            if (a)
            {
                var        out_trade_no = result.GetValue("out_trade_no").ToString();
                PayHistory order        = OnlinePayBusiness.Instance.GetOrder(out_trade_no, ThisCompanyType);
                Confirm(order, GetType(), order.Amount);
            }
            return(result.ToXml());;
        }
Beispiel #26
0
        protected override string OnNotify(HttpContext context)
        {
            var    response = ChargeNotify.FromRequest(context.Request.QueryString);
            var    a        = response.CheckSign();
            int    result   = 1;
            string msg1     = "error";

            if (a && response.payResult == "10")
            {
                PayHistory order = OnlinePayBusiness.Instance.GetOrder(response.orderId, ThisCompanyType);
                Confirm(order, GetType(), Convert.ToDecimal(response.payAmount) / 100);
                result = 1;
                msg1   = "success";
            }
            return("<result>" + result + "</result><redirecturl>" + return_url + "?msg=" + msg1 + "</redirecturl>");
        }
Beispiel #27
0
        /// <summary>
        /// 开始支付,输出到页面wxJsApiParam
        /// 页面执行脚本调用微信
        /// </summary>
        /// <param name="order"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        public string BeginPay(PayHistory order, string openId)
        {
            BaseSubmit(order);
            JsApiPay jsApiPay = new JsApiPay(System.Web.HttpContext.Current);

            jsApiPay.openid = openId;
            if (string.IsNullOrEmpty(jsApiPay.openid))
            {
                throw new Exception("openid为空,请传入 openId");
            }
            jsApiPay.total_fee = Convert.ToInt32(order.Amount * 100);
            //JSAPI支付预处理
            WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(order);
            var       wxJsApiParam       = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数

            return(wxJsApiParam);
        }
Beispiel #28
0
		/// <summary>
		/// 生成订单实例
		/// </summary>
		/// <param name="money"></param>
		/// <param name="userId"></param>
		/// <param name="userType"></param>
		/// <returns></returns>
        public PayHistory CreateOrder(decimal amount, int userId)
        {
            if (amount <= 0)
            {
                throw new Exception("支付金额不能小于或等于0");
            }
            PayHistory order = new PayHistory();
            order.Amount = amount;
            order.CompanyType = ThisCompanyType;
            order.Status = OrderStatus.已提交;
            order.UserId = userId;
            lock (lockObj)
            {
                order.OrderId = CreateOrderId();
            }
            return order;    
        }
Beispiel #29
0
        public override void Submit(PayHistory order)
        {
            //初始化Service
            Service ali     = new Service();
            var     context = HttpContext.Current;
            var     config  = new Config(order);

            config.Notify_url    = NotifyUrl;
            config.Call_back_url = ReturnUrl;
            //创建交易接口
            string token = ali.alipay_wap_trade_create_direct(
                config.Req_url, config.Subject, config.Out_trade_no, config.Total_fee, config.Seller_account_name, config.Notify_url,
                config.Out_user, config.Merchant_url, config.Call_back_url, config.Service_Create, config.Sec_id, config.Partner, config.Req_id, config.Format, config.V, config.Input_charset_UTF8, config.Req_url, config.Key, config.Sec_id);

            //构造,重定向URL
            string url = ali.alipay_Wap_Auth_AuthAndExecute(config.Req_url, config.Sec_id, config.Partner, config.Call_back_url, config.Format, config.V, config.Service_Auth, token, config.Input_charset_UTF8, config.Req_url, config.Key, config.Sec_id);

            //跳转收银台支付页面
            System.Web.HttpContext.Current.Response.Redirect(url);
        }
Beispiel #30
0
        protected override string OnNotify(System.Web.HttpContext context)
        {
            StreamReader stream = new StreamReader(context.Request.InputStream);
            string       json   = stream.ReadToEnd();

            stream.Close();
            var response = Message.MessageBase.FromRequest <Message.Web.PayNotify>(json);
            var a        = response.CheckSign();

            if (a && response.result_pay == "SUCCESS")
            {
                PayHistory order = OnlinePayBusiness.Instance.GetOrder(response.no_order, ThisCompanyType);
                Confirm(order, GetType(), Convert.ToDecimal(response.money_order));
                var result = new { ret_code = "0000", ret_msg = "交易成功" };
                return(CoreHelper.SerializeHelper.SerializerToJson(result));
            }
            var result2 = new { ret_code = "9999", ret_msg = "失败" };

            return(CoreHelper.SerializeHelper.SerializerToJson(result2));
        }
Beispiel #31
0
        /// <summary>
        /// 提交支付,转向需要按具体需求重写
        /// </summary>
        /// <param name="order"></param>
        public override void Submit(PayHistory order)
        {
            BaseSubmit(order);
            string out_trade_no = order.OrderId;
            string subject      = order.Desc;                                                                                                              //商品名称
            string body         = order.UserId.ToString();                                                                                                 //商品描述
            string price        = order.Amount.ToString();                                                                                                 //商品价格
            string bankType     = order.BankType;                                                                                                          //银行代码
            string token        = (HttpContext.Current.Session["ali_token"] != null) ? HttpContext.Current.Session["ali_token"].ToString() : string.Empty; // 支付宝来源用户的验证码

            //相关参数名称具体含义,可以在支付宝接口服务文档中查询到,
            //以上两个文件,通知正常都可以在notify data目录找到通知过来的日志
            string aliay_url = string.Empty;

            if (token == string.Empty)
            {
                //HttpContext.Current.Request.QueryString["is_company"] 判断企业网银支付渠道
                if (HttpContext.Current.Request.QueryString["is_company"] != null && HttpContext.Current.Request.QueryString["is_company"].ToString() != "")
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType);
                }
                else
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType);
                }
            }
            else
            {
                if (HttpContext.Current.Request.QueryString["is_company"] != null && HttpContext.Current.Request.QueryString["is_company"].ToString() != "")
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType, token);
                }
                else
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType, token);
                }
            }
            //HttpContext.Current.Response.Write(aliay_url);
            //HttpContext.Current.Response.End();
            HttpContext.Current.Response.Redirect(aliay_url);
        }
Beispiel #32
0
		/// <summary>
		/// 确认订单,失败会插入方法缓存,下次会自动重新执行方法
		/// </summary>
		/// <param name="orderNumber"></param>
		/// <param name="companyType"></param>
        //protected internal Order Confirm(string orderNumber, CompanyType companyType, Type fromType)
        //{
        //    Order order = OrderAction.GetOrder(orderNumber, companyType);
        //    if (order != null)
        //    {
        //        OrderAction.Confirm(order, fromType);
        //    }
        //    return order;
        //}

        /// <summary>
        /// 确认订单,并核对通知过来的金额
        /// </summary>
        /// <param name="order"></param>
        /// <param name="fromType"></param>
        /// <param name="notifyAmount">通知的订单金额,如果没有填原始订单的金额</param>
        protected internal void Confirm(PayHistory order, Type fromType,decimal notifyAmount)
        {
            if (order.Amount != notifyAmount)
            {
                string message = order.CompanyType + "订单金额和支付金额对不上:" + order.OrderId + " 订单金额:" + order.Amount + " 通知金额:" + notifyAmount;
                Log(message, true);
                throw new Exception(message);
            }
            string key = "IPayHistory_" + order.OrderId;
            if (!CoreHelper.ConcurrentControl.Check(key, 10))
            {
                Log("过滤重复通知确认:" + order.OrderId + " amount:" + order.Amount);
                return;
            }
            if (order.Status== OrderStatus.已确认 || order.Status == OrderStatus.已退款)
            {
                return;
            }
            OnlinePayBusiness.Instance.ConfirmByType(order, fromType);
            Log("确认订单:" + order.OrderId + " amount:" + order.Amount);
        }
Beispiel #33
0
 public override void Submit(PayHistory order)
 {
     BaseSubmit(order);
     var request = new ChargeSubmit();
     request.MerId = MerchantId;
     request.CmdId = "Buy";
     request.OrdId = order.OrderId;
     request.OrdAmt = order.Amount.ToString("f");
     request.BgRetUrl = NotifyUrl;
     request.RetUrl = ReturnUrl;
     request.ChkValue = request.MakeSign(MerchantId);
     var fields = request.GetType().GetFields();
     //测试
     string html = "<form id='form1' name='form1' action='https://mas.chinapnr.com/gar/RecvMerchant.do' method='post'>\r\n";
     foreach (var item in fields)
     {
         html += string.Format("<input type='hidden' Name='{0}' value='{1}' />\r\n", item.Name, item.GetValue(request));
     }
     html += "</form>\r\n";
     html += "<script>form1.submit()</script>";
     HttpContext.Current.Response.Write(html);
 }
Beispiel #34
0
        protected override string OnNotify(System.Web.HttpContext context)
        {
            context.Request.ContentEncoding = encode;
            var c      = context.Request.Form;
            var fields = typeof(ChargeResponse).GetFields();
            var obj    = new ChargeResponse();

            foreach (var item in fields)
            {
                item.SetValue(obj, c[item.Name]);
            }
            if (!obj.CheckSign(obj.ChkValue))
            {
                return("签名不正确");
            }
            if (obj.RespCode == "000000")
            {
                PayHistory order = OnlinePayBusiness.Instance.GetOrder(obj.OrdId, ThisCompanyType);
                Confirm(order, GetType(), Convert.ToDecimal(obj.OrdAmt));
                return(string.Format("RECV_ORD_ID_{0}", obj.OrdId));
            }
            return(string.Format("失败 {0}", obj.RespCode));
        }
Beispiel #35
0
        /// <summary>
        /// 查询订单状态,返回是否成功
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public override bool CheckOrder(PayHistory order, out string message)
        {
            string url         = AliPay.CreateQueryOrderUrl(company_gateway, "single_trade_query", partner, sign_type, order.OrderId, key, _input_charset);
            string responseTxt = CoreHelper.HttpRequest.HttpGet(url, Encoding.Default);

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(responseTxt);
                XmlNode node = doc.SelectSingleNode("alipay/response/trade/trade_status");
                if (node == null)
                {
                    message = "服务器返回:" + responseTxt;
                    return(false);
                }
                if (node != null)
                {
                    string trade_status = node.InnerText;
                    if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                    {
                        if (order.Status != OrderStatus.已确认)
                        {
                            Confirm(order, GetType(), order.Amount);
                        }
                        message = "成功";
                        return(true);
                    }
                }
            }
            catch (Exception ero)
            {
                message = "出现错误:" + ero.Message;
                return(false);
            }
            message = "失败";
            return(false);
        }
Beispiel #36
0
        public override void Submit(PayHistory order)
        {
            BaseSubmit(order);
            var request = new ChargeSubmit();

            request.MerId    = MerchantId;
            request.CmdId    = "Buy";
            request.OrdId    = order.OrderId;
            request.OrdAmt   = order.Amount.ToString("f");
            request.BgRetUrl = NotifyUrl;
            request.RetUrl   = ReturnUrl;
            request.ChkValue = request.MakeSign(MerchantId);
            var fields = request.GetType().GetFields();
            //测试
            string html = "<form id='form1' name='form1' action='https://mas.chinapnr.com/gar/RecvMerchant.do' method='post'>\r\n";

            foreach (var item in fields)
            {
                html += string.Format("<input type='hidden' Name='{0}' value='{1}' />\r\n", item.Name, item.GetValue(request));
            }
            html += "</form>\r\n";
            html += "<script>form1.submit()</script>";
            HttpContext.Current.Response.Write(html);
        }
Beispiel #37
0
        /// <summary>
        /// 退款接口,可重复提交得到状态
        /// </summary>
        /// <param name="order"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public override bool RefundOrder(PayHistory order, out string message)
        {
            #region 退款
            RequestHandler reqHandler = new RequestHandler(HttpContext.Current);

            //通信对象
            TenpayHttpClient httpClient = new TenpayHttpClient();
            ClientResponseHandler resHandler = new ClientResponseHandler();
            //-----------------------------
            //设置请求参数
            //-----------------------------
            reqHandler.init();
            reqHandler.setKey(key);
            reqHandler.setGateUrl("https://mch.tenpay.com/refundapi/gateway/refund.xml");

            reqHandler.setParameter("partner", bargainor_id);
            //out_trade_no和transaction_id至少一个必填,同时存在时transaction_id优先
            //reqHandler.setParameter("out_trade_no", order.OrderId);
            reqHandler.setParameter("transaction_id", order.OrderId);
            reqHandler.setParameter("out_refund_no", order.OrderId + "C");
            reqHandler.setParameter("total_fee", (order.Amount * 100).ToString());
            reqHandler.setParameter("refund_fee", (order.Amount * 100).ToString());
            reqHandler.setParameter("op_user_id", bargainor_id);
            reqHandler.setParameter("op_user_passwd", ChargeConfig.GetConfigKey(ThisCompanyType, ChargeConfig.DataType.PayPass));
            string requestUrl = reqHandler.getRequestURL();
            //证书和证书密码
            httpClient.setCertInfo(ChargeConfig.GetConfigKey(ThisCompanyType, ChargeConfig.DataType.CertFile), bargainor_id);
            //设置请求内容
            httpClient.setReqContent(requestUrl);
            //设置超时
            httpClient.setTimeOut(10);

            string rescontent = "";
            //后台调用
            if (!httpClient.call())
            {
                message = "接口调用失败";
                return false;
            }
            //获取结果
            rescontent = httpClient.getResContent();

            resHandler.setKey(key);
            //设置结果参数
            resHandler.setContent(rescontent);
            message = resHandler.getParameter("retmsg");
            //Log("退款返回结果为:" + rescontent);
            //判断签名及结果
            if (!resHandler.isTenpaySign())
            {
                message = "返回签名验证错误";
                return false;
            }
            if (resHandler.getParameter("retcode") != "0")
            {
                return false;
            }

            //商户订单号
            string out_trade_no = resHandler.getParameter("out_trade_no");
            //财富通订单号
            string transaction_id = resHandler.getParameter("transaction_id");

            // 退款状态:
            //4,10:退款成功。
            //3,5,6:退款失败。
            //8,9,11:退款处理中。
            //1,2:未确定,需要商户原退款单号重新发起。
            //7:转入代发,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,资金回流到商户的现金帐号,需要商户人工干预,通过线下或者财富通转账的方式进行退款

            string refund_status = resHandler.getParameter("refund_status");

            if (refund_status == "4" || refund_status == "10")
            {
                string recv_user_id = resHandler.getParameter("recv_user_id");
                string reccv_user_name = resHandler.getParameter("reccv_user_name");
                //Log("退款接收人信息为:" + recv_user_id + "  " + reccv_user_name);
                BaseRefundOrder(order);
                return true;
            }
            if (refund_status == "8" || refund_status == "9" || refund_status == "11")
            {
                //todo 自动重复查询
                message = "退款处理中";
                return true;
            }
            return false;

            #endregion
        }
Beispiel #38
0
 /// <summary>
 /// WAP认证支付
 /// 首次需传入银行卡进行绑定
 /// 再次按绑定的银行卡进行支付
 /// </summary>
 /// <param name="order"></param>
 /// <param name="id_no"></param>
 /// <param name="acct_name"></param>
 /// <param name="card_no"></param>
 /// <param name="no_agree"></param>
 /// <param name="risk_item"></param>
 public void WapAuthSubmit(PayHistory order, string id_no, string acct_name, string card_no, string no_agree, string risk_item)
 {
     var request = new Message.WapAuth.PayRequest();
     request.version = PartnerConfig.VERSION;
     request.oid_partner = PartnerConfig.OID_PARTNER;
     request.user_id = order.UserId.ToString();
     request.sign_type = PartnerConfig.SIGN_TYPE;
     request.busi_partner = PartnerConfig.BUSI_PARTNER;
     request.no_order = order.OrderId;
     request.dt_order = YinTongUtil.getCurrentDateTimeStr();
     request.name_goods = "在线充值";
     request.money_order = order.Amount.ToString();
     request.notify_url = CoreHelper.CustomSetting.GetConfigKey("lianlianWapAuthNotifyUrl");
     request.url_return = CoreHelper.CustomSetting.GetConfigKey("lianlianWapAuthReturnUrl");
     request.id_type = "0";
     request.id_no = id_no;
     request.acct_name = acct_name;
     request.card_no = card_no;
     request.no_agree = no_agree;
     request.risk_item = risk_item;//风控参数
     request.SetSign();
     var data = CoreHelper.SerializeHelper.SerializerToJson(request, Encoding.UTF8);
     StringBuilder sbHtml = new StringBuilder();
     sbHtml.Append("<form id='payBillForm' action='" + request.InterFaceUrl + "' method='post'>");
     sbHtml.Append("<input name='req_data' value='" + data + "' /></form>");
     sbHtml.Append("<script>document.forms['payBillForm'].submit();</script>");
     System.Web.HttpContext.Current.Response.Write(sbHtml.ToString());
 }
Beispiel #39
0
		/// <summary>
		/// 提交支付,转向需要按具体需求重写
		/// </summary>
		/// <param name="order"></param>
		public override void Submit(PayHistory order)
		{
			BaseSubmit(order);
			string out_trade_no =order.OrderId;
			string subject = order.Desc;                           //商品名称
            string body = order.UserId.ToString();                                  //商品描述
			string price = order.Amount.ToString();                                //商品价格
            string bankType = order.BankType; //银行代码
            string token = (HttpContext.Current.Session["ali_token"] != null) ? HttpContext.Current.Session["ali_token"].ToString() : string.Empty;  // 支付宝来源用户的验证码

			//相关参数名称具体含义,可以在支付宝接口服务文档中查询到,
			//以上两个文件,通知正常都可以在notify data目录找到通知过来的日志
            string aliay_url = string.Empty;
            if (token == string.Empty)
            {
                //HttpContext.Current.Request.QueryString["is_company"] 判断企业网银支付渠道
                if (HttpContext.Current.Request.QueryString["is_company"] != null && HttpContext.Current.Request.QueryString["is_company"].ToString()!="")
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType);
                }
                else
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType);
                }
            }
            else
            {
                if (HttpContext.Current.Request.QueryString["is_company"] != null && HttpContext.Current.Request.QueryString["is_company"].ToString() != "")
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType, token);
                }
                else
                {
                    aliay_url = AliPay.CreatUrl(company_gateway, service, partner, sign_type, out_trade_no, subject, body, price, show_url, seller_email, key, return_url, _input_charset, notify_url, bankType, token);
                }
            }
            //HttpContext.Current.Response.Write(aliay_url);
            //HttpContext.Current.Response.End();
			HttpContext.Current.Response.Redirect(aliay_url);

		}
Beispiel #40
0
		/// <summary>
		/// 查询订单状态,返回是否成功
		/// </summary>
		/// <param name="order"></param>
		/// <returns></returns>
		public override bool CheckOrder(PayHistory order,out string message)
		{
            string url = AliPay.CreateQueryOrderUrl(company_gateway, "single_trade_query", partner, sign_type, order.OrderId, key, _input_charset);
			string responseTxt = CoreHelper.HttpRequest.HttpGet(url, Encoding.Default);
			try
			{
				XmlDocument doc = new XmlDocument();
				doc.LoadXml(responseTxt);
				XmlNode node = doc.SelectSingleNode("alipay/response/trade/trade_status");
				if (node == null)
				{
					message = "服务器返回:" + responseTxt;
					return false;
				}
				if (node != null)
				{
					string trade_status = node.InnerText;
					if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
					{
						if (order.Status != OrderStatus.已确认)
						{
                            Confirm(order, GetType(), order.Amount);
						}
						message = "成功";
						return true;
					}
				}
				
			}
			catch(Exception ero)
			{
				message = "出现错误:" + ero.Message;
				return false;
			}
			message = "失败";
			return false;
		}
Beispiel #41
0
        public override bool RefundOrder(PayHistory order, out string message)
        {
            message = "";
            if (string.IsNullOrEmpty(order.SpBillno))
            {
                throw new Exception("支付宝订单号为空,请检查sp_billno");
            }
            ////////////////////////////////////////////请求参数////////////////////////////////////////////

            //服务器异步通知页面路径
            string notify_url = refundNotifyUrl;
            //需http://格式的完整路径,不允许加?id=123这类自定义参数

            //退款批次号
            string batch_no = DateTime.Now.ToString("yyyyMMdd") + order.OrderId.Substring(6, order.OrderId.Length - 6) + "C";
            //必填,每进行一次即时到账批量退款,都需要提供一个批次号,必须保证唯一性

            //退款请求时间
            string refund_date = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            //必填,格式为:yyyy-MM-dd hh:mm:ss

            //退款总笔数
            string batch_num = "1";
            //必填,即参数detail_data的值中,“#”字符出现的数量加1,最大支持1000笔(即“#”字符出现的最大数量999个)

            //单笔数据集
            string detail_data = order.SpBillno + "^" + order.Amount + "^协商退款";
            //必填,格式详见“4.3 单笔数据集参数说明”
            //Log(detail_data);

            ////////////////////////////////////////////////////////////////////////////////////////////////

            //把请求参数打包成数组
            SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>();
            sParaTemp.Add("partner", partner);
            sParaTemp.Add("_input_charset", _input_charset);
            sParaTemp.Add("service", "refund_fastpay_by_platform_nopwd");
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("batch_no", batch_no);
            sParaTemp.Add("refund_date", refund_date);
            sParaTemp.Add("batch_num", batch_num);
            sParaTemp.Add("detail_data", detail_data);

            //建立请求
            string sHtmlText = AlipaySubmit.BuildRequest(sParaTemp);

            //请在这里加上商户的业务逻辑程序代码

            //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(sHtmlText);
            Log(sHtmlText);
            string status = xmlDoc.SelectSingleNode("/alipay/is_success").InnerText;
            if (status == "F")
            {
                message = "退款失败:" + xmlDoc.SelectSingleNode("/alipay/error").InnerText;
                return false;
            }
            else
            {
                if (status == "T")
                {
                    message = "退款成功";
                    BaseRefundOrder(order);
                    return true;
                }
                else if (status == "P")
                {
                    message = "退款处理中";
                    //退款通知会用及时到帐接口发过来
                    return true;
                }
                return false;
            }
        }
Beispiel #42
0
 /// <summary>
 /// 订单退款方法
 /// </summary>
 /// <param name="order"></param>
 protected internal void BaseRefundOrder(PayHistory order)
 {
     ///未确认的订单不能退款
     if (order.Status != OrderStatus.已确认)
     {
         return;
     }
     OnlinePayBusiness.Instance.RefundOrder(order);
     Log("支付订单被退款:" + order.OrderId + " amount:" + order.Amount, true);
 }
Beispiel #43
0
 public override bool RefundOrder(PayHistory order, out string message)
 {
     throw new NotImplementedException();
 }
Beispiel #44
0
        /**
         * 调用统一下单,获得下单结果
         * @return 统一下单结果
         * @失败时抛异常WxPayException
         */
        public WxPayData GetUnifiedOrderResult(PayHistory order)
        {
            //统一下单
            WxPayData data = new WxPayData();
            data.SetValue("body", "test");
            data.SetValue("attach", "test");
            data.SetValue("out_trade_no", order.OrderId);
            data.SetValue("total_fee", total_fee);
            data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));
            data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));
            data.SetValue("goods_tag", "test");
            data.SetValue("trade_type", "JSAPI");
            data.SetValue("openid", openid);

            WxPayData result = WxPayApi.UnifiedOrder(data);
            if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "")
            {
                Log.Error(this.GetType().ToString(), "UnifiedOrder response error!");
                throw new WxPayException("UnifiedOrder response error!");
            }

            unifiedOrderResult = result;
            return result;
        }
Beispiel #45
0
		/// <summary>
		/// 产生记录并URL转向
		/// </summary>
		/// <param name="order"></param>
		public abstract void Submit(PayHistory order);
Beispiel #46
0
		/// <summary>
		/// 调用接口检查支付是否成功
		/// 根据情况手动Confirm
		/// </summary>
		/// <param name="order"></param>
		public abstract bool CheckOrder(PayHistory order,out string message);
Beispiel #47
0
		/// <summary>
		/// 转向页执行此方法
		/// 这里为了实现自定义转向
		/// </summary>
		/// <param name="order"></param>
		public void Redirect(PayHistory order)
		{
			if (!string.IsNullOrEmpty(order.RedirectUrl))
			{
                HttpContext.Current.Response.Redirect(order.RedirectUrl + "?amount=" + order.Amount + "&orderId=" + order.OrderId + "&companyType=" + (int)order.CompanyType + "&ProductOrderId=" + order.ProductOrderId);
			}
		}
Beispiel #48
0
        public override bool CheckOrder(PayHistory order,out string message)
        {

            //创建请求对象
            RequestHandler reqHandler = new RequestHandler(HttpContext.Current);

            //通信对象
            TenpayHttpClient httpClient = new TenpayHttpClient();

            //应答对象
            ClientResponseHandler resHandler = new ClientResponseHandler();

            //-----------------------------
            //设置请求参数
            //-----------------------------
            reqHandler.init();
            reqHandler.setKey(key);
            reqHandler.setGateUrl("https://gw.tenpay.com/gateway/normalorderquery.xml");

            reqHandler.setParameter("partner", bargainor_id);
            //out_trade_no和transaction_id至少一个必填,同时存在时transaction_id优先
            reqHandler.setParameter("out_trade_no", order.OrderId);
            //reqHandler.setParameter("transaction_id", "1900000109201103020030626316");

            string requestUrl = reqHandler.getRequestURL();
            //设置请求内容
            httpClient.setReqContent(requestUrl);
            //设置超时
            httpClient.setTimeOut(10);

            string rescontent = "";
            //后台调用
            if (httpClient.call())
            {
                //获取结果
                rescontent = httpClient.getResContent();

                resHandler.setKey(key);
                //设置结果参数
                resHandler.setContent(rescontent);

                //判断签名及结果
                if (resHandler.isTenpaySign() && resHandler.getParameter("retcode") == "0")
                {
                    //商户订单号
                    string out_trade_no = resHandler.getParameter("out_trade_no");
                    //财富通订单号
                    string transaction_id = resHandler.getParameter("transaction_id");
                    //金额,以分为单位
                    string total_fee = resHandler.getParameter("total_fee");
                    //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
                    string discount = resHandler.getParameter("discount");
                    //支付结果
                    string trade_state = resHandler.getParameter("trade_state");

                    //支付成功
                    if (trade_state == "0")
                    {
                        if (order.Status != OrderStatus.已确认)
                        {
                            Confirm(order, GetType(), order.Amount);
                        }
                        message = "成功";
                        return true;
                    }
                }
                else
                {
                    message = "失败";
                    return false;
                }
            }
            else
            {
                message = "服务器返回:" + httpClient.getResponseCode();
                return false;
            }
            message = "失败";
            return false;
        }
Beispiel #49
0
 public override void Submit(PayHistory order)
 {
     throw new NotImplementedException();
 }
Beispiel #50
0
        public override void Submit(PayHistory order)
        {
            //初始化Service
            Service ali = new Service();
            var context = HttpContext.Current;
            var config = new Config(order);
            config.Notify_url = NotifyUrl;
            config.Call_back_url = ReturnUrl;
            //创建交易接口
            string token = ali.alipay_wap_trade_create_direct(
               config.Req_url, config.Subject, config.Out_trade_no, config.Total_fee, config.Seller_account_name, config.Notify_url,
               config.Out_user, config.Merchant_url, config.Call_back_url, config.Service_Create, config.Sec_id, config.Partner, config.Req_id, config.Format, config.V, config.Input_charset_UTF8, config.Req_url, config.Key, config.Sec_id);

            //构造,重定向URL
            string url = ali.alipay_Wap_Auth_AuthAndExecute(config.Req_url, config.Sec_id, config.Partner, config.Call_back_url, config.Format, config.V, config.Service_Auth, token, config.Input_charset_UTF8, config.Req_url, config.Key, config.Sec_id);
            //跳转收银台支付页面
            System.Web.HttpContext.Current.Response.Redirect(url);
        }
Beispiel #51
0
 public override bool RefundOrder(PayHistory order, out string message)
 {
     throw new NotImplementedException();
 }
Beispiel #52
0
 /// <summary>
 /// 退款,取消订单
 /// </summary>
 /// <param name="order"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public abstract bool RefundOrder(PayHistory order, out string message);