public ActionResult GetFileTest() { IAopClient client = new DefaultAopClient("https://openapi.alipaydev.com/gateway.do", "2016101300673467", "MIIEogIBAAKCAQEAgV46jh5KmqbMbOFuFBQxnN6f0OngDpSr+Jkphwd7L6zC7N4yB0vF3EoLj/ahrgCEwTFy6oJz+tRif0hlt41KSMJCgJhiM/axrzyzDL7kGF0/ISwy5fZec8n5TGoS5cwNQ5koPO+ZsqGWd8rB7xIgpZ12APCwghUT1yDvxrAUEj78KBUhZfZTxRPZI5coat/fnVkC0EUR1DNzRjps3mDjleLb4g9fRgAxr/y8aUViOcnDZajZyA9RqZtRPWJOk80+rDGXV2/Z7r0EFokDe448PiV0bOK4Ggmmz+ADAsOvrZoGVUcfqo+1jr0KLOOSKdp9Bs6ft84tO3QMGMgFOqH8vwIDAQABAoIBABWd8DzlNOQosQoUlTdHtI6Y6K2ZFvZ4w0+0ECtfBaeOv7ei3Us4zyQjP1FcDeIsdgJuR9yF1el46ciJCW4lbt8/jqs8S1SRiVlV1DlyAF1N34mkgBDLHTdN7ZlmNCgv85tzETU1eEJQG/uCZuuS5N+nsxsvHN9vtDQDbe2OaJwvqmgxjqHvCLbP9v9U41aGyCveYFmnfEM/+2xufRMt9BzpE867ujmFOKyfqRj8fRHER2dlAGpLz9G2gOL5Eo0ve8KVxfFU3U93HRMCp6Yso0haM7nE0aNgYgl+gWMK+WdPOe/6f5MLVRyn9ePJWt2BIeEq2moZuuosE7B/QDID4PkCgYEA2Hqw4QU6/Z/u4Wl7cwgkdBTtZyGpXwCwjsnrFBqKHlJUowyl9HRqG1o7mqbGhS3iOc2UHA+BhNpRxYy0nl4vQUYzWWfkhq/PvYnuD2TzB3ybGd04iu/mY8hzM9VlsT4ojA3uL3QkO6I1pkLh9OyFglctvIs8KDJo4TP7a5T/6UUCgYEAmPxWCttT7O3vjlZQqjOr854l5Kn1xYKxF8PGaqfzHq79vHkhfNYiY/8cqKcJlJh8F+uG5Q6lRIiihwDuo+45MKmKL9ZHQpgBk9SKztpbflK/BR6UAXH/aloMr7j3IBFoJP7AiBpMtWsW6VTtJOwS9DoehkCN4bEZniDVF9o6tDMCgYBxA6xv7TEc02/8kfr21NtjFsHRw4sOo+eIw/VL64cLyWOSM7o34sa6POM9G7AsOwYNszuNYrL1Tpy+C3UH8Jeu9h08obZ2cjZ79xQnSUZvNCgs2ob4UcHveehauR975r14UJV2hKWd1FM511TrbsdMgoLIGdBwE9EZMPAi/AiWGQKBgHyNE9AK+KzwmhQcGdg38UqJ+vfLl5iR6nQao7O5wKm+dj23sJfeDmmzDTYRqC8eZglja5OY9NxzET8wdxlnnZAMt8Byh9mjv8UHSWtXQx35aCNW3dC/at6/KYz23dtx0IQuE7m7D7Cz2xdkWR2yRUwo9Sj/7YNNmDmxKUweE6UZAoGAPAkO10ddoGpNZ1VsIQPfYx/zn9UpIvax9HDkMYkAxMQdmG3h/yLH3x4c6QkytQE2VcLafQRAKc9il9WlgzUoOrzvO3W95XIck5dq16Re5ZZJCzc4jYnUmJ79AG0gJ3GDRBRWFpp/AxJWlMx7nMyNchj9kGQghgdVehWdV/eHmGM=", "json", "1.0", "RSA2", "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4PO7TRZraDCfHVc+xh6xO3pqthcju3GEd/V0bI+v+GU7BWjdNfQhZmqgCVmGFERf8CQFtX5IQk1+FlH3kwimwyl/TM0R+GwJxl8mIkBn6OSCR+WLMfhiYR9J/vCmUlzur9ByB2VuQk/QWAKFMsVUwhUaWNPWxCEN4nBlmgiss8vDgm+npNBfUJoiT/d/0SW2/jJEzFNWjT0P+MB/BKFCXHlW+2eU12uUZHblZ2yw0pDVnP6jUVd5Y4wrtb4TKrLWxgnCaiki4AsuD9AjTMD4kQ33+Dln9JYCyEyhLRDLWldJs9dw+arL95IkUzvfhAf1CWZo0TYBwlBUom6wmzFbewIDAQAB", "GBK", false); //"2019082766434970", // "MIIEpQIBAAKCAQEAsdm9hrmwgGt3FsiUFDr4wZMWMxLXt5mvJUNBMJacYyxbkCkXu+PNk+1ItN6EFdbIjoqLRlKXT4nGZmcSs7RhbWlDSG4Qd/PaAVZmtjEKiNEwCBIoQ2LyhCGuD5c6bA2K1e/HkgEhXnHPDlCJXf0BrkavPaOHYxG3iCQEXRDxGfDjaK3DSu1vPLEqxsMqPDieTDc81pXGQZeH7cW5iGIo4gX0ac+Bmc9vRz5uUbsfkitTvyx49tO9ROGp5XhlrmqMuslFbYpvx8KNcCr+eVVcaHPOpUXRCHXECBpF+jD0ZvMRg5f43dTaOiXtSdMayfeV2BVSN5vkPYUoNPp8amoVFQIDAQABAoIBAATWrrBWpvWndtL43AZ84D2r+cOj9Jh7Jue1n7Vps5GDKG6Qn6Ot++7VWtAI6cEKWeR+4nEkWBeC4RHyJfEbrDbk0T7MN8h7que0aRD13pqATnU5wTysGXr8y5aC/8TmzWsqndxcCYNfR0nVaRdUhdIu/B+KLmnElqCukivSBS02c9o39nNY2WsxTVabKUaoso7IBmM8dFdEBY7AjlEJQfPBUQldTllm8uRXcKItaHh7/WYQ4MeAf1612eao5LKVR9N+XkDEIz+wys48W58bT/McruvIPjLI3S6MLG6loo34czH7YDbLLtarAUaPGs6YFTRXE2s0+eNrCWHRRrMdmAECgYEA7tmsESQwaEOhu4xPYK4qYqVFVSV8Ve2NP6hvr9fQBlgilshBpVwR0MX41TlFG76qdkBSStky333AoNIf2OzjpZNBA0rAVfnHY3tqJwzeJfsOYUmniY6nepBdorgh94b8DdaeurEre7vwqvFMTBGwmDsR4oIOidY49UiSQ8d+ggECgYEAvp7Tp6ApmyO+PI7yujfE1VsNTeHLiVnf87xYnMW87EOjyl2XqiycspBxiVtcy7PZnQVYaFqcAMf1cYb0ti6BiCNXMOMg0eWFpUknYHllsB7pXu7n8Aheu0QkKRlFzkTBlFcs5yRG7V/vfP0DPL53jI54xj8LHS69FIF9ikazaxUCgYEA7hpogZ4F86qYLBKvfr2g2z3OZBc+X5q0WGVdEXqekfSCZrWzW1jxGaKBcG3rCsGDxOZSIvNq14jQ4oEV5nYgagrloJaALjUWI4IATHVzb4Fa0HlQXryrEG+iKHhOxCb4VgNBsPK1Wl/8hyyM1rg7x0X7ikYEoDvCBCMYTCEvaAECgYEAsaCzPoqi+qxOA4R5b0m0o9RbC24TCoSzih7CvCQPLmLBaDvarnsv8b1j70kxqaiIaienAGce5CNw9j96HaIslj3IbAfad31YEnOeu+mj9oB3mz0o6KYEEKEoyRuBzvqHIMIzV5iYd25kbqYetCYQpOvGY4YvxxvcmhUodQf4/RkCgYEA2SM3mgOz+jaBs96JVtTeLeEFIaKmnceD8u+wuuVfulY2aDDkEwYPfHXBqu4EqZjpcDg2l2EBsLRy7Ot7K2EaGJV0s7H1AP/13kziKCl9WwDoDg4Dk7ZRzj378YFehX4b9T3SQ36WMkgFHB9zOcRP5Rf7HO4inN6UqILHSTuTOY4=", // "json", // "1.0", 2088631146114221 // "RSA2", // "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA05z4aIvz0V9DyE/YS72CuCVbb9ncn5EJHGijdQ+qokDXR1e0SNIbZeitNKUL1bfqapjYIDIPON49VHtPFBWz2osSITsv9+lIQUhb/nBvTAhLL2Yebx6/NPC3a+meqm5e53Fu8W6WYvpQGI7zcGMiJaDs19xZHyTGJf0dTVn7+r2/XWA37801W8rADnikIyKm4gu1AiWWtpuVy+bimc6fcFq5dHOnHGlcK+kx+Bm4yRN3aDE8kG2EszLV850KaZwvHlUGdiW3mVixpfbQJV8ei2n0HIwLVGVvt1hjwNGgvrNAuBBc2ACAkk45gg77+pTiHR1XzxyjiXEelGUfFN09wQIDAQAB", // "GBK", false); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); request.BizContent = "{" + "\"out_trade_no\":\"201523423420101001\"," + "\"seller_id\":\"2088102179325219\"," + "\"total_amount\":0.1," + "\"subject\":\"Iphone6 16G\"," + "\"timeout_express\":\"90m\"," + "\"qr_code_timeout_express\":\"90m\"" + " }"; AlipayTradePrecreateResponse response = client.Execute(request); ViewBag.Src = response.QrCode; return(File(QrCodeHelper.GenQrCode(response.QrCode, 200).ToArray(), @"image/jpeg")); }
public AlipayTradePrecreateResponse BuildNew(EAliPayApplication app, EStoreInfo store, EUserInfo AgentUI, string TotalAmt, bool needNotifyUrl = true, bool needControl = true) { string NotifyUrl = ConfigurationManager.AppSettings["Main_SiteUrl"] + "AliPay/PayNotify"; _OrderNo = StringHelper.GenerateOrderNo(); IAopClient aliyapClient = new DefaultAopClient("https://openapi.alipay.com/gateway.do", app.AppId, app.Merchant_Private_Key, "json", "1.0", "RSA2", app.Merchant_Public_key, "GBK", false); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); AlipayTradePrecreateModel model = new AlipayTradePrecreateModel(); model.SellerId = store.AliPayAccount; NLogHelper.InfoTxt("当面付OrderNo:" + _OrderNo); model.OutTradeNo = _OrderNo; model.TotalAmount = TotalAmt; model.Subject = "#" + AgentUI.Name + " 收银台"; model.Body = app.AppName + "-商品"; model.ExtendParams = new Aop.Api.Domain.ExtendParams(); model.ExtendParams.SysServiceProviderId = app.AppId; if (needControl) { model.DisablePayChannels = "balance,moneyFund,creditCard,creditCardExpress,creditCardCartoon,debitCardExpress,point,bankPay"; } request.SetBizModel(model); if (needNotifyUrl) { request.SetNotifyUrl(NotifyUrl); } AlipayTradePrecreateResponse response = aliyapClient.Execute(request, null, store.AliPayAuthToke); return(response); }
/// <summary> /// 获取扫码支付的二维码图片链接 /// </summary> /// <param name="orderNo">商户订单号,64个字符以内、只能包含字母、数字、下划线;需保证在商户端不重复</param> /// <param name="amount">订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000] 如果同时传入了【打折金额】,【不可打折金额】,【订单总金额】三者,则必须满足如下条件:【订单总金额】=【打折金额】+【不可打折金额】</param> /// <param name="subject">订单标题</param> /// <param name="body">商品描述信息</param> /// <param name="storeId">商户门店编号</param> /// <returns></returns> public string GetQrCodeUrl(string orderNo, decimal amount, string subject, string body, string storeId) { string link = string.Empty; //组装业务参数 var model = new AlipayTradePrecreateModel() { Body = body, Subject = subject, TotalAmount = amount.ToString(), OutTradeNo = orderNo, StoreId = storeId //商户门店编号 }; var request = new AlipayTradePrecreateRequest(); request.SetBizModel(model); request.SetNotifyUrl(NotifyUrl); AlipayTradePrecreateResponse response = aopClient.Execute(request); if (response != null && response.Code == "10000") { link = response.QrCode; } return(link); }
/// <summary> /// 获取扫码支付的二维码图片链接(将链接用二维码工具生成二维码打印出来,顾客可以用支付宝钱包扫码支付) /// </summary> public string GetQrCodePayLink(decimal amount, string orderNo, string subject, string body, string storeId, string operatorId) { string link = string.Empty; //组装业务参数 var model = new AlipayTradePrecreateModel() { Body = body, Subject = subject, TotalAmount = amount.ToString(), OutTradeNo = orderNo, StoreId = storeId, //商户门店编号 OperatorId = operatorId }; var request = new AlipayTradePrecreateRequest(); request.SetBizModel(model); //不推荐使用异步通知,避免单边账问题发生。推荐使用轮询撤销机制 //对所有唤起收银台的交易(支付宝返回状态10003(等待用户支付))发起轮询,并且建议轮询总时间设为30秒,轮询平均间隔设为3秒。在让用户再次支付前,必须通过查询确认当前订单的状态。 //request.SetNotifyUrl(NotifyUrl); AlipayTradePrecreateResponse response = aopClient.Execute(request); if (response != null && response.Code == "10000") { link = response.QrCode; } //记日志response.ToJson(); return(link); }
/// <summary> /// 预下单请求 /// </summary> /// <returns></returns> public static PrecreateResponseModel Prepay(PrecreateModel precreateModel) { AlipayTradePrecreateRequest payRequst = new AlipayTradePrecreateRequest(); if (precreateModel.extend_params == null) { precreateModel.extend_params = new ExtendParams(); } precreateModel.extend_params.sys_service_provider_id = Config.providerid; payRequst.BizContent = JsonConvert.SerializeObject(precreateModel); LogUtil.WriteAlipayLog("预下单请求", "请求参数", payRequst.BizContent); //需要异步通知的时候,需要是指接收异步通知的地址。 payRequst.SetNotifyUrl("http://10.5.21.14/notify_url.aspx"); Dictionary <string, string> paramsDict = (Dictionary <string, string>)payRequst.GetParameters(); AlipayTradePrecreateResponse payResponse = _client.Execute(payRequst); LogUtil.WriteAlipayLog("预下单响应", "响应原始参数", payResponse.Body); return(new PrecreateResponseModel { code = payResponse.Code, msg = payResponse.Msg, subcode = payResponse.SubCode, submsg = payResponse.SubMsg, out_trade_no = payResponse.OutTradeNo, qr_code = payResponse.QrCode }); }
public static string MakePreAliPayOrder(string companyId, PreAliPayOrderModel model) { try { AliPayApiConfig config = AliPayApiConfigServices.QueryAliPayConfig(companyId); if (config == null) { throw new MyException("获取支付宝配置失败"); } string aliPayNotifyUrl = string.Format("{0}/AliPayNotify", config.SystemDomain); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); request.BizContent = JsonHelper.GetJsonString(model); request.SetNotifyUrl(aliPayNotifyUrl); AlipayTradePrecreateResponse response = GetDefaultAopClient(companyId).Execute(request); if (response.IsError) { TxtLogServices.WriteTxtLogEx("AliPayApiServices", string.Format("预下单失败:{0}", response.Body)); return(""); } return(response.QrCode); } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("AliPayApiServices", string.Format("预下单失败:{0}", ex.Message)); } return(""); }
public AlipayTradePrecreateResponse BuildPartyPay(EAliPayApplication app, EStoreInfo store, EUserInfo AgentUI, string TotalAmt, bool needNotifyUrl = true) { string NotifyUrl = ConfigurationManager.AppSettings["Main_SiteUrl"] + "AliPay/PayNotify"; _OrderNo = StringHelper.GenerateOrderNo(); IAopClient aliyapClient = new DefaultAopClient("https://openapi.alipay.com/gateway.do", app.AppId, app.Merchant_Private_Key, "json", "1.0", "RSA2", app.Merchant_Public_key, "GBK", false); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); AlipayTradePrecreateModel model = new AlipayTradePrecreateModel(); model.SellerId = store.AliPayAccount; model.OutTradeNo = _OrderNo; model.TotalAmount = TotalAmt; model.Subject = "#" + AgentUI.Name + " 收银台"; model.Body = app.AppName + "-商品"; model.ExtendParams.HbFqNum = "3"; model.ExtendParams.HbFqSellerPercent = "0"; request.SetBizModel(model); if (needNotifyUrl) { request.SetNotifyUrl(NotifyUrl); } AlipayTradePrecreateResponse response = aliyapClient.Execute(request, null, store.AliPayAuthToke); return(response); }
public async Task <IActionResult> PreCreate(AlipayTradePreCreateViewModel viewModel) { if (_Interceptor != null) { return(Ok("this is _Interceptor")); } var model = new AlipayTradePrecreateModel { OutTradeNo = viewModel.OutTradeNo, Subject = viewModel.Subject, TotalAmount = viewModel.TotalAmount, Body = viewModel.Body }; var req = new AlipayTradePrecreateRequest(); req.SetBizModel(model); req.SetNotifyUrl(viewModel.NotifyUrl); //var response = await _client.CertificateExecuteAsync(req, _optionsAccessor.Value); var response = await _client.ExecuteAsync(req, _optionsAccessor.Value); ViewData["qrcode"] = response.QrCode; ViewData["response"] = response.Body; return(View()); }
public async Task <IActionResult> PreCreate(string out_trade_no, string subject, string total_amount, string body, string notify_url = "") { var model = new AlipayTradePrecreateModel { OutTradeNo = out_trade_no, Subject = subject, TotalAmount = total_amount, Body = body }; var req = new AlipayTradePrecreateRequest(); req.SetBizModel(model); req.SetNotifyUrl(notify_url); var response = await _client.ExecuteAsync(req); ResponseModel responseModel = new ResponseModel() { code = HTTPResponseCode.PartialContent, data = response.Body }; if (response.IsError) { responseModel.code = HTTPResponseCode.BadRequest; responseModel.message = response.Msg; } else { responseModel.code = HTTPResponseCode.Successful; } return(Json(responseModel)); }
//扫码支付 public override async Task <AlipayReponse> ExecuteAsync(TradeModel request, ServerCallContext context) { var model = new AlipayTradePrecreateModel { OutTradeNo = request.OutTradeNo, Subject = request.Subject, TotalAmount = request.TotalAmount, Body = request.Body }; var req = new AlipayTradePrecreateRequest(); req.SetBizModel(model); req.SetNotifyUrl("http://domain.com/alipay/notify/precreate"); var response = await _client.ExecuteAsync(req, _optionsAccessor.Value); return(new AlipayReponse { Message = response.Body, Qrcode = response.QrCode }); //return base.ExecuteAsync(request, context); }
public ActionResult GetFile() { IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", "2019082766434970", "MIIEpQIBAAKCAQEAsdm9hrmwgGt3FsiUFDr4wZMWMxLXt5mvJUNBMJacYyxbkCkXu+PNk+1ItN6EFdbIjoqLRlKXT4nGZmcSs7RhbWlDSG4Qd/PaAVZmtjEKiNEwCBIoQ2LyhCGuD5c6bA2K1e/HkgEhXnHPDlCJXf0BrkavPaOHYxG3iCQEXRDxGfDjaK3DSu1vPLEqxsMqPDieTDc81pXGQZeH7cW5iGIo4gX0ac+Bmc9vRz5uUbsfkitTvyx49tO9ROGp5XhlrmqMuslFbYpvx8KNcCr+eVVcaHPOpUXRCHXECBpF+jD0ZvMRg5f43dTaOiXtSdMayfeV2BVSN5vkPYUoNPp8amoVFQIDAQABAoIBAATWrrBWpvWndtL43AZ84D2r+cOj9Jh7Jue1n7Vps5GDKG6Qn6Ot++7VWtAI6cEKWeR+4nEkWBeC4RHyJfEbrDbk0T7MN8h7que0aRD13pqATnU5wTysGXr8y5aC/8TmzWsqndxcCYNfR0nVaRdUhdIu/B+KLmnElqCukivSBS02c9o39nNY2WsxTVabKUaoso7IBmM8dFdEBY7AjlEJQfPBUQldTllm8uRXcKItaHh7/WYQ4MeAf1612eao5LKVR9N+XkDEIz+wys48W58bT/McruvIPjLI3S6MLG6loo34czH7YDbLLtarAUaPGs6YFTRXE2s0+eNrCWHRRrMdmAECgYEA7tmsESQwaEOhu4xPYK4qYqVFVSV8Ve2NP6hvr9fQBlgilshBpVwR0MX41TlFG76qdkBSStky333AoNIf2OzjpZNBA0rAVfnHY3tqJwzeJfsOYUmniY6nepBdorgh94b8DdaeurEre7vwqvFMTBGwmDsR4oIOidY49UiSQ8d+ggECgYEAvp7Tp6ApmyO+PI7yujfE1VsNTeHLiVnf87xYnMW87EOjyl2XqiycspBxiVtcy7PZnQVYaFqcAMf1cYb0ti6BiCNXMOMg0eWFpUknYHllsB7pXu7n8Aheu0QkKRlFzkTBlFcs5yRG7V/vfP0DPL53jI54xj8LHS69FIF9ikazaxUCgYEA7hpogZ4F86qYLBKvfr2g2z3OZBc+X5q0WGVdEXqekfSCZrWzW1jxGaKBcG3rCsGDxOZSIvNq14jQ4oEV5nYgagrloJaALjUWI4IATHVzb4Fa0HlQXryrEG+iKHhOxCb4VgNBsPK1Wl/8hyyM1rg7x0X7ikYEoDvCBCMYTCEvaAECgYEAsaCzPoqi+qxOA4R5b0m0o9RbC24TCoSzih7CvCQPLmLBaDvarnsv8b1j70kxqaiIaienAGce5CNw9j96HaIslj3IbAfad31YEnOeu+mj9oB3mz0o6KYEEKEoyRuBzvqHIMIzV5iYd25kbqYetCYQpOvGY4YvxxvcmhUodQf4/RkCgYEA2SM3mgOz+jaBs96JVtTeLeEFIaKmnceD8u+wuuVfulY2aDDkEwYPfHXBqu4EqZjpcDg2l2EBsLRy7Ot7K2EaGJV0s7H1AP/13kziKCl9WwDoDg4Dk7ZRzj378YFehX4b9T3SQ36WMkgFHB9zOcRP5Rf7HO4inN6UqILHSTuTOY4=", "json", "1.0", "RSA2", "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA05z4aIvz0V9DyE/YS72CuCVbb9ncn5EJHGijdQ+qokDXR1e0SNIbZeitNKUL1bfqapjYIDIPON49VHtPFBWz2osSITsv9+lIQUhb/nBvTAhLL2Yebx6/NPC3a+meqm5e53Fu8W6WYvpQGI7zcGMiJaDs19xZHyTGJf0dTVn7+r2/XWA37801W8rADnikIyKm4gu1AiWWtpuVy+bimc6fcFq5dHOnHGlcK+kx+Bm4yRN3aDE8kG2EszLV850KaZwvHlUGdiW3mVixpfbQJV8ei2n0HIwLVGVvt1hjwNGgvrNAuBBc2ACAkk45gg77+pTiHR1XzxyjiXEelGUfFN09wQIDAQAB", "GBK", false); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); var rand = this.GetRandomMumber(17); request.BizContent = "{" + "\"out_trade_no\":\"" + (201523423420101001 + long.Parse(rand)) + "\"," + "\"seller_id\":\"2088631146114221\"," + "\"total_amount\":0.1," + "\"subject\":\"Iphone6 16G\"," + "\"timeout_express\":\"90m\"," + "\"qr_code_timeout_express\":\"90m\"" + " }"; AlipayTradePrecreateResponse response = client.Execute(request); ViewBag.Src = response.QrCode; return(File(QrCodeHelper.GenQrCode(response.QrCode, 200).ToArray(), @"image/jpeg")); }
/// <summary> /// 预付统一下单 /// </summary> /// <param name="request">提交给统一下单API的参数</param> /// <param name="config"></param> /// <param name="accessToken">用户授权码</param> /// <param name="timeOut">超时时间</param> /// <returns>成功时返回,其他抛异常</returns> public static async Task <AlipayTradePrecreateResponse> CreateOrderAsync(AlipayTradePrecreateModel request, AlipayConfig config, string accessToken = null, int timeOut = 6) { IAopClient client = new AopClient(AlipayConstants.GATEWAYURL, config.AppId, config.PrivateKey, config.Format, config.Version, config.SignType, config.AliPublicKey, config.Charset, config.KeyFromFile); var requestData = new AlipayTradePrecreateRequest(); requestData.SetNotifyUrl(config.NotifyUrl); requestData.SetBizModel(request); return(await client.ExecuteAsync(requestData, accessToken)); }
/// <summary> /// 请求支付宝创建订单接口 /// </summary> /// <param name="biz_content"></param> /// <returns></returns> private AlipayTradePrecreateResponse Prepay(string biz_content) { AlipayTradePrecreateRequest payRequst = new AlipayTradePrecreateRequest(); payRequst.BizContent = biz_content; //需要异步通知的时候,需要是指接收异步通知的地址。 payRequst.SetNotifyUrl("http://alipayapi.zhilvtx.com/API/ALIPAY/Notify"); Dictionary <string, string> paramsDict = (Dictionary <string, string>)payRequst.GetParameters(); AlipayTradePrecreateResponse payResponse = client.Execute(payRequst); return(payResponse); }
/// <summary> /// 获取扫码支付的Html /// </summary> /// <param name="transaction">支付交易</param> /// <returns></returns> public virtual HtmlString GetQRCodePaymentHtml(PaymentTransaction transaction) { var templateManager = Application.Ioc.Resolve <TemplateManager>(); #if !NETCORE // 获取商户Id等设置 var apiData = transaction.Api.ExtraData.GetOrDefault <ApiData>("ApiData") ?? new ApiData(); // 获取货币信息,目前仅支持人民币支付 var currencyManager = Application.Ioc.Resolve <CurrencyManager>(); var info = currencyManager.GetCurrency(transaction.CurrencyType); if (info == null || info.Type != "CNY") { return(new HtmlString(templateManager.RenderTemplate( "finance.payment/error_text.html", new { error = new T("Alipay only support CNY") }))); } // 如果交易之前没有获取过二维码Url,则通过支付宝Api获取二维码Url // 当前沙箱环境中交易流水号相同时不会重复创建支付宝交易,仅可能会返回不同的二维码 // 如果正式环境有变化可能需要做出更多处理,例如缓存之前的二维码(并考虑二维码的过期时间) var client = GetAopClient(apiData); var request = new AlipayTradePrecreateRequest(); request.BizContent = JsonConvert.SerializeObject(new { out_trade_no = transaction.Serial, // 交易流水号 seller_id = apiData.PayeePartnerId, // 收款商户Id total_amount = transaction.Amount.ToString("0.00"), // 金额 subject = transaction.Description.TruncateWithSuffix(15), // 交易标题 body = transaction.Description, // 交易描述 }, Formatting.Indented); var notifyUrl = PaymentUtils.GetReturnOrNotifyUrl( apiData.ReturnDomain, AlipayQRCodePayNotifyUrl); request.SetNotifyUrl(notifyUrl); var response = client.Execute(request); if (response.IsError) { return(new HtmlString(templateManager.RenderTemplate( "finance.payment/error_text.html", new { error = $"{response.Msg}: {response.SubMsg}" }))); } // 生成二维码图片 var generator = new QRCodeGenerator(); var qrCodeData = generator.CreateQrCode(response.QrCode, QRCodeGenerator.ECCLevel.Q); var qrCode = new Base64QRCode(qrCodeData); var qrCodeBase64 = qrCode.GetGraphic(20); // 返回模板 return(new HtmlString(templateManager.RenderTemplate( "finance.payment.alipaymobile/qrcode_pay.html", new { transactionId = transaction.Id, qrCodeBase64 }))); #else return(new HtmlString(templateManager.RenderTemplate( "finance.payment/error_text.html", new { error = new T("Alipay qrcode pay is unsupported on .net core yet") }))); #endif }
private void Start_Request(object sender, RoutedEventArgs e) { if (AliPayClient != null) { var request = new AlipayTradePrecreateRequest(); var trade_ID = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds; if (Price.Text != "" && Operation.Text != "") { request.BizContent = JsonConvert.SerializeObject(new PrecreatReContent(trade_ID, Price.Text, Operation.Text, Convert.ToInt32(QrTime_Setting.Value).ToString())); } else { MsBoxShow("两项不能为空!"); } var Alipay_Response = AliPayClient.Execute(request); var JsonObj = JObject.Parse(Alipay_Response.Body)["alipay_trade_precreate_response"]; if (Alipay_Response.Code == "10000") { var QR_String = JsonObj["qr_code"].ToString(); QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeVersion = 0; Bitmap img = qrCodeEncoder.Encode(QR_String, Encoding.UTF8); BitmapImage bitmapimg = new BitmapImage(); using (var ms = new MemoryStream()) { img.Save(ms, ImageFormat.Bmp); bitmapimg.BeginInit(); bitmapimg.StreamSource = ms; bitmapimg.CacheOption = BitmapCacheOption.OnLoad; bitmapimg.EndInit(); } Pay_State.Content = "已生成待支付"; QRImg.Source = bitmapimg; Expander_Request.IsExpanded = false; Order_Num.Text = trade_ID.ToString(); } else { MsBoxShow(Alipay_Response.Msg, $"错误代码:{Alipay_Response.Code}"); } } else { MsBoxShow("请先填写相关API"); } }
private AlipayTradePrecreateResponse Prepay(string biz_content) { AlipayTradePrecreateRequest payRequst = new AlipayTradePrecreateRequest(); payRequst.BizContent = biz_content; //需要异步通知的时候,需要是指接收异步通知的地址。 payRequst.SetNotifyUrl("http://10.5.21.14/notify_url.aspx"); Dictionary <string, string> paramsDict = (Dictionary <string, string>)payRequst.GetParameters(); //new DefaultAopClient(Config.serverUrl, Config.appId, Config.merchant_private_key); AlipayTradePrecreateResponse payResponse = client.Execute(payRequst); return(payResponse); }
public AlipayF2FPrecreateResult tradePrecreate(AlipayTradePrecreateContentBuilder builder) { AlipayF2FPrecreateResult payResult = new AlipayF2FPrecreateResult(); try { AlipayTradePrecreateRequest payRequest = new AlipayTradePrecreateRequest(); payRequest.BizContent = builder.BuildJson(); payResult.response = client.Execute(payRequest); return(payResult); } catch { payResult.response = null; return(payResult); } }
public AlipayF2FPrecreateResult tradePrecreate(AlipayTradePrecreateContentBuilder builder, string notify_url) { AlipayF2FPrecreateResult payResult = new AlipayF2FPrecreateResult(); try { AlipayTradePrecreateRequest payRequest = new AlipayTradePrecreateRequest(); payRequest.BizContent = builder.BuildJson(); payRequest.SetNotifyUrl(notify_url); payResult.response = client.Execute(payRequest); return(payResult); } catch (Exception ex) { payResult.response = null; return(payResult); } }
public async Task <IActionResult> PreCreate(string out_trade_no, string subject, string total_amount, string body, string notify_url) { var model = new AlipayTradePrecreateModel() { Body = body, Subject = subject, TotalAmount = total_amount, OutTradeNo = out_trade_no, }; var req = new AlipayTradePrecreateRequest(); req.SetBizModel(model); req.SetNotifyUrl(notify_url); var response = await _client.ExecuteAsync(req); return(Ok(response.Body)); }
// 当面付/扫码支付 public async Task <AlipayTradePrecreateResponse> PreCreate(PayRequest request) { var order = OrderService.Get(request.Id); var model = new AlipayTradePrecreateModel { OutTradeNo = order.Order_SN, Subject = order.Name, TotalAmount = order.Order_Money.ToString("n"), Body = order.Remark }; var req = new AlipayTradePrecreateRequest(); req.SetBizModel(model); req.SetNotifyUrl(request.NotifyUrl); return(await client.ExecuteAsync(req, options.Value)); }
public async Task <AlipayF2FPrecreateResult> TradePrecreateAsync(AlipayTradePrecreateContentBuilder builder, string notify_url) { AlipayF2FPrecreateResult payResult = new AlipayF2FPrecreateResult(); try { AlipayTradePrecreateRequest payRequest = new AlipayTradePrecreateRequest(); payRequest.BizContent = builder.BuildJson(); payRequest.SetNotifyUrl(notify_url); payResult.response = await client.ExecuteAsync(payRequest); return(payResult); } catch { payResult.response = null; return(payResult); } }
public async Task <IActionResult> PreCreate(AlipayTradePreCreateViewModel viewModel) { var model = new AlipayTradePrecreateModel() { OutTradeNo = viewModel.OutTradeNo, Subject = viewModel.Subject, TotalAmount = viewModel.TotalAmount, Body = viewModel.Body, }; var req = new AlipayTradePrecreateRequest(); req.SetBizModel(model); req.SetNotifyUrl(viewModel.NotifyUrl); var response = await _client.ExecuteAsync(req); ViewData["qrcode"] = response.QrCode; ViewData["response"] = response.Body; return(View()); }
/// <summary> /// 预支付,提供码,扫完付款 /// </summary> /// <returns></returns> public ActionResult Precreate() { string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff"); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); request.BizContent = "{" + " \"out_trade_no\":\"20150320010101002\"," + " \"total_amount\":\"88.88\"," + " \"subject\":\"Iphone6 16G\"," + " \"store_id\":\"NJ_001\"," + " \"timeout_express\":\"90m\"}";//设置业务参数 // AlipayTradePrecreateResponse response = client.execute(request); AlipayTradePrecreateResponse response = new AliPayHelper().Client().pageExecute(request); // var resp = new AliPayHelper().Client().SdkExecute(request); //string resultData = HttpHelper.Post(AliPayConfig.serverUrl, resp.Body); //LogHelper.WriteLog("扫码支付", resultData); return(Content(response.Body)); }
public void Precreate() { IAopClient client = GetClient(); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); //TODO:此处替换官方文档 request.BizContent = "{" + " \"out_trade_no\":\"20160320010101001\"," + " \"total_amount\":88.88," + " \"discountable_amount\":8.88," + " \"undiscountable_amount\":80," + " \"buyer_logon_id\":\"15901825620\"," + " \"subject\":\"Iphone6 16G\"," + " \"body\":\"Iphone6 16G\"," + " \"timeout_express\":\"90m\"," + " \"sub_merchant\":{" + " \"merchant_id\":\"19023454\"" + " }" + " }"; request.BizContent = JsonConvert.SerializeObject(new Entities.Precreate() { out_trade_no = "20160320010101001", subject = "Iphone6 16G", total_amount = 88.88 }); AlipayTradePrecreateResponse response = client.Execute(request); if (!response.IsError) { Console.WriteLine("调用成功"); } else { Console.WriteLine("调用失败"); } Assert.IsFalse(response.IsError); }
public ActionResult Show(Order order) { IAopClient client = new DefaultAopClient(URL, APPID, APP_PRIVATE_KEY, FORMAT, "2.0", "RSA2", ALIPAY_PUBLIC_KEY, CHARSET, false); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称如: AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); //创建API对应的request类,请求返回二维码 AlipayTradePagePayRequest requestPagePay = new AlipayTradePagePayRequest(); //请求返回支付宝支付网页 AlipayTradePagePayModel model = new AlipayTradePagePayModel(); //主要注意的是这个地方的值 model.Body = order.GoodsMs; model.Subject = order.OrderName; model.TotalAmount = order.Count; model.OutTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss");;//订单号我们是直接用日期产生的 model.StoreId = "William001"; model.ProductCode = "FAST_INSTANT_TRADE_PAY"; requestPagePay.SetBizModel(model); //这是要注意的,支付后就要通过他完成回调,这里填写你要跳转页面的地址 requestPagePay.SetReturnUrl("http://47.106.255.80:8080/Snail/#/OrderDetailss"); var response = client.SdkExecute(requestPagePay);//Execute(request); if (!response.IsError) { var res = new { success = true, out_trade_no = response.OutTradeNo, // qr_code = response.QrCode, //二维码字符串 pay_url = URL + "?" + response.Body }; return(Json(res)); } else { var res = new { success = false, }; return(Json(res)); } }
/// <summary> /// 支付宝扫码预支付 /// </summary> /// <param name="precreate">支付实体</param> /// <param name="alipaySMPayBack">支付返回实体</param> /// <param name="message">错误提示</param> /// <returns></returns> internal bool Precreate(Precreate precreate, out PrecreateBack alipaySMPayBack, out string message) { _log.Info("扫码预支付 Precreate 开始"); var payRequst = new AlipayTradePrecreateRequest(); payRequst.SetNotifyUrl(AlipayConfig.NotifyUrl); precreate.Body = $"{precreate.DeviceID}║{precreate.Body}"; //生成bizcontent的json数据,并把默认值除掉 payRequst.BizContent = JsonConvert.SerializeObject(precreate, new Newtonsoft.Json.JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore, ContractResolver = new LowerPropertyContractResolver() }).ToLower(); var payResponse = client.Execute(payRequst); if (payResponse.Code == "10000") { _log.Info("扫码预支付成功!"); alipaySMPayBack = new PrecreateBack() { Code = payResponse.Code, Msg = payResponse.Msg, Out_Trade_No = payResponse.OutTradeNo, Sub_Code = payResponse.SubCode, Sub_Msg = payResponse.SubMsg, Qr_Code = payResponse.QrCode }; message = ""; return(true); } else { alipaySMPayBack = null; message = $"{ payResponse.Msg},{payResponse.SubMsg}"; _log.Error($"扫码预支付失败:{message}"); return(false); } }
public ActionResult QrcodeRSAPay(string bizContent) { var op = new OpResult(); AlipayTradePrecreateRequest payRequst = new AlipayTradePrecreateRequest(); payRequst.BizContent = bizContent; //需要异步通知的时候,需要是指接收异步通知的地址。 payRequst.SetNotifyUrl(qrcode._1.Config.Notify_url); Dictionary <string, string> paramsDict = (Dictionary <string, string>)payRequst.GetParameters(); AlipayTradePrecreateResponse payResponse = client.Execute(payRequst); //以下返回结果的处理供参考。 //payResponse.QrCode即二维码对于的链接 //将链接用二维码工具生成二维码打印出来,顾客可以用支付宝钱包扫码支付。 string result = payResponse.Body; if (payResponse != null) { switch (payResponse.Code) { case qrcode._2.ResultCode.SUCCESS: var createUrl = Url.Action("GenerateQrcode", new { codeUrl = payResponse.QrCode }); op.Message = Request.Url.Scheme + "://" + Request.Url.Authority + Url.Action("CreateQRCode", new { url = createUrl, paySN = payResponse.OutTradeNo }); op.Successed = true; break; case qrcode._2.ResultCode.FAIL: StringBuilder sb2 = new StringBuilder(); sb2.Append("{\"out_trade_no\":\"" + payResponse.OutTradeNo + "\"}"); Cancel(sb2.ToString()); op.Message = "预下单失败"; break; } } return(new JsonNetResult(op)); }
public ActionResult FaceToPay(string orderName, string orderAmount, string outTradeNo, bool pin = false) { //域名 IAopClient client = new DefaultAopClient(URL, APPID, APP_PRIVATE_KEY, FORMAT, "1.0", "RSA2", ALIPAY_PUBLIC_KEY, CHARSET, false); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称如: AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();//创建API对应的request类 //SDK已经封装掉了公共参数,这里只需要传入业务参数 Random ran = new Random(); int RandKey = ran.Next(100, 999); AlipayTradePayModel model = new AlipayTradePayModel { OutTradeNo = outTradeNo + RandKey, TotalAmount = orderAmount, Subject = orderName, //StoreId = "NJ_001", TimeoutExpress = "90m" }; request.SetBizModel(model); //此次只是参数展示,未进行字符串转义,实际情况下请转义 //request.BizContent = "{" + // " \"out_trade_no\":\"20150320010101002\"," + // " \"total_amount\":\"88.88\"," + // " \"subject\":\"Iphone6 16G\"," + // " \"store_id\":\"NJ_001\"," + // " \"timeout_express\":\"90m\"}"; AlipayTradePrecreateResponse response = client.Execute(request); AlipayTradePrecreateContentBuilder builder = BuildPrecreateContent(model.Subject, model.TotalAmount, model.OutTradeNo); //如果需要接收扫码支付异步通知,那么请把下面两行注释代替本行。 //推荐使用轮询撤销机制,不推荐使用异步通知,避免单边账问题发生。 AlipayF2FPrecreateResult precreateResult = serviceClient.tradePrecreate(builder); //string notify_url = "http://10.5.21.14/notify_url.aspx"; //商户接收异步通知的地址 //AlipayF2FPrecreateResult precreateResult = serviceClient.tradePrecreate(builder, notify_url); //payResponse.QrCode即二维码对于的链接 //将链接用二维码工具生成二维码打印出来,顾客可以用支付宝钱包扫码支付。 var bitmap = new Bitmap(Path.Combine(_hostingEnvironment.WebRootPath, "images/error.png")); //调用成功,则处理业务逻辑 if (!response.IsError) { bitmap.Dispose(); bitmap = RenderQrCode(response.QrCode); //轮询订单结果 //根据业务需要,选择是否新起线程进行轮询 ParameterizedThreadStart parStart = new ParameterizedThreadStart(LoopQuery); //Thread myThread = new Thread(parStart); //object o = precreateResult.response.OutTradeNo; //myThread.Start(o); var res = new { success = true, out_trade_no = response.OutTradeNo, tot = model.TotalAmount, suj = model.Subject, qr_code = response.QrCode //发现返回的是一个网址,后续需要用这个网址字符串创建二维码 }; if (pin) { return(Json(res)); } else { MemoryStream ms = new MemoryStream(); bitmap.Save(ms, ImageFormat.Png); byte[] bytes = ms.GetBuffer(); return(File(bytes, "image/png")); } } else { //return Content("调用失败,原因:" + response.Msg + "," + response.SubMsg); var res = new { success = false, }; return(Json(res)); } ////以下返回结果的处理供参考。 ////payResponse.QrCode即二维码对于的链接 ////将链接用二维码工具生成二维码打印出来,顾客可以用支付宝钱包扫码支付 //var bitmap = new Bitmap(Path.Combine(_hostingEnvironment.WebRootPath, "images/error.png")); //switch (precreateResult.Status) //{ // case ResultEnum.SUCCESS: // bitmap.Dispose(); // bitmap = RenderQrCode(precreateResult.response.QrCode); // //轮询订单结果 // //根据业务需要,选择是否新起线程进行轮询 // ParameterizedThreadStart parStart = new ParameterizedThreadStart(LoopQuery); // Thread myThread = new Thread(parStart); // object o = precreateResult.response.OutTradeNo; // myThread.Start(o); // break; // case ResultEnum.FAILED: // Console.WriteLine("生成二维码失败:" + precreateResult.response.Body); // break; // case ResultEnum.UNKNOWN: // Console.WriteLine("生成二维码失败:" + (precreateResult.response == null ? "配置或网络异常,请检查后重试" : "系统异常,请更新外部订单后重新发起请求")); // break; //} //MemoryStream ms = new MemoryStream(); //bitmap.Save(ms, ImageFormat.Png); //byte[] bytes = ms.GetBuffer(); //return File(bytes, "image/png"); }
public void Post() { string Data = DataObj.GetData(); if (Data.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } JObject json = new JObject(); try { json = (JObject)JsonConvert.DeserializeObject(Data); } catch (Exception Ex) { Log.Write("[OrderQC]:", "【Data】" + Data, Ex); json = null; } if (json == null) { DataObj.OutError("1000"); return; } OrderF2F OrderF2F = new OrderF2F(); OrderF2F = JsonToObject.ConvertJsonToModel(OrderF2F, json); UserTrack UserTrack = new UserTrack(); UserTrack = JsonToObject.ConvertJsonToModel(UserTrack, json); #region 获取并处理用户信息 Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == OrderF2F.Token); if (baseUsers == null)//用户令牌不存在 { DataObj.OutError("2004"); return; } if (baseUsers.State != 1)//用户被锁定 { DataObj.OutError("2003"); return; } if (baseUsers.CardStae != 2)//未实名认证 { //DataObj.OutError("2006"); //return; } if (baseUsers.MiBao != 1)//未设置支付密码 { //DataObj.OutError("2008"); //return; } string NeekName = baseUsers.NeekName; if (NeekName.IsNullOrEmpty()) { NeekName = baseUsers.TrueName; } if (NeekName.IsNullOrEmpty()) { NeekName = "货款"; } #endregion #region 创建交易 if (OrderF2F.Action == "Create") { #region 处理选择通道 int PayWay = OrderF2F.PayWay; string Tag = ""; byte PayType = 1; string PayName = ""; string OpenId = ""; //微信JSAPI专用 if (OrderF2F.OType == 7) { //支付宝 Tag = "AliPay"; } if (OrderF2F.OType == 8) {//微信 Tag = "WeiXin"; } if (PayWay.IsNullOrEmpty()) { if (Tag == "AliPay") { PayWay = 5;//兼容老版本 } if (Tag == "WeiXin") { PayWay = 6;//兼容老版本 } } PayConfig PayConfig = Entity.PayConfig.FirstOrDefault(n => n.Id == PayWay && n.State == 1); //获取系统支付配置 if (PayConfig == null) { DataObj.OutError("1000"); return; } if (PayConfig.GroupType != Tag) { DataObj.OutError("1000"); return; } PayName = "扫码付-" + PayConfig.Name; byte ComeWay = 1; if (!OrderF2F.PayId.IsNullOrEmpty()) { if (OrderF2F.PayId == "shop") { ComeWay = 2; } PayName = "收银台-" + PayConfig.Name; if (OrderF2F.OType == 7) { if (OrderF2F.PayId == "shop") { OrderF2F.PayId = string.Empty; PayType = 2; } } if (OrderF2F.OType == 8) { OpenId = OrderF2F.PayId; OrderF2F.PayId = string.Empty; PayType = 2; } } int InType = 0; if (!OrderF2F.InType.IsNullOrEmpty()) { InType = 1; } SysControl SysControl = new SysControl(); bool IsNew = true; if (OrderF2F.Id.IsNullOrEmpty()) { //这是旧逻辑,有一些旧版还在用 #region 版本比较 升级之后比较长时间后可以考滤删除版本判断代码 var vSysAgent = this.Entity.SysAgent.FirstOrDefault(o => o.Id == baseUsers.Agent); if (vSysAgent == null) { DataObj.OutError("1000"); return; } IsNew = BizExt.NewOrOldVersion(vSysAgent, Equipment, this.Entity); #endregion if (IsNew)//新版 { if (InType == 1) { SysControl = Entity.SysControl.FirstOrDefault(n => n.Tag == Tag && n.PayWay == PayWay && n.LagEntryDay > 0); } else { SysControl = Entity.SysControl.FirstOrDefault(n => n.Tag == Tag && n.PayWay == PayWay && n.LagEntryDay == 0); } } else//旧版 { SysControl = Entity.SysControl.FirstOrDefault(n => n.Tag == Tag && n.PayWay == PayWay); } } else { SysControl = Entity.SysControl.FirstOrDefault(n => n.Id == OrderF2F.Id); if (SysControl.LagEntryDay > 0) { InType = 1; } else { InType = 0; } } //获取系统支付配置 if (SysControl == null) { DataObj.OutError("1005"); return; } if (InType == 1 && (SysControl.LagEntryDay.IsNullOrEmpty() || SysControl.LagEntryNum.IsNullOrEmpty())) { DataObj.Msg = "请升级到最新版再发起Tn到帐交易!"; DataObj.OutError("1005"); return; } SysControl syscontrol = SysControl.ChkState(); if (syscontrol.State != 1) { DataObj.OutError("1005"); return; } #endregion #region 订单生成 //处理交易地点 if (OrderF2F.X.IsNullOrEmpty() || OrderF2F.Y.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } //开始处理参数 OType通道,7支付宝,8微信 if (OrderF2F.Amoney.IsNullOrEmpty() || OrderF2F.OType.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } OrderF2F.Amoney = OrderF2F.Amoney.FormatMoney(); //获取用户支付配置 UserPay UserPay = Entity.UserPay.FirstOrDefault(n => n.UId == baseUsers.Id && n.PId == PayWay); if (UserPay == null) { DataObj.OutError("1000"); return; } //获取分支机构信息 SysAgent SysAgent = new SysAgent(); if (!baseUsers.Agent.IsNullOrEmpty()) { SysAgent = Entity.SysAgent.FirstOrNew(n => n.Id == baseUsers.Agent); } OrderF2F.PayWay = PayWay; //获取系统配置 SysSet SysSet = Entity.SysSet.FirstOrDefault(); if (InType == 1) {//客户端传来T+N但是系统没开启时无效 if (SysSet.LagEntry == 0) { InType = 0; } } if (InType == 1) { //手续费 OrderF2F.Poundage = 0; //商户费率 OrderF2F.UserRate = 0; //T+n时,代理佣金为 交易金额*费率 decimal AgentPayGet = OrderF2F.Amoney * SysSet.AgentGet; OrderF2F.AgentPayGet = (Double)AgentPayGet; //佣金舍位 OrderF2F.AgentPayGet = OrderF2F.AgentPayGet.Floor(); } else { //手续费 OrderF2F.Poundage = OrderF2F.Amoney * (decimal)UserPay.Cost; //手续费取进 OrderF2F.Poundage = OrderF2F.Poundage.Ceiling(); //商户费率 OrderF2F.UserRate = UserPay.Cost; //分支机构佣金设置为0,待分润计算后再写入 OrderF2F.AgentPayGet = 0; } OrderF2F.UId = baseUsers.Id; //到帐金额=支付金额-手续费 OrderF2F.PayMoney = OrderF2F.Amoney - OrderF2F.Poundage; //第三方支付通道率 OrderF2F.SysRate = (double)PayConfig.Cost; //这里是利润计算========== //利润=总金额-到帐-支付手续费 decimal GetAll = OrderF2F.Amoney - OrderF2F.PayMoney - OrderF2F.Amoney * (decimal)OrderF2F.SysRate; //利润舍位 GetAll = GetAll.Floor(); //总利润 OrderF2F.AIdPayGet = (double)GetAll; OrderF2F.Agent = SysAgent.Id;//分支机构Id OrderF2F.AId = baseUsers.AId; OrderF2F.FId = 0; OrderF2F.OrderState = 1; OrderF2F.PayState = 0; OrderF2F.AgentState = 0; OrderF2F.AddTime = DateTime.Now; OrderF2F.PayId = string.Empty; OrderF2F.PayType = PayType; //写入前,判断交易金额限制 if (OrderF2F.Amoney < syscontrol.SNum || OrderF2F.Amoney > syscontrol.ENum) { DataObj.OutError("1006"); return; } //写入订单总表 Orders Orders = new Orders(); Orders.UId = OrderF2F.UId; Orders.TName = NeekName; Orders.PayType = PayType; Orders.PayName = PayName; Orders.RUId = 0; Orders.RName = string.Empty; Orders.TType = OrderF2F.OType; Orders.TState = 1; Orders.Amoney = OrderF2F.Amoney; Orders.Poundage = OrderF2F.Poundage; Orders.AddTime = DateTime.Now; Orders.PayState = 0; Orders.PayWay = PayConfig.Id; Orders.Agent = OrderF2F.Agent; Orders.AgentState = 0; Orders.AId = OrderF2F.AId; Orders.FId = 0; Orders.ComeWay = ComeWay; string OrderAddress = OrderF2F.OrderAddress; if (OrderAddress.IsNullOrEmpty()) { OrderAddress = Utils.GetAddressByGPS(OrderF2F.X, OrderF2F.Y); } Orders.OrderAddress = OrderAddress; Orders.X = OrderF2F.X; Orders.Y = OrderF2F.Y; if (InType == 1) { if (IsNew)//新版 { Orders.LagEntryDay = SysControl.LagEntryDay; Orders.LagEntryNum = SysControl.LagEntryNum; } else { Orders.LagEntryDay = SysSet.LagEntryDay; Orders.LagEntryNum = SysSet.LagEntryNum; } } else { Orders.LagEntryDay = 0; Orders.LagEntryNum = 0; } Entity.Orders.AddObject(Orders); Entity.SaveChanges(); Entity.Refresh(RefreshMode.StoreWins, Orders); OrderF2F.OId = Orders.TNum; Entity.OrderF2F.AddObject(OrderF2F); Entity.SaveChanges(); //======================================= UserTrack.ENo = DataObj.ENo; UserTrack.OPType = Orders.PayName; UserTrack.UserName = Orders.TNum; UserTrack.GPSAddress = Orders.OrderAddress; UserTrack.GPSX = Orders.X; UserTrack.GPSY = Orders.Y; if (!OrderF2F.IP.IsNullOrEmpty()) { UserTrack.IP = OrderF2F.IP; } Orders.SeavGPSLog(UserTrack, Entity); //======================================= #endregion if (PayConfig.DllName == "AliPay") { #region 提交支付宝 string[] PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' }); //接口信息 商户号,密钥,支付宝号 if (PayConfigArr.Length != 3) { DataObj.OutError("9999"); return; } if (AlipayVer == "1.0") { #region 1.0老接口 Submit Submit = new Submit(); Submit.pid = PayConfigArr[0]; Submit.key = PayConfigArr[1]; //卖家支付宝帐户 string seller_email = PayConfigArr[2]; //订单业务类型 string product_code = "QR_CODE_OFFLINE"; //SOUNDWAVE_PAY_OFFLINE:声波支付,FINGERPRINT_FAST_PAY:指纹支付,BARCODE_PAY_OFFLINE:条码支付 //////////////////////////////////////////////////////////////////////////////////////////////// //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Submit.pid); sParaTemp.Add("_input_charset", "utf-8"); sParaTemp.Add("service", "alipay.acquire.precreate"); sParaTemp.Add("out_trade_no", OrderF2F.OId); sParaTemp.Add("subject", Orders.TName + ":" + OrderF2F.OId); sParaTemp.Add("product_code", product_code); sParaTemp.Add("total_fee", OrderF2F.Amoney.ToString("F2")); sParaTemp.Add("seller_email", seller_email); sParaTemp.Add("notify_url", NoticePath + "/PayCenter/AliPay/Notice.html"); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp); Utils.WriteLog(sHtmlText, "orderface"); try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(sHtmlText); string is_success = xmlDoc.SelectSingleNode("/alipay/is_success").InnerText; if (is_success == "T") { string result_code = xmlDoc.SelectSingleNode("/alipay/response/alipay/result_code").InnerText; if (result_code == "SUCCESS") { //成功 string qr_code = xmlDoc.SelectSingleNode("/alipay/response/alipay/qr_code").InnerText; /* * voucher_type 凭证类型 * qr_code 二维码码串 * pic_url 二维码图片地址 * small_pic_ur 二维码小图地址 */ OrderF2F.PayId = qr_code; Entity.SaveChanges(); Orders.PayId = qr_code; } else { Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } } else { Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } } catch (Exception) { //Utils.WriteLog(Ex.ToString()); Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } #endregion } if (AlipayVer == "2.0") { #region 2.0新接口 ALF2FPAY ALF2FPAY = new ALF2FPAY(); ALF2FPAY.pid = PayConfigArr[0]; ALF2FPAY.appId = PayConfigArr[2]; IAopClient client = new DefaultAopClient(ALF2FPAY.serverUrl, ALF2FPAY.appId, ALF2FPAY.merchant_private_key, "json", ALF2FPAY.version, ALF2FPAY.sign_type, ALF2FPAY.alipay_public_key, ALF2FPAY.charset); StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append("\"out_trade_no\":\"" + OrderF2F.OId + "\","); sb.Append("\"total_amount\":\"" + OrderF2F.Amoney.ToMoney() + "\","); sb.Append("\"timeout_express\":\"30m\","); sb.Append("\"subject\":\"" + OrderF2F.OId + "\""); sb.Append("}"); AlipayTradePrecreateRequest payRequst = new AlipayTradePrecreateRequest(); string notify_url = NoticePath + "/PayCenter/AliPay/Notice.html"; payRequst.SetNotifyUrl(notify_url); payRequst.BizContent = sb.ToString(); Dictionary <string, string> paramsDict = (Dictionary <string, string>)payRequst.GetParameters(); AlipayTradePrecreateResponse payResponse = client.Execute(payRequst); if (payResponse != null) { payResponse.SaveLog(Entity); //保存记录 if (payResponse.Code == "10000") { OrderF2F.PayId = payResponse.QrCode; Entity.SaveChanges(); Orders.PayId = payResponse.QrCode; } else { Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } } else { Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } #endregion } #endregion } if (PayConfig.DllName == "WeiXin") { #region 提交微信 //初始化支付配置 WxPayConfig WxPayConfig = new WxPayConfig(); string[] PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' }); //接口信息 appid,mchid,key,appsecret if (PayConfigArr.Length != 4 && PayConfigArr.Length != 5) { DataObj.OutError("9999"); return; } string ServerIp = ConfigurationManager.AppSettings["ServerIp"].ToString(); string Wx_Cert_Path = ConfigurationManager.AppSettings["Wx_Cert_Path"].ToString(); string Wx_Cert_PWD = ConfigurationManager.AppSettings["Wx_Cert_PWD"].ToString(); WxPayConfig.IP = ServerIp; WxPayConfig.APPID = PayConfigArr[0]; WxPayConfig.MCHID = PayConfigArr[1]; WxPayConfig.KEY = PayConfigArr[2]; WxPayConfig.APPSECRET = PayConfigArr[3]; if (PayConfigArr.Length == 5) { WxPayConfig.SubMCHID = PayConfigArr[4]; } WxPayConfig.SSLCERT_PATH = Wx_Cert_Path; WxPayConfig.SSLCERT_PASSWORD = Wx_Cert_PWD; //支付配置结束 WxPayData data = new WxPayData(); //data.SetValue("auth_code", OrderF2F.PayId);//授权码 data.SetValue("body", Orders.TName + ":" + OrderF2F.OId); //商品描述 string total_fee = (OrderF2F.Amoney * 100).ToString("F0"); data.SetValue("total_fee", total_fee); //总金额 data.SetValue("out_trade_no", OrderF2F.OId); //产生随机的商户订单号 if (PayType == 2) { data.SetValue("trade_type", "JSAPI"); //交易类型 if (PayConfigArr.Length == 5) { //子商户模式 data.SetValue("sub_openid", OpenId); //用户OpenId } else { data.SetValue("openid", OpenId); //用户OpenId } } else { data.SetValue("trade_type", "NATIVE"); //交易类型 } data.SetValue("notify_url", NoticePath + "/PayCenter/WeiXinPay/Notice.html"); //异步通知地址 WxPayData result = WxPayApi.UnifiedOrder(data, WxPayConfig, 10); //调用统一下单接口 result.SaveLog(Entity); if (!result.IsSet("return_code") || result.GetValue("return_code").ToString() == "FAIL") { //支付失败 Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } else { if (!result.CheckSign(WxPayConfig.KEY)) { //签名失败,取消订单 Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } else { if (result.GetValue("return_code").ToString() == "SUCCESS" && result.GetValue("result_code").ToString() == "SUCCESS") { //获取支付字符串 if (PayType == 2) //JSAPI { string PayId = result.GetValue("prepay_id").ToString(); OrderF2F.PayId = PayId; } else { string PayId = result.GetValue("code_url").ToString(); OrderF2F.PayId = PayId; } Entity.SaveChanges(); Orders.PayId = OrderF2F.PayId; } else { //业务明确失败 Orders.TState = 0; OrderF2F.OrderState = 0; Entity.SaveChanges(); } } } #endregion } #region 提交好付 if (PayConfig.DllName == "HFAliPay" || PayConfig.DllName == "HFWeiXin") { string NoticeUrl = ""; string Action = ""; if (PayConfig.DllName == "HFAliPay") { NoticeUrl = NoticePath + "/PayCenter/HFAliPay/Notice.html"; Action = "AliSao"; } if (PayConfig.DllName == "HFWeiXin") { NoticeUrl = NoticePath + "/PayCenter/HFWeiXin/Notice.html"; if (PayType == 2) { Action = "WxJsApi"; } else { Action = "WxSao"; } } string[] PayConfigArr = PayConfig.QueryArray.Split(','); if (PayConfigArr.Length != 3) { DataObj.OutError("1000"); return; } //提交结算中心 string merId = PayConfigArr[0]; //商户号 string merKey = PayConfigArr[1]; //商户密钥 string JsPayWay = PayConfigArr[2]; //绑定通道 string orderId = Orders.TNum; //商户流水号 decimal money = Orders.Amoney * 100; long intmoney = Int64.Parse(money.ToString("F0")); string OrderMoney = intmoney.ToString();//金额,以分为单 string OpenIdStr = ""; if (PayConfig.Id == 13) { //特殊处理通道 Action = "WxJsApi"; OpenId = "OpenId"; } if (Action == "WxJsApi") { OpenIdStr = ",\"openid\":\"" + OpenId + "\""; } string PostJson = "{\"action\":\"" + Action + "\",\"txnamt\":\"" + OrderMoney + "\",\"merid\":\"" + merId + "\",\"payway\":\"" + JsPayWay + "\",\"orderid\":\"" + orderId + "\",\"backurl\":\"" + NoticeUrl + "\"" + OpenIdStr + "}"; string DataBase64 = LokFuEncode.Base64Encode(PostJson, "utf-8"); string Sign = (DataBase64 + merKey).GetMD5(); DataBase64 = HttpUtility.UrlEncode(DataBase64); string PostData = string.Format("req={0}&sign={1}", DataBase64, Sign); string HF_Url = "https://api.zhifujiekou.com/api/mpgateway"; string Ret = Utils.PostRequest(HF_Url, PostData, "utf-8"); JObject JS = new JObject(); try { JS = (JObject)JsonConvert.DeserializeObject(Ret); } catch (Exception Ex) { Log.Write("[Order_HF]:", "【PostData】" + PostData + "\n【Ret】" + Ret, Ex); json = null; } if (JS == null) { DataObj.OutError("1000"); return; } string resp = JS["resp"].ToString(); Ret = LokFuEncode.Base64Decode(resp, "utf-8"); try { JS = (JObject)JsonConvert.DeserializeObject(Ret); } catch (Exception Ex) { Log.Write("[Order_HF]:", "【Ret2】" + Ret, Ex); JS = null; } if (JS == null) { DataObj.OutError("1000"); return; } string respcode = JS["respcode"].ToString(); if (respcode != "00") { string respmsg = JS["respmsg"].ToString(); DataObj.OutError("1000"); Utils.WriteLog("[Order_HF_Err]:【" + respcode + "】" + respmsg, "orderface"); return; } if (JS["formaction"] == null) { Utils.WriteLog("[Order_HF_Err]:【formaction NULL】" + Ret, "orderface"); DataObj.OutError("2096"); return; } Orders.PayId = JS["formaction"].ToString(); if (PayConfig.Id == 13) { string myData = "{\"merid\":\"" + merId + "\",\"orderid\":\"" + orderId + "\",\"code\":\"" + Orders.PayId + "\"}"; DataBase64 = LokFuEncode.Base64Encode(myData, "utf-8"); Sign = (DataBase64 + merKey).GetMD5(); DataBase64 = HttpUtility.UrlEncode(DataBase64); string myUrl = string.Format("req={0}&sign={1}", DataBase64, Sign); string Url = "https://api.zhifujiekou.com/wxjsapi/gopay.html?" + myUrl; OrderF2F.PayId = Url; Entity.SaveChanges(); Orders.PayId = "http://api.kkapay.com/home/jump?tnum=" + Orders.TNum; } } #endregion Orders.Cols = "Id,TNum,PayId"; DataObj.Data = Orders.OutJson(); DataObj.Code = "0000"; DataObj.OutString(); } #endregion if (OrderF2F.Action == "GET")//获取订交易信息 { //开始处理参数 if (OrderF2F.OId.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } Orders Orders = Entity.Orders.FirstOrDefault(n => n.TNum == OrderF2F.OId && n.UId == baseUsers.Id); if (Orders == null) { DataObj.OutError("1000"); return; } OrderF2F Orderf2f = Entity.OrderF2F.FirstOrDefault(n => n.OId == OrderF2F.OId && n.UId == baseUsers.Id); if (Orders.TState == 1 && Orders.PayState == 0) { PayConfig PayConfig = Entity.PayConfig.FirstOrNew(n => n.Id == Orders.PayWay); if (PayConfig.DllName == "AliPay") { #region 支付宝处理 string[] PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' }); //接口信息 商户号,密钥,支付宝号 if (PayConfigArr.Length != 3) { DataObj.OutError("9999"); return; } if (AlipayVer == "1.0") { #region 1.0老接口 string pid = PayConfigArr[0]; string key = PayConfigArr[1]; int queryTimes = 10; //查询次数计数器 int Run = 0; while (queryTimes > 0 && Run != 1) { AliPayApi Api = new AliPayApi(); int succResult = Api.AliPayQuery(Orderf2f.OId, pid, key); //如果需要继续查询,则等待2s后继续 if (succResult == 2) { //Thread.Sleep(5000); //continue; Run = 1; //跳出循环,20160420 } //查询成功,返回订单查询接口返回的数据 else if (succResult == 1) { //Orders.PayState = 1;//此处不保存支付状态,由通知返回再操作 Orders = Orders.PaySuccess(Entity); Run = 1; } //订单交易失败 else { Orders.TState = 0; Orderf2f.OrderState = 0; Entity.SaveChanges(); } queryTimes--; } #endregion } if (AlipayVer == "2.0") { #region 2.0新接口 ALF2FPAY ALF2FPAY = new ALF2FPAY(); ALF2FPAY.pid = PayConfigArr[0]; ALF2FPAY.appId = PayConfigArr[2]; IAopClient client = new DefaultAopClient(ALF2FPAY.serverUrl, ALF2FPAY.appId, ALF2FPAY.merchant_private_key, "json", ALF2FPAY.version, ALF2FPAY.sign_type, ALF2FPAY.alipay_public_key, ALF2FPAY.charset); string QueryStr = "{\"out_trade_no\":\"" + Orders.TNum + "\"}"; ALF2FPAYObj ObjQuery = new ALF2FPAYObj(); ObjQuery.BizCode = QueryStr; ObjQuery.Client = client; ObjQuery.Entity = Entity; AliPayApi Api = new AliPayApi(); AlipayTradeQueryResponse queryResponse = Api.LoopAlipayQuery(ObjQuery, 1); if (queryResponse != null) { if (queryResponse.Code == "10000") { if (queryResponse.TradeStatus == "TRADE_FINISHED" || queryResponse.TradeStatus == "TRADE_SUCCESS") { //Orders.PayState = 1;//此处不保存支付状态,由通知返回再操作 Orders = Orders.PaySuccess(Entity); } } } #endregion } #endregion } if (PayConfig.DllName == "WeiXin") { #region 微信处理 //初始化支付配置 WxPayConfig WxPayConfig = new WxPayConfig(); string[] PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' }); //接口信息 appid,mchid,key,appsecret if (PayConfigArr.Length != 4 && PayConfigArr.Length != 5) { DataObj.OutError("9999"); return; } string ServerIp = ConfigurationManager.AppSettings["ServerIp"].ToString(); string Wx_Cert_Path = ConfigurationManager.AppSettings["Wx_Cert_Path"].ToString(); string Wx_Cert_PWD = ConfigurationManager.AppSettings["Wx_Cert_PWD"].ToString(); WxPayConfig.IP = ServerIp; WxPayConfig.APPID = PayConfigArr[0]; WxPayConfig.MCHID = PayConfigArr[1]; WxPayConfig.KEY = PayConfigArr[2]; WxPayConfig.APPSECRET = PayConfigArr[3]; if (PayConfigArr.Length == 5) { WxPayConfig.SubMCHID = PayConfigArr[4]; } WxPayConfig.SSLCERT_PATH = Wx_Cert_Path; WxPayConfig.SSLCERT_PASSWORD = Wx_Cert_PWD; //支付配置结束 int queryTimes = 10; //查询次数计数器 int Run = 0; while (queryTimes > 0 && Run != 1) { int succResult = 0;//查询结果 MicroPay MicroPay = new MicroPay(); WxPayData queryResult = MicroPay.WXQuery(Orderf2f.OId, WxPayConfig, Entity, out succResult); //如果需要继续查询,则等待2s后继续 if (succResult == 2) { //Thread.Sleep(5000); //continue; Run = 1; //跳出循环,20160420 } //查询成功,返回订单查询接口返回的数据 else if (succResult == 1) { Orderf2f.Trade_no = queryResult.GetValue("transaction_id").ToString(); int ret = Entity.SaveChanges(); //Orders.PayState = 1;//此处不保存支付状态,由通知返回再操作 Orders = Orders.PaySuccess(Entity); Run = 1; } //订单交易失败 else { Orders.TState = 0; Orderf2f.OrderState = 0; Entity.SaveChanges(); } queryTimes--; } #endregion } if (PayConfig.DllName == "HFAliPay" || PayConfig.DllName == "HFWeiXin") { #region 好付处理 string[] QueryArr = PayConfig.QueryArray.Split(','); if (QueryArr.Length == 3) { //提交结算中心 string merId = QueryArr[0]; //商户号 string merKey = QueryArr[1]; //商户密钥 string orderId = Orders.TNum; //商户流水号 string PostJson = "{\"merid\":\"" + merId + "\",\"orderid\":\"" + orderId + "\"}"; string DataBase64 = LokFuEncode.Base64Encode(PostJson, "utf-8"); string Sign = (DataBase64 + merKey).GetMD5(); DataBase64 = HttpUtility.UrlEncode(DataBase64); string PostData = string.Format("req={0}&sign={1}", DataBase64, Sign); string HF_Url = "https://api.zhifujiekou.com/api/query"; string Ret = Utils.PostRequest(HF_Url, PostData, "utf-8"); JObject JS = new JObject(); try { JS = (JObject)JsonConvert.DeserializeObject(Ret); } catch (Exception Ex) { Log.Write("[Order_HFQuery]:", "【PostData】" + PostData + "\n【Ret】" + Ret, Ex); JS = null; } if (JS == null) { DataObj.OutError("1000"); return; } if (JS["resp"] == null) { Utils.WriteLog("【Ret】" + Ret, "OrderQC_HFQuery"); DataObj.OutError("1000"); return; } string resp = JS["resp"].ToString(); Ret = LokFuEncode.Base64Decode(resp, "utf-8"); try { JS = (JObject)JsonConvert.DeserializeObject(Ret); } catch (Exception Ex) { Log.Write("[Order_HFQuery]:", "【Ret2】" + Ret, Ex); JS = null; } if (JS == null) { DataObj.OutError("1000"); return; } string respcode = JS["respcode"].ToString(); if (respcode != "00") { string respmsg = JS["respmsg"].ToString(); DataObj.OutError("1000"); Utils.WriteLog("[Order_HFQuery_Err]:【" + respcode + "】" + respmsg, "orderface"); return; } string resultcode = JS["resultcode"].ToString(); if (resultcode == "0000" || resultcode == "1002" || resultcode == "1004") { string txnamt = JS["txnamt"].ToString(); int factmoney = int.Parse(txnamt); if (((int)(Orders.Amoney * 100)) == factmoney) { //Orders.PayState = 1;//此处不保存支付状态,由通知返回再操作 Orders = Orders.PaySuccess(Entity); } } } #endregion } } DataObj.Data = Orders.OutJson(); DataObj.Code = "0000"; DataObj.OutString(); } }