public async Task ExecuteAsync(HttpContext context) { try { var body = (await context.Request.ReadFormAsync()).AsNameValueCollection(); if (body?.Count == 0) { throw new ArgumentNullException(nameof(body)); } var request = new WapPayRequest(); request.AddParameters(new WapPayModel() { Body = body.Get("Body"), OutTradeNo = body.Get("Out_Trade_No"), TotalFee = int.Parse(body.Get("Total_Amount")) }); await context.Response.WriteAsync((await _client.ExecuteAsync(request)).ToJson()); } catch (Exception ex) { context.Response.StatusCode = StatusCodes.Status500InternalServerError; await context.Response.WriteAsync(ex.Message); } context.Response.ContentType = "application/json; charset=UTF-8"; await context.Response.Body.FlushAsync(); }
public async Task <OkObjectResult> WapPay(string Body, string Out_Trade_No, int Total_Amount) { var request = new WapPayRequest(); request.AddParameters(new WapPayModel() { Body = Body, OutTradeNo = Out_Trade_No, TotalFee = Total_Amount }); return(Ok(await _client.ExecuteAsync(request))); }
/// <summary> /// 手机网站支付 /// </summary> /// <returns></returns> public async Task <OkObjectResult> WapPay(string body, string outTradeNo, int totalAmount) { var request = new WapPayRequest(); request.AddParameters(new { Body = body, OutTradeNo = outTradeNo, TotalAmount = totalAmount, Subject = "测试app支付标题" }); return(Ok(await _client.ExecuteAsync(request))); }