protected void Page_Load(object sender, EventArgs e) { PayConfig payConfig = new PayConfig(); int userID = Cookies.User.GetUserID(true); Md5Pay md5pay = new Md5Pay(); string action = RequestHelper.GetQueryString <string>("Action"); switch (action) { case "Apply": int applyID = RequestHelper.GetQueryString <int>("ApplyID"); UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRecharge(applyID, userID); md5pay.Sp_billno = userRecharge.Number; md5pay.Desc = "网上冲值:" + userRecharge.Number; md5pay.Total_fee = Convert.ToInt64(userRecharge.Money * 100); break; case "PayOrder": int orderID = RequestHelper.GetQueryString <int>("OrderID"); OrderInfo order = OrderBLL.ReadOrder(orderID, userID); md5pay.Sp_billno = order.OrderNumber; md5pay.Desc = "在线支付:" + order.OrderNumber; md5pay.Total_fee = Convert.ToInt64((order.ProductMoney - order.FavorableMoney + order.ShippingMoney + order.OtherMoney - order.Balance - order.CouponMoney) * 100); break; default: break; } md5pay.Bargainor_id = payConfig.BargainorID; //卖家商户号 md5pay.Key = payConfig.BusinessKey; //卖家商户key md5pay.Date = DateTime.Now.ToString("yyyyMMdd"); //交易日期 md5pay.Attach = "tenpay"; //交易标识 md5pay.Purchaser_id = ""; //买家帐号 md5pay.Return_url = "http://" + Request.ServerVariables["Http_Host"] + "/Plugins/Pay/TenPay/Return.aspx"; //商户回调url md5pay.Transaction_id = md5pay.Bargainor_id + md5pay.Date + md5pay.UnixStamp(); //財付通交易号,需保证此订单号每天唯一,切不能重复! // md5pay.Spbill_create_ip = Page.Request.UserHostAddress; string url = ""; if (!md5pay.GetPayUrl(out url)) { ResponseHelper.Write("创建地址失败"); } else { Response.Redirect(url); } }
protected void Page_Load(object sender, EventArgs e) { PayConfig payConfig = new PayConfig(); merchant_id.Value = payConfig.MerchantID; ///商户编号 string merchant_key = payConfig.MerchantKey; ///商户密钥 string action = RequestHelper.GetQueryString <string>("Action"); int userID = Cookies.User.GetUserID(true); switch (action) { case "Apply": int applyID = RequestHelper.GetQueryString <int>("ApplyID"); UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRecharge(applyID, userID); orderid.Value = userRecharge.Number; ///订单编号 amount.Value = userRecharge.Money.ToString(); ///订单金额 commodity_info.Value = "网上冲值:" + userRecharge.Number; ///商品信息,如果含中文请通过System.Web.HttpUtility.UrlEncode()编码 break; case "PayOrder": int orderID = RequestHelper.GetQueryString <int>("OrderID"); OrderInfo order = OrderBLL.ReadOrder(orderID, userID); orderid.Value = order.OrderNumber; ///订单编号 amount.Value = (order.ProductMoney - order.FavorableMoney + order.ShippingMoney + order.OtherMoney - order.Balance - order.CouponMoney).ToString(); ///订单金额 commodity_info.Value = "在线支付:" + order.OrderNumber; ///商品信息,如果含中文请通过System.Web.HttpUtility.UrlEncode()编码 break; default: break; } currency.Value = "1"; ///货币类型,1为人民币 isSupportDES.Value = "2"; ///是否安全校验,2为必校验,推荐 merchant_url.Value = "http://" + Request.ServerVariables["Http_Host"] + "/Plugins/Pay/BillPay/Return.aspx"; ///支付结果返回地址 pname.Value = ""; ///支付人姓名,如果含中文请通过System.Web.HttpUtility.UrlEncode()编码 merchant_param.Value = ""; ///商户私有参数 pemail.Value = ""; ///传递email到快钱网关页面 pid.Value = ""; ///代理/合作伙伴商户编号 ///生成加密串,注意顺序 String ScrtStr = "merchant_id=" + merchant_id.Value + "&orderid=" + orderid.Value + "&amount=" + amount.Value + "&merchant_url=" + merchant_url.Value + "&merchant_key=" + merchant_key; mac.Value = FormsAuthentication.HashPasswordForStoringInConfigFile(ScrtStr, "MD5"); }
protected void Page_Load(object sender, EventArgs e) { PayConfig payConfig = new PayConfig(); string out_trade_no = string.Empty; //订单号 string subject = ""; //商品名称 string body = ""; //商品描述 string price = ""; //单价 string quantity = ""; //数量 string show_url = ""; //展示地址 string logistics_fee = ""; //邮费 string action = RequestHelper.GetQueryString <string>("Action"); int userID = Cookies.User.GetUserID(true); string service = payConfig.Service; //服务参数 trade_create_by_buyer 标准双接口交易 create_direct_pay_by_user 直接付款,create_partner_trade_by_buyer 担保付款 switch (action) { case "Apply": int applyID = RequestHelper.GetQueryString <int>("ApplyID"); UserRechargeInfo userRecharge = UserRechargeBLL.ReadUserRecharge(applyID, userID); out_trade_no = userRecharge.Number; subject = "在线冲值:" + userRecharge.Number; body = "在线冲值"; price = userRecharge.Money.ToString(); quantity = "1"; show_url = "http://" + Request.ServerVariables["Http_Host"]; logistics_fee = "0"; break; case "PayOrder": int orderID = RequestHelper.GetQueryString <int>("OrderID"); OrderInfo order = OrderBLL.ReadOrder(orderID, userID); out_trade_no = order.OrderNumber; subject = "在线支付:" + order.OrderNumber; body = "在线支付"; price = (order.ProductMoney - order.FavorableMoney + order.ShippingMoney + order.OtherMoney - order.Balance - order.CouponMoney).ToString(); quantity = "1"; show_url = "http://" + Request.ServerVariables["Http_Host"]; logistics_fee = "0"; break; default: break; } string gateway = "https://www.alipay.com/cooperate/gateway.do?"; //'支付接口 string partner = payConfig.Partner; // 合作伙伴ID string sign_type = "MD5"; //加密协议 string payment_type = "1"; //支付类型 string seller_email = payConfig.SellerEmail; //卖家账号 string key = payConfig.SecurityKey; //partner账户的支付宝安全校验码 string return_url = "http://" + Request.ServerVariables["Http_Host"] + "/Plugins/Pay/AliPay/Return.aspx"; //服务器返回接口 string notify_url = "http://" + Request.ServerVariables["Http_Host"] + "/Plugins/Pay/AliPay/Notify.aspx"; //服务器通知接口 string _input_charset = "utf-8"; string logistics_type = "POST"; string logistics_payment = "BUYER_PAY"; AliPay ap = new AliPay(); string aliay_url = ap.CreatUrl( gateway, service, partner, sign_type, out_trade_no, subject, body, payment_type, price, show_url, seller_email, key, return_url, _input_charset, notify_url, logistics_type, logistics_fee, logistics_payment, quantity ); Response.Redirect(aliay_url); }