예제 #1
0
 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();
 }
예제 #2
0
        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)));
        }
예제 #3
0
        /// <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)));
        }