예제 #1
0
        // 刷卡支付
        public async Task <WeChatPayMicroPayResponse> MicroPay(PayRequest request)
        {
            var order = orderService.GetByRef(request.Id);
            var req   = new WeChatPayMicroPayRequest
            {
                OutTradeNo     = order.Order_SN,
                Body           = order.Name,
                TotalFee       = (int)(order.Pay_Money * 100),
                SpBillCreateIp = App.Context.GetClientIp(),
                AuthCode       = request.AuthCode
            };

            return(await client.ExecuteAsync(req, options.Value));
        }
        public async Task <IActionResult> MicroPay(WeChatPayMicroPayViewModel viewModel)
        {
            var request = new WeChatPayMicroPayRequest()
            {
                Body           = viewModel.Body,
                OutTradeNo     = viewModel.OutTradeNo,
                TotalFee       = viewModel.TotalFee,
                SpbillCreateIp = viewModel.SpbillCreateIp,
                AuthCode       = viewModel.AuthCode
            };
            var response = await _client.ExecuteAsync(request);

            ViewData["response"] = response.Body;
            return(View());
        }
예제 #3
0
        public async Task <IActionResult> MicroPay(WeChatPayMicroPayViewModel viewModel)
        {
            var request = new WeChatPayMicroPayRequest
            {
                Body           = viewModel.Body,
                OutTradeNo     = viewModel.OutTradeNo,
                TotalFee       = viewModel.TotalFee,
                SpBillCreateIp = viewModel.SpBillCreateIp,
                AuthCode       = viewModel.AuthCode
            };
            var response = await _client.ExecuteAsync(request, _optionsAccessor.Value);

            // ViewData["response"] = response.Body;
            return(Ok(response.Body));
        }
예제 #4
0
        // 刷卡支付
        public async Task <OrderResult> MicroPay(PayRequest request)
        {
            var order = OrderService.Get(request.Id);
            var req   = new WeChatPayMicroPayRequest
            {
                OutTradeNo     = order.Order_SN,
                Body           = order.Name,
                TotalFee       = (int)(order.Order_Money * 100),
                SpBillCreateIp = App.Context.GetClientIp(),
                AuthCode       = request.AuthCode
            };

            logger.LogDebug($"Wepay MicroPay begin with: {request.Id}");
            var res = await client.ExecuteAsync(req, options.Value);

            if (res.ReturnCode == "SUCCESS" && res.ResultCode == "SUCCESS")
            {
                logger.LogDebug($"Wepay MicroPay end with: {request.Id} SUCCESS");
                return(new OrderResult
                {
                    Success = true,
                    Order = OrderService.Paidup(
                        order,
                        res.TransactionId,
                        (decimal)(res.TotalFee / 100.0),
                        res.TimeEnd,
                        PayType.Wechat
                        )
                });
            }

            logger.LogDebug($"Wepay MicroPay end with: {request.Id} Fail: {res.ErrCode}:{res.ErrCodeDes}");
            return(new OrderResult
            {
                Success = false,
                Error = $"{res.ErrCode}:{res.ErrCodeDes}"
            });
        }
예제 #5
0
        public async Task <IActionResult> MicroPay(string out_trade_no, int total_fee, string body, string spbill_create_ip, string auth_code)
        {
            var request = new WeChatPayMicroPayRequest
            {
                Body           = body,
                OutTradeNo     = out_trade_no,
                TotalFee       = total_fee,
                SpbillCreateIp = spbill_create_ip,
                AuthCode       = auth_code
            };
            var response = await _client.ExecuteAsync(request);

            ResponseModel responseModel = new ResponseModel()
            {
                code = HTTPResponseCode.PartialContent,
                data = response.Body
            };

            Dictionary <string, string> result = new Dictionary <string, string>();

            result.Add("return_code", response.ReturnCode);
            result.Add("return_msg", response.ReturnMsg);

            if (response.ReturnCode == "SUCCESS" && response.ResultCode == "SUCCESS")
            {
                responseModel.code = HTTPResponseCode.Successful;
            }
            else
            {
                responseModel.code = HTTPResponseCode.BadRequest;
                result.Add("err_code", response.ErrCode);
                result.Add("err_code_des", response.ErrCodeDes);
            }
            responseModel.message = JsonConvert.SerializeObject(result);
            return(Json(responseModel));
        }
예제 #6
0
        public async Task <WeChatPayMicroPayResponse> MicroPay([FromQuery] WeChatSignSettings weChatSignSettings, [FromBody] WeChatPayMicroPayRequest microPayRequest)
        {
            try
            {
                WeChatPayMicroPayResponse result = await _weChatPayClient.MicroPay(weChatSignSettings, microPayRequest);

                WeChatPayReverseResponse a = await _weChatPayClient.Reverse(weChatSignSettings, new WeChatPayReverseRequest()
                {
                    OutTradeNo = result.OutTradeNo,
                    SubMchId   = result.SubMchId,
                });

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }