protected void Page_Load(object sender, EventArgs e) { var orderNo = Request.QueryString["orderNo"]; var userAddressId = Request.QueryString["userAddressId"]; if (string.IsNullOrWhiteSpace(orderNo)) { Response.Write("请求错误"); Response.End(); return; } if (string.IsNullOrWhiteSpace(userAddressId)) { Response.Write("请选择收货地址"); Response.End(); return; } _database = new Database("ecard"); using (_databaseInstance = new DatabaseInstance(_database)) { var address = _databaseInstance.Query <Order>("select * from fz_UserAddress where userAddressId=@userAddressId", new { userAddressId = userAddressId }).FirstOrDefault(); if (address == null) { Response.Write("收货地址不存在,请重新付款"); Response.End(); return; } var order = _databaseInstance.Query <Order>("select * from fz_Orders where orderNo=@orderNo", new { orderNo = orderNo }).FirstOrDefault(); if (order == null) { Response.Write("订单不存在"); Response.End(); return; } if (order.orderState != OrderStates.awaitPay) { Response.Write("订单不是待付款状态"); Response.End(); return; } order.payAmount = order.amount + order.freight; order.detailedAddress = address.detailedAddress; order.moblie = address.moblie; order.recipients = address.recipients; order.UserAddressId = address.UserAddressId; if (_databaseInstance.Update(order, "fz_Orders") <= 0) { Response.Write("付款失败"); Response.End(); return; } IAopClient client = new DefaultAopClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.APP_PRIVATE_KEY, "json", "1.0", "RSA", AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, false); AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); request.SetReturnUrl("http://wx.fislive.com/WeChatViews/i.html"); request.SetNotifyUrl("http://wx.fislive.com/NotifyUrl/AlipayNotifyUrl.aspx"); request.BizContent = "{" + " \"body\":\"菲爱仕商城\"," + " \"subject\":\"菲爱仕商城\"," + " \"out_trade_no\":\"" + orderNo + "\"," + " \"timeout_express\":\"90m\"," + " \"total_amount\":" + order.payAmount + "," + " \"product_code\":\"QUICK_WAP_WAY\"" + " }"; AlipayTradeWapPayResponse response = client.pageExecute(request); string form = response.Body; WxPayAPI.Log.Info("支付宝请求参数:", form); Response.Write(form); } //IAopClient client = new DefaultAopClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.APP_PRIVATE_KEY, "json", "1.0", "RSA", AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, false); //////实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称如:alipay.trade.app.pay //AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); ////SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 //AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); ////model.m //model.Body = "我是测试数据"; //model.Subject = "App支付测试DoNet"; //model.TotalAmount = "0.01"; //model.ProductCode = "QUICK_WAP_PAY"; //model.OutTradeNo = "sadfa" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); //// model.TimeoutExpress = "30m"; //request.SetBizModel(model); //request.SetNotifyUrl(AlipayConfig.NOTIFY_URL); ////这里和普通的接口调用不同,使用的是sdkExecute //string from = client.pageExecute(request).Body; ////AlipayTradeAppPayResponse response = client.SdkExecute(request); //Response.AddHeader("content-type", "text/html"); //Response.AddHeader("charset","UTF-8"); //Response.Write(from); }
public ActionResult ajaxorder(OrdersEntity ordersEntity) { try { string city = ordersEntity.City; if (city.Contains("-")) { string[] area = ordersEntity.City.Split('-'); if (area.Length > 0) { ordersEntity.Province = area[0]; //省 ordersEntity.City = area[1]; //市 ordersEntity.Country = area[2]; //市 } } else { string[] area = ordersEntity.City.Split(' '); if (area.Length > 0) { ordersEntity.Province = area[0]; //省 ordersEntity.City = area[1]; //市 } } string payType = ordersEntity.PayType; if (payType == "alipay") { payType = "支付宝"; } else { if (ordersEntity.PC == 1) { payType = "微信扫码"; } else { payType = "微信H5"; } } ordersEntity.PayType = payType; ordersEntity = ordersbll.SaveForm(ordersEntity); var sp_billno = ordersEntity.OrderSn; var nonceStr = TenPayV3Util.GetNoncestr(); //商品Id,用户自行定义 string productId = ordersEntity.TelphoneID.ToString(); H5Response root = null; if (payType == "支付宝") { try { DefaultAopClient client = new DefaultAopClient(WeixinConfig.serviceUrl, WeixinConfig.aliAppId, WeixinConfig.privateKey, "json", "1.0", WeixinConfig.signType, WeixinConfig.payKey, WeixinConfig.charset, false); // 组装业务参数model AlipayTradeWapPayModel model = new AlipayTradeWapPayModel(); model.Body = "支付宝购买靓号"; // 商品描述 model.Subject = productId; // 订单名称 model.TotalAmount = ordersEntity.Price.ToString(); // 付款金额"0.01" model.OutTradeNo = sp_billno; // 外部订单号,商户网站订单系统中唯一的订单号 model.ProductCode = "QUICK_WAP_WAY"; model.QuitUrl = "https://cfdv.digitdance.cn:8070/webapp/jntt2/Index"; // 支付中途退出返回商户网站地址 model.TimeoutExpress = "90m"; AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); //设置支付完成同步回调地址 request.SetReturnUrl(WeixinConfig.return_url); //设置支付完成异步通知接收地址 request.SetNotifyUrl(WeixinConfig.notify_url); // 将业务model载入到request request.SetBizModel(model); AlipayTradeWapPayResponse response = null; try { response = client.pageExecute(request, null, "post"); //Response.Write(response.Body); H5PayData h5PayData = new H5PayData(); h5PayData.form = response.Body; root = new H5Response { code = true, status = true, msg = "\u652f\u4ed8\u5b9d\u63d0\u4ea4\u6210\u529f\uff01", data = h5PayData }; } catch (Exception exp) { throw exp; } } catch (Exception ex) { //return Json(new { Result = false, msg = "缺少参数" }); } } else { //pc端返回二维码,否则H5 if (payType == "微信扫码") { //创建请求统一订单接口参数 var xmlDataInfo = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID2, tenPayV3Info.MchId, "扫码支付靓号", sp_billno, Convert.ToInt32(ordersEntity.Price * 100), //1, Request.UserHostAddress, tenPayV3Info.TenPayV3Notify, TenPayV3Type.NATIVE, null, tenPayV3Info.Key, nonceStr, productId: productId); //调用统一订单接口 var result = TenPayV3.Unifiedorder(xmlDataInfo); if (result.return_code == "SUCCESS") { H5PayData h5PayData = new H5PayData() { appid = WeixinConfig.AppID2, code_url = result.code_url,//weixin://wxpay/bizpayurl?pr=lixpXgt-----------扫码支付 mch_id = WeixinConfig.MchId, nonce_str = result.nonce_str, prepay_id = result.prepay_id, result_code = result.result_code, return_code = result.return_code, return_msg = result.return_msg, sign = result.sign, trade_type = "NATIVE", trade_no = sp_billno, payid = ordersEntity.Id.ToString(), wx_query_href = "https://shop.jnlxsm.net/webapp/jntt2/queryWx/" + ordersEntity.Id, wx_query_over = "https://shop.jnlxsm.net/webapp/jntt2/paymentFinish/" + ordersEntity.Id }; root = new H5Response { code = true, status = true, msg = "\u5fae\u4fe1\u626b\u7801\u63d0\u4ea4\u6210\u529f\uff01", data = h5PayData }; } else { root = new H5Response { code = false, status = false, msg = result.return_msg }; } } else { var xmlDataInfoH5 = new TenPayV3UnifiedorderRequestData(WeixinConfig.AppID2, tenPayV3Info.MchId, "H5购买靓号", sp_billno, // 1, Convert.ToInt32(ordersEntity.Price * 100), Request.UserHostAddress, tenPayV3Info.TenPayV3Notify, TenPayV3Type.MWEB /*此处无论传什么,方法内部都会强制变为MWEB*/, null, tenPayV3Info.Key, nonceStr); var resultH5 = TenPayV3.Html5Order(xmlDataInfoH5); //调用统一订单接口 LogHelper.AddLog(resultH5.ResultXml); //记录日志 if (resultH5.return_code == "SUCCESS") { H5PayData h5PayData = new H5PayData() { appid = WeixinConfig.AppID2, mweb_url = resultH5.mweb_url,//H5访问链接 mch_id = WeixinConfig.MchId, nonce_str = resultH5.nonce_str, prepay_id = resultH5.prepay_id, result_code = resultH5.result_code, return_code = resultH5.return_code, return_msg = resultH5.return_msg, sign = resultH5.sign, trade_type = "H5", trade_no = sp_billno, payid = ordersEntity.Id.ToString(), wx_query_href = "https://shop.jnlxsm.net/webapp/jntt2/queryWx/" + ordersEntity.Id, wx_query_over = "https://shop.jnlxsm.net/webapp/jntt2/paymentFinish/" + ordersEntity.Id }; root = new H5Response { code = true, status = true, msg = "\u5fae\u4fe1\u0048\u0035\u63d0\u4ea4\u6210\u529f\uff01", data = h5PayData }; } else { root = new H5Response { code = false, status = false, msg = resultH5.return_msg }; } } } LogHelper.AddLog(JsonConvert.SerializeObject(root));//记录日志 return(Content(JsonConvert.SerializeObject(root))); } catch (Exception ex) { LogHelper.AddLog(ex.Message);//记录日志 throw; } }
public ActionResult PcPay() { string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff"); IAopClient client = new DefaultAopClient(AliPayConfig.serverUrl, AliPayConfig.app_id, AliPayConfig.merchant_private_key, AliPayConfig.format, AliPayConfig.version, AliPayConfig.sginType , AliPayConfig.alipay_public_key, AliPayConfig.charset, AliPayConfig.keyFromsFile); AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); request.SetNotifyUrl("http://1x687f9296.iok.la/AliPay/Receive_notify"); request.SetReturnUrl("http://www.baidu.com"); //----------------- //AlipayTradePayModel model = new AlipayTradePayModel(); //model.OutTradeNo = out_trade_no; //model.ProductCode = "FAST_INSTANT_TRADE_PAY"; //model.TotalAmount = "8.88"; //model.Subject = "zhifu"; //model.Body = "zhifu"; //request.SetBizModel(model); ///------------ // request.BizContent = "{" + //" \"out_trade_no\":\"" + out_trade_no + "\"," + //" \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," + //" \"total_amount\":88.88," + //" \"subject\":\"Iphone616G\"," + //" \"body\":\"Iphone616G\"," + //" }";//填充业务参数 //request.BizContent = "{" + // "\"out_trade_no\":\"" + out_trade_no + "\"," + // "\"scene\":\"bar_code\"," + // "\"auth_code\":\"28763443825664394\"," + // "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +// FACE_TO_FACE_PAYMENT // "\"subject\":\"Iphone616G\"," + // "\"buyer_id\":\"2088202954065786\"," + // "\"seller_id\":\"2088102146225135\"," + // "\"total_amount\":88.88," + // "\"discountable_amount\":8.88," + // "\"body\":\"Iphone616G\"," + // "\"goods_detail\":[{" + // "\"goods_id\":\"apple-01\"," + // "\"goods_name\":\"ipad\"," + // "\"quantity\":1," + // "\"price\":2000," + // "\"goods_category\":\"34543238\"," + // "\"body\":\"特价手机\"," + // "\"show_url\":\"http://www.alipay.com/xxx.jpg\"" + // "}]," + // "\"operator_id\":\"yx_001\"," + // "\"store_id\":\"NJ_001\"," + // "\"terminal_id\":\"NJ_T_001\"," + // "\"extend_params\":{" + // "\"sys_service_provider_id\":\"2088511833207846\"" + // "}," + // "\"timeout_express\":\"90m\"" + // "}"; request.BizContent = "{" + " \"body\":\"Iphone6 16G\"," + " \"subject\":\"Iphone6 16G\"," + " \"out_trade_no\":\"" + out_trade_no + "\"," + " \"total_amount\":88.88," + " \"product_code\":\"FAST_INSTANT_TRADE_PAY\"" + " }"; AlipayTradePagePayResponse response = client.pageExecute(request); return(Content(response.Body)); }
protected void Button1_Click(object sender, EventArgs e) { int userid = int.Parse(Session["UserID"].ToString()); float goodprice = float.Parse(this.Label2.Text); float carriageprice = float.Parse(this.DropDownList1.SelectedValue.ToString()); float totalprice = goodprice + carriageprice; string receivername = this.TextBox4.Text.Trim(); string receiverphone = this.TextBox5.Text.Trim(); string receiveremail = this.TextBox6.Text.Trim(); string receiveraddress = this.TextBox7.Text.Trim(); string remark = this.TextBox8.Text.Trim(); string generatetime = DateTime.Now.ToString(); string sql = "insert into [Order] values('" + userid + "','" + goodprice + "','" + carriageprice + "','" + totalprice + "','" + receivername + "','" + receiveraddress + "','" + receiverphone + "','" + receiveremail + "','待付款','" + generatetime + "',null,null,'" + remark + "') select SCOPE_IDENTITY() as 'OrderID'"; SqlDataReader dr = db.redr(sql); string orderid = null; if (dr.HasRows) { while (dr.Read()) { orderid = dr["OrderID"].ToString(); } } else { Response.Write("<script>alert('订单创建失败')</script>"); } int goodid; int goodnum; float singleprice; float allprice; foreach (GridViewRow gridViewRow in this.GridView1.Rows) { goodid = int.Parse(gridViewRow.Cells[1].Text); goodnum = int.Parse(gridViewRow.Cells[3].Text); singleprice = float.Parse(gridViewRow.Cells[4].Text); allprice = float.Parse(gridViewRow.Cells[5].Text); sql = "insert into OrderDetail values('" + goodid + "','" + goodnum + "','" + singleprice + "','" + allprice + "','" + orderid + "')"; if (!db.exsql(sql)) { Response.Write("<script>alert('订单创建失败')</script>"); } } Session["ShoppingCart"] = null; Response.Write("<script>alert('下单成功,请尽快支付')</script>"); DefaultAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false); // 外部订单号,商户网站订单系统中唯一的订单号 string out_trade_no = orderid.ToString(); // 订单名称 string subject = "安徽大学校园物品交易系统结算中心"; // 付款金额 string total_amout = totalprice.ToString(); // 商品描述 string body = "test"; // 组装业务参数model AlipayTradePagePayModel model = new AlipayTradePagePayModel(); model.Body = body; model.Subject = subject; model.TotalAmount = total_amout; model.OutTradeNo = out_trade_no; model.ProductCode = "FAST_INSTANT_TRADE_PAY"; AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); // 设置同步回调地址 request.SetReturnUrl(config.nataddress + "/Return_url.aspx"); // 设置异步通知接收地址 request.SetNotifyUrl(config.nataddress + "/Notify_url.aspx"); // 将业务model载入到request request.SetBizModel(model); AlipayTradePagePayResponse response = null; try { response = client.pageExecute(request, null, "post"); Response.Write(response.Body); } catch (Exception exp) { throw exp; } }
public string ChargeByAlipayPc(string productName, decimal amount, string orderNo, string returnUrl) { var config = ConfigInfo; if (!config.IsAlipayPc) { return(null); } if (config.AlipayPcIsMApi) { // 合作身份者ID,签约账号,以2088开头由16位纯数字组成的字符串,查看地址:https://b.alipay.com/order/pidAndKey.htm Third.Alipay.MApi.Pc.Config.partner = config.AlipayPcPid; // 收款支付宝账号,以2088开头由16位纯数字组成的字符串,一般情况下收款账号就是签约账号 Third.Alipay.MApi.Pc.Config.seller_id = Third.Alipay.MApi.Pc.Config.partner; // MD5密钥,安全检验码,由数字和字母组成的32位字符串,查看地址:https://b.alipay.com/order/pidAndKey.htm Third.Alipay.MApi.Pc.Config.key = config.AlipayPcMd5; // 服务器异步通知页面路径,需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问 Third.Alipay.MApi.Pc.Config.notify_url = string.Empty; // 页面跳转同步通知页面路径,需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问 Third.Alipay.MApi.Pc.Config.return_url = returnUrl; // 字符编码格式 目前支持 gbk 或 utf-8 Third.Alipay.MApi.Pc.Config.input_charset = "utf-8"; // 支付类型 ,无需修改 Third.Alipay.MApi.Pc.Config.payment_type = "1"; // 调用的接口名,无需修改 Third.Alipay.MApi.Pc.Config.service = "create_direct_pay_by_user"; //////////////////////////////////////////////////////////////////////////////////////////////// //把请求参数打包成数组 var sParaTemp = new SortedDictionary <string, string> { { "service", Third.Alipay.MApi.Pc.Config.service }, { "partner", Third.Alipay.MApi.Pc.Config.partner }, { "seller_id", Third.Alipay.MApi.Pc.Config.seller_id }, { "_input_charset", Third.Alipay.MApi.Pc.Config.input_charset.ToLower() }, { "payment_type", Third.Alipay.MApi.Pc.Config.payment_type }, { "notify_url", Third.Alipay.MApi.Pc.Config.notify_url }, { "return_url", Third.Alipay.MApi.Pc.Config.return_url }, { "anti_phishing_key", Third.Alipay.MApi.Pc.Config.anti_phishing_key }, { "exter_invoke_ip", Third.Alipay.MApi.Pc.Config.exter_invoke_ip }, { "out_trade_no", orderNo }, { "subject", productName }, { "total_fee", amount.ToString("N2") }, { "body", string.Empty } }; //商户订单号,商户网站订单系统中唯一订单号,必填 //其他业务参数根据在线开发文档,添加参数.文档地址:https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.O9yorI&treeId=62&articleId=103740&docType=1 //如sParaTemp.Add("参数名","参数值"); //建立请求 return(Third.Alipay.MApi.Pc.Submit.BuildRequest(sParaTemp, "get", "确认")); } var client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", config.AlipayMobiAppId, config.AlipayMobiPrivateKey, "JSON", "1.0", "RSA2", config.AlipayMobiPublicKey, "utf-8", false); // 组装业务参数model var model = new AlipayTradePagePayModel { Body = string.Empty, Subject = productName, TotalAmount = amount.ToString("N2"), OutTradeNo = orderNo, TimeoutExpress = "90m", ProductCode = "FAST_INSTANT_TRADE_PAY" }; // 付款金额 // 外部订单号,商户网站订单系统中唯一的订单号 var request = new AlipayTradePagePayRequest(); // 设置同步回调地址 request.SetReturnUrl(returnUrl); // 设置异步通知接收地址 request.SetNotifyUrl(string.Empty); // 将业务model载入到request request.SetBizModel(model); var response = client.pageExecute(request); return(response.Body); }
/// <summary> /// Post process payment (used by payment gateways that require redirecting to a third-party URL) /// </summary> /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param> public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest) { //RemotePost DefaultAopClient client = new DefaultAopClient(_aliPayPaymentSettings.GatewayUrl, _aliPayPaymentSettings.AppID, _aliPayPaymentSettings.PrivateKey, "json", "1.0", _aliPayPaymentSettings.SignType, _aliPayPaymentSettings.AlipayPublicKey, "UTF-8", false); // 外部订单号,商户网站订单系统中唯一的订单号 string out_trade_no = postProcessPaymentRequest.Order.Id.ToString(); // 订单名称 string subject = _storeContext.CurrentStore.Name; //订单原始价格按主货币, var CNY = _currencyService.GetCurrencyByCode("CNY"); var primaryExchangeCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryExchangeRateCurrencyId); if (primaryExchangeCurrency == null) { throw new NopException("Primary exchange rate currency is not set"); } // 付款金额 ,换算成 人民币 decimal cur_total = postProcessPaymentRequest.Order.OrderTotal; cur_total = cur_total / primaryExchangeCurrency.Rate * CNY.Rate; string total_amout = cur_total.ToString("0.00", CultureInfo.InvariantCulture); // 商品描述 string body = "Order from " + _storeContext.CurrentStore.Name; AopResponse response = null; string s = _httpContext.Request.UserAgent; Regex b = new Regex(@"android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline); Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (!(b.IsMatch(s) || v.IsMatch(s.Substring(0, 4)))) { AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); // 设置同步回调地址 request.SetReturnUrl(_webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Return"); // 设置异步通知接收地址 request.SetNotifyUrl(_webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Notify"); // 将业务model载入到request request.SetBizModel(new AlipayTradePagePayModel() { Body = body, Subject = subject, TotalAmount = total_amout, OutTradeNo = out_trade_no, GoodsType = "0", TimeoutExpress = "15m", ProductCode = "FAST_INSTANT_TRADE_PAY" }); try { response = client.pageExecute(request, null, "post"); } catch (Exception exp) { _logger.Warning($"{DateTime.Now.ToString()}Ali Page PayError:{exp.Message}"); } } else { AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); // 设置同步回调地址 request.SetReturnUrl(_webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Return"); // 设置异步通知接收地址 request.SetNotifyUrl(_webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Notify"); // 将业务model载入到request request.SetBizModel(new AlipayTradeWapPayModel() { Body = body, Subject = subject, TotalAmount = total_amout, OutTradeNo = out_trade_no, GoodsType = "0", TimeoutExpress = "15m", ProductCode = "FAST_INSTANT_TRADE_PAY" }); try { response = client.pageExecute(request, null, "post"); } catch (Exception exp) { _logger.Warning($"{DateTime.Now.ToString()}Ali Wap PayError:{exp.Message}"); } } _httpContext.Response.Clear(); _httpContext.Response.Write("<html><head><meta http-equiv=\"Content - Type\" content=\"text / html; charset = utf - 8\"/></head><body style=\"display:none\">"); _httpContext.Response.Write(response.Body); _httpContext.Response.Write("</body></html>"); _httpContext.Response.End(); }