又为大家带来简单的c#后台支付结果回调方法,首先还是要去微信官网下载模板(WxPayAPI),将模板(WxPayAPI)添加到服务器上,然后在打开WxPayAPI项目中的example文件下的
NativeNotifyPage.aspx打开网页中的代码页如图:
将以下代码加入进去就能完成:
public partial class NativeNotifyPage : System.Web.UI.Page { public static string wxJsApiParam { get; set; } //前段显示 public string return_result = ""; protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "text/plain"; Response.Write("Hello World"); LogHelper.WriteLog(typeof(NativeNotifyPage), "可以运行1-1"); String xmlData = getPostStr();//获取请求数据 if (xmlData == "") { } else { var dic = new Dictionary<string, string> { { "return_code", "SUCCESS"}, { "return_msg","OK"} }; var sb = new StringBuilder(); sb.Append("<xml>"); foreach (var d in dic) { sb.Append("<" + d.Key + ">" + d.Value + "</" + d.Key + ">"); } sb.Append("</xml>"); //把数据重新返回给客户端 DataSet ds = new DataSet(); StringReader stram = new StringReader(xmlData); XmlTextReader datareader = new XmlTextReader(stram); ds.ReadXml(datareader); if (ds.Tables[0].Rows[0]["return_code"].ToString() == "SUCCESS") { LogHelper.WriteLog(typeof(NativeNotifyPage), "数据能返回"); string wx_appid = "";//