123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.Threading.Tasks;
- using System.Web.UI;
- using WayneCloud.Models.Models;
- namespace Wechat.PayAPI
- {
-
-
-
-
- public class ResultNotify:Notify
- {
- public ResultNotify(Page page):base(page)
- {
- }
- public override async Task ProcessNotify(WxPayConfig config)
- {
- WxPayData notifyData = GetNotifyData();
-
- if (!notifyData.IsSet("transaction_id"))
- {
-
- WxPayData res = new WxPayData();
- res.SetValue("return_code", "FAIL");
- res.SetValue("return_msg", "支付结果中微信订单号不存在");
- Log.Error(this.GetType().ToString(), "The Pay result is error : " + res.ToXml());
- page.Response.Write(res.ToXml());
- page.Response.End();
- }
- string transaction_id = notifyData.GetValue("transaction_id").ToString();
-
- if ((await QueryOrder(transaction_id, null)) == false)
- {
-
- WxPayData res = new WxPayData();
- res.SetValue("return_code", "FAIL");
- res.SetValue("return_msg", "订单查询失败");
- Log.Error(this.GetType().ToString(), "Order query failure : " + res.ToXml());
- page.Response.Write(res.ToXml());
- page.Response.End();
- }
-
- else
- {
- WxPayData res = new WxPayData();
- res.SetValue("return_code", "SUCCESS");
- res.SetValue("return_msg", "OK");
- Log.Info(this.GetType().ToString(), "order query success : " + res.ToXml());
- page.Response.Write(res.ToXml());
- page.Response.End();
- }
- }
-
- private async Task<bool> QueryOrder(string transaction_id, WxPayConfig config)
- {
- WxPayData req = new WxPayData();
- req.SetValue("transaction_id", transaction_id);
- WxPayData res = await WxPayApi.OrderQuery(req, config);
- if (res.GetValue("return_code").ToString() == "SUCCESS" &&
- res.GetValue("result_code").ToString() == "SUCCESS")
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
|