public IHttpActionResult paycustom_get([FromBody] Order order) { UserInfo user = new UserInfo(); //报关通道实体 AliPayOrder aliorder = new AliPayOrder(); //支付报关实体 alipay alipay_reponse = new alipay(); API_Message message = new API_Message(); message.MessageCode = "1"; if (ModelState.IsValid) { try { user = _IUserRepository.UserInfos.Where(t => t.userId == order.OrderItems[0].CustomsChannelId.ToString()).FirstOrDefault(); if (user != null) { aliorder.partner = user.alipayAppId; aliorder.out_request_no = order.SubOrderNo ?? "" + order.OrderNo.ToString(); aliorder.trade_no = order.PayTransactionId; //"2019052222001497581037471813";// order.PayTransactionId; aliorder.merchant_customs_code = user.cebCode; aliorder.amount = order.OrderTotal.ToString("f2"); //"0.01";// order.OrderTotal.ToString(".00"); aliorder.customs_place = "tianjin"; aliorder.merchant_customs_name = user.copName; aliorder.is_split = "F"; aliorder.buyer_name = order.BuyerName; //"王江";// order.BuyerName; aliorder.buyer_id_no = order.BuyerIdNumber; //"360403197708222712";// order.BuyerIdNumber; //alipay_reponse = _IAlipayRepository.alipay_update(aliorder, "ujsidc9esjszyov0fc0trsveq733ttvd"); var a = _IAlipayRepository.alipay_get(aliorder, "ujsidc9esjszyov0fc0trsveq733ttvd"); } else { message.MessageCode = "2"; message.ErrorMsg = "没有对应的报关通道"; } } catch (Exception ex) { } } else { var modelstate = BadRequest(ModelState); string returestr = ""; foreach (var item in modelstate.ModelState.Values) { returestr += item.Errors != null ? item.Errors[0].ErrorMessage + "\r\n" : ""; } message.MessageCode = "2"; message.ErrorMsg = returestr; } return(Json(message)); }
public bool PayOrder(AliPayOrder input, out string msg) { try { var payOrder = new PayOrder() { ID = input.ID, Cost = input.Cost, GoodsID = input.GoodsId, GoodsName = input.GoodsName, GoodsType = input.GoodType, PayAppID = AliPayConfig.APPID, PayType = Convert.ToInt32(PayType.AliPay), PayMode = Convert.ToInt32(PayMode.MobileWeb), UId = input.Uid, Remarks = "支付宝手机网页支付", }; var isNewPayOrderSuccess = _purchaseService.GeneratePayOrder(payOrder, out msg); if (!isNewPayOrderSuccess) { return(false); } var options = new AlipayOrderOptions() { out_trade_no = input.ID, seller_id = AliPayConfig.PID, subject = input.GoodsName, total_amount = input.Cost.ToString("0.00") }; _alipayRequest.Wappay(options, out msg); return(true); } catch (Exception e) { LogHelper.Logger.Error(e.Message); msg = e.Message; return(false); } }
public static StringBuilder signBuild_get(AliPayOrder alipayOrder) { if (alipayOrder == null) { return(null); } StringBuilder strBuild = new StringBuilder(); strBuild.Append("_input_charset=" + alipayOrder._input_charset + "&"); //strBuild.Append("amount=" + alipayOrder.amount + "&"); //strBuild.Append("buyer_id_no=" + alipayOrder.buyer_id_no + "&"); //strBuild.Append("buyer_name=" + alipayOrder.buyer_name + "&"); //strBuild.Append("customs_place=" + alipayOrder.customs_place + "&"); //strBuild.Append("is_split=" + alipayOrder.is_split + "&"); //strBuild.Append("merchant_customs_code=" + alipayOrder.merchant_customs_code + "&"); //strBuild.Append("merchant_customs_name=" + alipayOrder.merchant_customs_name + "&"); strBuild.Append("out_request_nos=" + alipayOrder.out_request_no + "&"); strBuild.Append("partner=" + alipayOrder.partner + "&"); strBuild.Append("service=" + alipayOrder.service); //strBuild.Append("trade_no=" + alipayOrder.trade_no); //strBuild.Append("pujughw1hy7aetkwo3y98tqk8jzy2a0d"); return(strBuild); }
/// <summary> /// 查询给支付宝支付报关 /// </summary> /// <param name="order">支付报关实体</param> /// <param name="alipaySec">秘钥</param> /// <returns>支付报关结果</returns> public alipay alipay_get(AliPayOrder order, string alipaySec) { alipay model = new alipay(); order.service = "alipay.overseas.acquire.customs.query"; order._input_charset = "UTF-8"; order.sign_type = "MD5"; order.partner = "2088531118503209"; order.merchant_customs_code = "121096080H"; order.merchant_customs_name = "天津智信通电子商务有限公司"; //order.partner = "2088102177882682";联调测试 StringBuilder strBuild = SignsHelper.signBuild_get(order); try { alipaySec = "ujsidc9esjszyov0fc0trsveq733ttvd"; string signStr = SignsHelper.sign(strBuild, alipaySec); strBuild.Append("&sign=" + signStr); strBuild.Append("&sign_type=MD5"); string urlStr = "https://mapi.alipay.com/gateway.do?" + strBuild.ToString(); //string urlStr = "https://openapi.alipaydev.com/gateway.do?" + strBuild.ToString(); var client = new RestClient(urlStr); var request = new RestRequest(Method.GET); request.AddHeader("cache-control", "no-cache"); IRestResponse re = client.Execute(request);//_input_charset=utf-8&out_request_no=string&partner=2088531118503209&service=alipay.acquire.customs&sign=3c9fa6e2ff865717adb5b227e2d800ea&sign_type=MD5 XmlSerializer serializer = new XmlSerializer(typeof(alipay)); using (StringReader reader = new StringReader(re.Content)) { model = (alipay)serializer.Deserialize(reader); } } catch (Exception ex) { } return(model); }
public IHttpActionResult paycustom([FromBody] Order order) { UserInfo user = new UserInfo(); //报关通道实体 AliPayOrder aliorder = new AliPayOrder(); //支付报关实体 alipay alipay_reponse = new alipay(); wxpay wxpay = new wxpay(); wxpay_re wxpay_re = new wxpay_re(); WxpayViewModel wxpayviewmodel = new WxpayViewModel(); API_Message message = new API_Message(); message.MessageCode = "1"; if (ModelState.IsValid) { try { string userid = order.OrderItems?[0].OrderItemDetails?[0].CustomsChannelId.ToString(); user = _IUserRepository.UserInfos.Where(t => t.userId == (order.OrderItems?[0].OrderItemDetails?[0].CustomsChannelId.ToString() ?? order.OrderItems[0].CustomsChannelId.ToString())).FirstOrDefault(); if (user != null && userid != null) { order.OrderGuid = Guid.NewGuid(); order.api_type = 3;//类型:支付报关 for (int i = 0; i < order.OrderItems.Count; i++) { order.OrderItems[i].ItemGuid = Guid.NewGuid(); } _iEcmOrder.Save_Orders(order);//保存接收order信息 if ((order?.PaymentMethodSystemName).Contains("支付宝")) { aliorder.partner = user.alipayAppId; aliorder.out_request_no = order.SubOrderNo ?? "" + order.OrderNo.ToString(); //aliorder.trade_no = "2019052222001497581037471813";// order.PayTransactionId; aliorder.trade_no = order.PayTransactionId; //"2019052322001491491036394115";// order.PayTransactionId; aliorder.merchant_customs_code = user.ebpCode; // user.cebCode; aliorder.amount = order.OrderTotal.ToString("f2"); //"0.01";// order.OrderTotal.ToString(".00"); aliorder.alipaySec = user.alipaySec; aliorder.customs_place = user?.AlipayPortCode;// user.PortCode;// "tianjin"; aliorder.merchant_customs_name = user.copName; aliorder.is_split = "F"; aliorder.buyer_name = order.BuyerName; // "李晨";// order.BuyerName; aliorder.buyer_id_no = order.BuyerIdNumber;; // "120102199966552141";// order.BuyerIdNumber; _IRabbitMQHelper.Publish <custompayController>(JsonConvert.SerializeObject(aliorder)); if ((user?.AlipayPortCode).ToLower().Contains("tianjin") || (user?.AlipayPortCode).ToLower().Contains("guangzhou")) { aliorder.customs_place = "zongshu";// user?.AlipayPortCode;// user.PortCode;// "tianjin"; _IRabbitMQHelper.Publish_Delay <custompay_zongshuController>(JsonConvert.SerializeObject(aliorder), "custompayController"); } _ILog4netHelper.WriteLog_Info <custompayController>(JsonConvert.SerializeObject(aliorder), null, "aliorder", null); //alipay_reponse = _IAlipayRepository.alipay_update(aliorder, "ujsidc9esjszyov0fc0trsveq733ttvd"); } else if ((order?.PaymentMethodSystemName).Contains("财付通")) { wxpay.appid = user.wxappId; // "wx75732915fa967aca"; wxpay.mch_id = user.wxshopId; // "1536978981"; wxpay.out_trade_no = order.OrderNo; wxpay.transaction_id = order.PayTransactionId; wxpay.customs = user?.WxpayPortCode;// user.PortCode;//"GUANGZHOU_ZS"; wxpay.mch_customs_no = user.copCode; wxpay.cert_type = "IDCARD"; wxpay.cert_id = order?.BuyerIdNumber.ToUpper(); wxpay.name = order.BuyerName; wxpayviewmodel.wxshopId = user.wxshopId; wxpayviewmodel.wxpayCode = user.wxpayCode; wxpayviewmodel.wxappId = user.wxappId; wxpayviewmodel.wxpay = wxpay; _IRabbitMQHelper.Publish <custompayController_wx>(JsonConvert.SerializeObject(wxpayviewmodel)); _ILog4netHelper.WriteLog_Info <custompayController>(JsonConvert.SerializeObject(wxpayviewmodel), null, "wxpayviewmodel", null); } _ILog4netHelper.WriteLog_Info <custompayController>(JsonConvert.SerializeObject(order), null, null, null); } else { message.MessageCode = "2"; message.ErrorMsg = "没有对应的报关通道"; } } catch (Exception ex) { _ILog4netHelper.WriteLog_Error <custompayController>(JsonConvert.SerializeObject(order), null, null, ex); } } else { var modelstate = BadRequest(ModelState); string returestr = ""; foreach (var item in modelstate.ModelState.Values) { returestr += item.Errors != null ? item.Errors[0].ErrorMessage + "\r\n" : ""; } message.MessageCode = "2"; message.ErrorMsg = returestr; } return(Json(message)); }