发布:2022/7/4 22:03:33作者:管理员 来源:本站 浏览次数:1165
/// <summary>
/// 微信回调接口
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("WxPayNotifyHanler")]
public async Task<string> WXChatPayNoticeAsync()
{
System.IO.Stream message = Request.Body;
try
{
using (StreamReader sr = new StreamReader(message, Encoding.UTF8))
{
string content1 = await sr.ReadToEndAsync();
WxPayData res = WxPayData.GetNotifyData(content1);
if (res != null) {
string ordecode = res.GetValue("out_trade_no").ToString();
string trade_no = res.GetValue("transaction_id").ToString();
//通信成功
if (res.GetValue("return_code").ToString() == "SUCCESS")
{
DateTime time = DateTime.Now;
//回传
return WxPayData.setXml("SUCCESS", "OK");
}
else
{
//回传
return WxPayData.setXml("FAIL", "交易失败");
}
}
}
}
catch (Exception ex)
{
return WxPayData.setXml("FAIL", "交易失败");
}
//回传
return WxPayData.setXml("FAIL", "交易失败");
}