public async Task<ActionResult> WePayAsync(WePayReqParam payInfo) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:8115/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // HTTP POST var gizmo = new WePayReqParam { OrderNo = payInfo.OrderNo, ProductName = payInfo.ProductName, CustomerIp="127.0.0.1", TotalFee = payInfo.TotalFee, TradeType = EnumWePayTradeType.NATIVE}; var response = await client.PostAsJsonAsync("api/Payment/CreateWePayRequestParam", gizmo); var resultValue = await response.Content.ReadAsAsync<BizResult<string>>(); if (resultValue.Code == EnumBizCode.Failed) { throw new Exception("微信支付失败"); } ViewBag.OrderId = payInfo.OrderNo; ViewBag.PayAmount = payInfo.TotalFee; ViewBag.PayUrl = resultValue.ReturnObject; return View("WePay"); } }
public BizResult<string> CreateWePayRequestParam(WePayReqParam payInfo) { BizResult<string> biz = new BizResult<string>(); biz.ReturnObject = this._wePay.BuildWePay(payInfo.OrderNo,payInfo.ProductName,payInfo.TotalFee,payInfo.CustomerIp,payInfo.TradeType); ; return biz; }