public async Task <IActionResult> CloseOrder(WeChatPayCloseOrderViewModel viewModel)
        {
            var request = new WeChatPayCloseOrderRequest()
            {
                OutTradeNo = viewModel.OutTradeNo,
            };
            var response = await _client.ExecuteAsync(request);

            ViewData["response"] = response.Body;
            return(View());
        }
Пример #2
0
        public async Task <IActionResult> CloseOrder(WeChatPayCloseOrderViewModel viewModel)
        {
            var request = new WeChatPayCloseOrderRequest
            {
                OutTradeNo = viewModel.OutTradeNo
            };
            var response = await _client.ExecuteAsync(request, _optionsAccessor.Value);

            //ViewData["response"] = response.Body;
            return(Ok(response.Body));
        }
Пример #3
0
        public async Task <OrderResult> Close(Pay_Order order)
        {
            if (order.State != OrderState.Pending)
            {
                // 只有待支付时可关闭订单
                return(new OrderResult
                {
                    Success = false,
                    Error = $"只有未支付的订单可关闭"
                });
            }

            var request = new WeChatPayCloseOrderRequest
            {
                OutTradeNo = order.Order_SN
            };

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

            if (res.ReturnCode == "SUCCESS" && res.ResultCode == "SUCCESS")
            {
                logger.LogDebug($"Wepay Close end with: {order.Id} SUCCESS");
                return(new OrderResult
                {
                    Success = true,
                    Order = OrderService.Close(order, PayType.Wechat)
                });
            }

            logger.LogDebug($"Wepay Close end with: {order.Id} FAIL: {res.ErrCode}:{res.ErrCodeDes}");
            return(new OrderResult
            {
                Success = false,
                Error = $"{res.ErrCode}:{res.ErrCodeDes}"
            });
        }