OrderQuery.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web;
  4. namespace LYFZ.WxPayAPI
  5. {
  6. public class OrderQuery
  7. {
  8. /***
  9. * 订单查询完整业务流程逻辑
  10. * @param transaction_id 微信订单号(优先使用)
  11. * @param out_trade_no 商户订单号
  12. * @return 订单查询结果(xml格式)
  13. */
  14. public static string Run(string transaction_id, string out_trade_no)
  15. {
  16. Log.Info("OrderQuery", "OrderQuery is processing...");
  17. WxPayData data = new WxPayData();
  18. if(!string.IsNullOrEmpty(transaction_id))//如果微信订单号存在,则以微信订单号为准
  19. {
  20. data.SetValue("transaction_id", transaction_id);
  21. }
  22. else//微信订单号不存在,才根据商户订单号去查单
  23. {
  24. data.SetValue("out_trade_no", out_trade_no);
  25. }
  26. WxPayData result = WxPayApi.OrderQuery(data);//提交订单查询请求给API,接收返回数据
  27. Log.Info("OrderQuery", "OrderQuery process complete, result : " + result.ToXml());
  28. return result.ToPrintStr();
  29. }
  30. }
  31. }