コード例 #1
0
        public async Task <IActionResult> CloseOrder(OrderCloseModel orderClose)
        {
            if (string.IsNullOrWhiteSpace(orderClose.NonceStr))
            {
                orderClose.NonceStr = TenPayV3Util.GetNoncestr();
            }
            orderClose.SignType = "MD5";

            //设置package订单参数
            //  TenPayV3CloseOrderRequestData datainfo

            TenPayV3CloseOrderRequestData datainfo = new TenPayV3CloseOrderRequestData(
                TenPyConfigRead.AppId,
                TenPyConfigRead.MchId,
                orderClose.OutTradeNo,
                TenPyConfigRead.Key,
                orderClose.NonceStr
                );
            var result = await TenPayV3.CloseOrderAsync(datainfo);

            var log = _logger.CreateLogger("关闭订单");

            if (result.return_code == "FAIL")
            {
                log.LogError($"商家订单号(OutTradeNo):{orderClose.OutTradeNo}   通讯标记(return_code):{result.return_code}  {result.return_msg}");
            }
            if (result.result_code == "FAIL")
            {
                log.LogError($"商家订单号(OutTradeNo):{orderClose.OutTradeNo}   业务结果(result_code):{result.result_code}\n{result.err_code}:{result.err_code_des}");
            }
            else if (result.result_code == "SUCCESS")
            {
                log.LogInformation($"商家订单号(OutTradeNo):{orderClose.OutTradeNo}  业务结果(result_code):{result.result_code}");
            }

            //string openid = res.Element("xml").Element("sign").Value;
            return(Ok(new
            {
                respond = result,
                request = orderClose
            }));
        }