public IHttpActionResult PayMoney([FromBody] Log_Recharge model) { log.Log(LoggerLevels.Debug, "进入API[PayMoney]"); if (model.Amount <= 0) { return(BadRequest("充值金额必须大于0!")); } #region 统一下单 var paymodel = new UnifiedorderRequest { OpenId = WeiChatApplicationContext.Current.WeiChatUser.OpenId, SpbillCreateIp = "8.8.8.8", OutTradeNo = PayUtil.GenerateOutTradeNo(), TotalFee = Convert.ToInt32(model.Amount * 100).ToString(), NonceStr = PayUtil.GetNoncestr(), TradeType = "JSAPI", Body = "购买商品", DeviceInfo = "WEB" }; var result = WeChatApisContext.Current.TenPayV3Api.Unifiedorder(paymodel); var _dict = new Dictionary <string, string> { { "appId", result.AppId }, { "timeStamp", PayUtil.GetTimestamp() }, { "nonceStr", result.NonceStr }, { "package", string.Format("prepay_id={0}", result.PrepayId) }, { "signType", "MD5" } }; _dict.Add("paySign", PayUtil.CreateMd5Sign(_dict, WeChatConfigManager.Current.GetPayConfig().TenPayKey)); #endregion return(Ok(_dict)); }