WechatHelper.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing.Imaging;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using Autofac;
  10. using EMIS.Utility;
  11. using EMIS.ViewModel;
  12. using EMIS.Utility.OnlinePay.WeChat;
  13. using Senparc.Weixin;
  14. using Senparc.Weixin.MP;
  15. using Senparc.Weixin.MP.Entities.Request;
  16. using Senparc.Weixin.MP.MvcExtension;
  17. using Senparc.Weixin.TenPay;
  18. using Senparc.Weixin.TenPay.V3;
  19. using Senparc.Weixin.MP.Containers;
  20. using Senparc.Weixin.MP.AdvancedAPIs;
  21. using System.Configuration;
  22. using Senparc.Weixin.MP.Helpers;
  23. using System.Xml.Linq;
  24. using EMIS.ViewModel.WechatModel;
  25. using Bowin.Common.Log;
  26. namespace EMIS.Utility.OnlinePay
  27. {
  28. public class WechatHelper
  29. {
  30. private static readonly string Token = Config.SenparcWeixinSetting.Token == null ? ConfigurationManager.AppSettings["WeixinToken"] : Config.SenparcWeixinSetting.Token;//与微信公众账号后台的Token设置保持一致,区分大小写。
  31. private static readonly string EncodingAESKey = Config.SenparcWeixinSetting.EncodingAESKey == null ? ConfigurationManager.AppSettings["WeixinEncodingAESKey"] : Config.SenparcWeixinSetting.EncodingAESKey;//与微信公众账号后台的EncodingAESKey设置保持一致,区分大小写。
  32. private static readonly string AppId = Config.SenparcWeixinSetting.WeixinAppId == null ? ConfigurationManager.AppSettings["WeixinAppId"] : Config.SenparcWeixinSetting.WeixinAppId;//与微信公众账号后台的AppId设
  33. private static readonly string TenPayV3_MchId = Config.SenparcWeixinSetting.TenPayV3_MchId == null ? ConfigurationManager.AppSettings["TenPayV3_MchId"] : Config.SenparcWeixinSetting.TenPayV3_MchId;
  34. private static readonly string TenPayV3_Key = Config.SenparcWeixinSetting.TenPayV3_Key == null ? ConfigurationManager.AppSettings["TenPayV3_Key"] : Config.SenparcWeixinSetting.TenPayV3_Key;
  35. private static readonly string TenPayV3_AppId = Config.SenparcWeixinSetting.TenPayV3_AppId == null ? ConfigurationManager.AppSettings["TenPayV3_AppId"] : Config.SenparcWeixinSetting.TenPayV3_AppId;
  36. private static readonly string TenPayV3_AppSecret = Config.SenparcWeixinSetting.TenPayV3_AppSecret == null ? ConfigurationManager.AppSettings["TenPayV3_AppSecret"] : Config.SenparcWeixinSetting.TenPayV3_AppSecret;
  37. private static readonly string TenPayV3_TenpayNotify = Config.SenparcWeixinSetting.TenPayV3_TenpayNotify == null ? ConfigurationManager.AppSettings["TenPayV3_TenpayNotify"] : Config.SenparcWeixinSetting.TenPayV3_TenpayNotify;
  38. private static readonly string TenPayV3_RefundNotify = ConfigurationManager.AppSettings["TenPayV3_RefundNotify"];
  39. #region 公众号基础处理
  40. public static ActionResult EventHandler(PostModel postModel, string echostr)
  41. {
  42. if (CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token))
  43. {
  44. return new ContentResult() { Content = echostr }; //返回随机字符串则表示验证通过
  45. }
  46. else
  47. {
  48. return new ContentResult()
  49. {
  50. Content = "failed:" + postModel.Signature + "," + Senparc.Weixin.MP.CheckSignature.GetSignature(postModel.Timestamp, postModel.Nonce, Token) + "。" +
  51. "如果你在浏览器中看到这句话,说明此地址可以被作为微信公众账号后台的Url,请注意保持Token一致。"
  52. };
  53. }
  54. }
  55. public static ActionResult PostEventHandler(PostModel postModel)
  56. {
  57. if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token))
  58. {
  59. return new ContentResult() { Content = "参数错误!" };
  60. }
  61. postModel.Token = Token;//根据自己后台的设置保持一致
  62. postModel.EncodingAESKey = EncodingAESKey;//根据自己后台的设置保持一致
  63. postModel.AppId = AppId;//根据自己后台的设置保持一致
  64. //自定义MessageHandler,对微信请求的详细判断操作都在这里面。
  65. var messageHandler = new CustomMessageHandler(HttpContext.Current.Request.InputStream, postModel);//接收消息
  66. messageHandler.Execute();//执行微信处理过程
  67. return new FixWeixinBugWeixinResult(messageHandler);//返回结果
  68. }
  69. public static void SendAnnouncement(string title, string content, IList<string> openIDList, string examinationProjectName = null, DateTime? startTime = null)
  70. {
  71. if (openIDList.Count > 0)
  72. {
  73. var templateID = ConfigurationManager.AppSettings["WxMp_NoticeTemplateID"];
  74. var result = AccessTokenContainer.TryGetAccessToken(Config.SenparcWeixinSetting.WeixinAppId, Config.SenparcWeixinSetting.WeixinAppSecret);
  75. foreach (var openID in openIDList)
  76. {
  77. if (openID != null && openID != "null")
  78. {
  79. TemplateApi.SendTemplateMessage(result, openID, templateID, null, new
  80. {
  81. first = new WxTemplateMessageData
  82. {
  83. value = (examinationProjectName != null ? examinationProjectName + "项目" : "") + "通知",
  84. color = "#FF0000"
  85. },
  86. remark = new WxTemplateMessageData
  87. {
  88. value = HttpUtility.HtmlDecode(content)
  89. },
  90. keyword1 = new WxTemplateMessageData
  91. {
  92. value = "广东岭南职业技术学院"
  93. },
  94. keyword2 = new WxTemplateMessageData
  95. {
  96. value = "鉴定中心"
  97. //startTime.HasValue ? startTime.Value.ToString("yyyy年MM月dd日 HH时mm分") : ""
  98. },
  99. keyword3 = new WxTemplateMessageData
  100. {
  101. value = startTime.HasValue ? startTime.Value.ToString("yyyy年MM月dd日 HH时mm分") : ""
  102. },
  103. keyword4 = new WxTemplateMessageData
  104. {
  105. value = title
  106. },
  107. });
  108. }
  109. }
  110. }
  111. }
  112. public static void SendAnnouncementGDCX(string title, string content,string userName, IList<string> openIDList, string examinationProjectName = null, DateTime? startTime = null)
  113. {
  114. if (openIDList.Count > 0)
  115. {
  116. var templateID = ConfigurationManager.AppSettings["WxMp_NoticeTemplateID"];
  117. var result = AccessTokenContainer.TryGetAccessToken(Config.SenparcWeixinSetting.WeixinAppId, Config.SenparcWeixinSetting.WeixinAppSecret);
  118. foreach (var openID in openIDList)
  119. {
  120. if (openID != null && openID != "null")
  121. {
  122. TemplateApi.SendTemplateMessage(result, openID, templateID, null, new
  123. {
  124. first = new WxTemplateMessageData
  125. {
  126. value = title,
  127. color = "#FF0000"
  128. },
  129. keyword1 = new WxTemplateMessageData
  130. {
  131. value = "广东创新科技职业学院"
  132. },
  133. keyword2 = new WxTemplateMessageData
  134. {
  135. value = "继续教育学院"
  136. //startTime.HasValue ? startTime.Value.ToString("yyyy年MM月dd日 HH时mm分") : ""
  137. },
  138. keyword3 = new WxTemplateMessageData
  139. {
  140. value = userName
  141. },
  142. keyword4 = new WxTemplateMessageData
  143. {
  144. value = startTime.HasValue ? startTime.Value.ToString("yyyy年MM月dd日 HH时mm分") : ""
  145. },
  146. remark = new WxTemplateMessageData
  147. {
  148. value = HttpUtility.HtmlDecode(content)
  149. },
  150. });
  151. }
  152. }
  153. }
  154. }
  155. public static JsSdkUiPackage GetJSConfigData(string url)
  156. {
  157. try
  158. {
  159. return JSSDKHelper.GetJsSdkUiPackage(TenPayV3_AppId, TenPayV3_AppSecret, url);
  160. }
  161. catch (Exception ex)
  162. {
  163. LogHelper.WriteLog(LogType.ServiceLog, ex.Message);
  164. throw;
  165. }
  166. }
  167. public static string GetBaseAuthorizeUrl(string url,string state = null)
  168. {
  169. var stateStr = "";
  170. if (state != null)
  171. {
  172. stateStr = state;
  173. }
  174. return OAuthApi.GetAuthorizeUrl(TenPayV3_AppId, url, stateStr, OAuthScope.snsapi_base) + "&v=" + DateTime.Now.ToFileTime().ToString();
  175. }
  176. public static string GetUserInfoAuthorizeUrl(string url,string state = null)
  177. {
  178. var stateStr = "";
  179. if (state != null)
  180. {
  181. stateStr = state;
  182. }
  183. return OAuthApi.GetAuthorizeUrl(TenPayV3_AppId, url, stateStr, OAuthScope.snsapi_userinfo) + "&v=" + DateTime.Now.ToFileTime().ToString();
  184. }
  185. public static string GetOpenID(string code)
  186. {
  187. return OAuthApi.GetAccessToken(TenPayV3_AppId, TenPayV3_AppSecret, code).openid;
  188. }
  189. public static string DownloadMedia(string mediaID)
  190. {
  191. var stream = new MemoryStream();
  192. try
  193. {
  194. MediaApi.Get(TenPayV3_AppId, mediaID, stream);
  195. return FileUploadHelper.UploadFile(stream, ".png");
  196. }
  197. catch (Exception)
  198. {
  199. throw;
  200. }
  201. }
  202. #endregion
  203. #region 支付
  204. public static FileContentResult GetPayQRCode(string productId, decimal fee, string feeTypeName, out string payUrl)
  205. {
  206. string timestamp = TenPayV3Util.GetTimestamp();
  207. string nonceString = TenPayV3Util.GetNoncestr();
  208. int intFee = Convert.ToInt32(Math.Round(fee * 100, 0));
  209. TenPayV3UnifiedorderRequestData orderData = new TenPayV3UnifiedorderRequestData(TenPayV3_AppId, TenPayV3_MchId, feeTypeName, productId, intFee, HttpContext.Current.Request.UserHostAddress,
  210. TenPayV3_TenpayNotify, Senparc.Weixin.TenPay.TenPayV3Type.NATIVE, null, TenPayV3_Key, nonceString);
  211. //TenPayV3UnifiedorderRequestData orderData = new TenPayV3UnifiedorderRequestData(TenPayV3_AppId, TenPayV3_MchId, feeTypeName, productId, 1, HttpContext.Current.Request.UserHostAddress,
  212. // TenPayV3_TenpayNotify, Senparc.Weixin.TenPay.TenPayV3Type.NATIVE, null, TenPayV3_Key, nonceString);
  213. UnifiedorderResult result = TenPayV3.Unifiedorder(orderData);
  214. if (result.return_code == "SUCCESS")
  215. {
  216. var memoryStream = new MemoryStream();
  217. var qrcodeImage = QRCodeHelper.GenerateQRCode(result.code_url);
  218. qrcodeImage.Save(memoryStream, ImageFormat.Png);
  219. payUrl = result.code_url;
  220. return new FileContentResult(memoryStream.GetBuffer(), "image/png");
  221. }
  222. else
  223. {
  224. throw new Exception("生成二维码失败:调用统一下单接口失败。");
  225. }
  226. }
  227. public static JSPayView JsPay(string productId, decimal fee, string feeTypeName, string openId)
  228. {
  229. var result = new JSPayView();
  230. result.AppID = TenPayV3_AppId;
  231. result.TimeStamp = TenPayV3Util.GetTimestamp();
  232. result.NonceStr = TenPayV3Util.GetNoncestr();
  233. int intFee = Convert.ToInt32(Math.Round(fee * 100, 0));
  234. TenPayV3UnifiedorderRequestData orderData = new TenPayV3UnifiedorderRequestData(TenPayV3_AppId, TenPayV3_MchId, feeTypeName, productId, intFee, HttpContext.Current.Request.UserHostAddress,
  235. TenPayV3_TenpayNotify, Senparc.Weixin.TenPay.TenPayV3Type.JSAPI, openId, TenPayV3_Key, result.NonceStr);
  236. UnifiedorderResult orderResult = TenPayV3.Unifiedorder(orderData);
  237. if (orderResult.return_code == "SUCCESS")
  238. {
  239. result.Package = "prepay_id=" + orderResult.prepay_id;
  240. result.PaySign = TenPayV3.GetJsPaySign(TenPayV3_AppId, result.TimeStamp, result.NonceStr, result.Package, TenPayV3_Key);
  241. }
  242. else
  243. {
  244. throw new Exception("支付失败:调用统一下单接口失败。" + orderResult.return_msg);
  245. }
  246. return result;
  247. }
  248. public static bool CloseOrder(string productId)
  249. {
  250. bool isOK = true;
  251. string timestamp = TenPayV3Util.GetTimestamp();
  252. string nonceString = TenPayV3Util.GetNoncestr();
  253. TenPayV3CloseOrderRequestData orderData = new TenPayV3CloseOrderRequestData(TenPayV3_AppId, TenPayV3_MchId, productId, TenPayV3_Key, nonceString);
  254. CloseOrderResult result = TenPayV3.CloseOrder(orderData);
  255. if (result.return_code != "SUCCESS")
  256. {
  257. isOK = false;
  258. //throw new Exception("关闭重复订单失败:" + result.return_msg);
  259. }
  260. else if (result.result_code != "SUCCESS")
  261. {
  262. isOK = false;
  263. //throw new Exception("关闭重复订单失败:" + result.result_msg);
  264. }
  265. return isOK;
  266. }
  267. /// <summary>
  268. /// 接收微信支付返回信息
  269. /// </summary>
  270. /// <returns></returns>
  271. public static PayNotifyView PayNotify()
  272. {
  273. ResponseHandler resHandler = new ResponseHandler(null);
  274. resHandler.Init();
  275. resHandler.SetKey(TenPayV3_Key);
  276. var response = HttpContext.Current.Response;
  277. response.Clear();
  278. //判断签名
  279. if (resHandler.IsTenpaySign())
  280. {
  281. PayNotifyView payNotifyView = new PayNotifyView();
  282. //商户在收到后台通知后根据通知ID向财付通发起验证确认,采用后台系统调用交互模式
  283. payNotifyView.NotifyID = resHandler.GetParameter("notify_id");
  284. //取结果参数做业务处理
  285. payNotifyView.OrderID = resHandler.GetParameter("out_trade_no");
  286. //财付通订单号
  287. payNotifyView.WechatOrderID = resHandler.GetParameter("transaction_id");
  288. //金额,以分为单位
  289. payNotifyView.TotalFee = resHandler.GetParameter("total_fee");
  290. //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
  291. payNotifyView.Discount = resHandler.GetParameter("discount");
  292. //支付结果
  293. payNotifyView.ResultCode = resHandler.GetParameter("result_code");
  294. //范例上有个trade_state参数,估计是旧版接口……
  295. payNotifyView.TradeState = resHandler.GetParameter("trade_state");
  296. //即时到账
  297. if ("SUCCESS".Equals(payNotifyView.ResultCode))
  298. {
  299. return payNotifyView;
  300. }
  301. else
  302. {
  303. string exceptionMessage = "支付失败";
  304. response.Write("<xml><return_code>FAIL</return_code><return_msg>exceptionMessage</return_msg></xml>");
  305. response.End();
  306. throw new Exception(exceptionMessage);
  307. }
  308. }
  309. else
  310. {//md5签名失败
  311. string exceptionMessage = "MD5签名失败:" + resHandler.GetDebugInfo();
  312. response.Write("<xml><return_code>FAIL</return_code><return_msg>exceptionMessage</return_msg></xml>");
  313. response.End();
  314. throw new Exception(exceptionMessage);
  315. }
  316. }
  317. public static ActionResult PayNotifySuccess
  318. {
  319. get
  320. {
  321. return new ContentResult() { Content = "<xml><return_code>SUCCESS</return_code><return_msg>OK</return_msg></xml>", ContentEncoding = Encoding.UTF8 };
  322. }
  323. }
  324. public static ActionResult PayNotifyFail(string errorMessage)
  325. {
  326. return new ContentResult() { Content = "<xml><return_code>FAIL</return_code><return_msg>" + errorMessage + "</return_msg></xml>", ContentEncoding = Encoding.UTF8 };
  327. }
  328. public static OrderQueryResult OrderQuery(string productId)
  329. {
  330. string nonceStr = TenPayV3Util.GetNoncestr();
  331. RequestHandler packageReqHandler = new RequestHandler(null);
  332. //设置package订单参数
  333. var datainfo = new TenPayV3OrderQueryRequestData(TenPayV3_AppId, TenPayV3_MchId, "", nonceStr, productId, TenPayV3_Key);
  334. var result = TenPayV3.OrderQuery(datainfo);
  335. return result;
  336. }
  337. #endregion
  338. #region 退款
  339. public static void Refund(string orderID, decimal totalFee, decimal fee)
  340. {
  341. //totalFee = (decimal)0.01;
  342. //fee = (decimal)0.01;
  343. //orderID = "20190801000019";
  344. if (fee > totalFee)
  345. {
  346. throw new Exception("退款金额不能大于总金额。");
  347. }
  348. string nonceStr = TenPayV3Util.GetNoncestr();
  349. string outTradeNo = orderID;
  350. string outRefundNo = "RN-" + orderID + SystemTime.Now.Ticks;
  351. int totalFeeInt = Convert.ToInt32(Math.Round(totalFee * 100, 0));
  352. int refundFeeInt = Convert.ToInt32(Math.Round(fee * 100, 0));
  353. string opUserId = TenPayV3_MchId;
  354. var notifyUrl = TenPayV3_RefundNotify;
  355. var dataInfo = new TenPayV3RefundRequestData(TenPayV3_AppId, TenPayV3_MchId, TenPayV3_Key,
  356. null, nonceStr, null, outTradeNo, outRefundNo, totalFeeInt, refundFeeInt, opUserId, null, notifyUrl: notifyUrl);
  357. var cert = @"D:\webs\jdks\wechatpay\cert\apiclient_cert.p12";//根据自己的证书位置修改
  358. //var cert = @"H:\surfacepro备份\开发项目\教务管理系统\岭南职业技术学院源码\1544542811_20190802_cert\apiclient_cert.p12";
  359. var password = TenPayV3_MchId;//默认为商户号,建议修改
  360. var result = TenPayV3.Refund(dataInfo, cert, password);
  361. if (result.return_code != "SUCCESS")
  362. {
  363. throw new Exception(result.return_msg);
  364. }
  365. if (result.result_code != "SUCCESS")
  366. {
  367. if (result.err_code == "NOTENOUGH")
  368. {
  369. dataInfo = new TenPayV3RefundRequestData(TenPayV3_AppId, TenPayV3_MchId, TenPayV3_Key,
  370. null, nonceStr, null, outTradeNo, outRefundNo, totalFeeInt, refundFeeInt, opUserId, "REFUND_SOURCE_RECHARGE_FUNDS", notifyUrl: notifyUrl);
  371. result = TenPayV3.Refund(dataInfo, cert, password);
  372. if (result.return_code != "SUCCESS")
  373. {
  374. throw new Exception(result.return_msg);
  375. }
  376. if (result.result_code != "SUCCESS")
  377. {
  378. throw new Exception("(" + result.err_code + ")" + result.err_code_des);
  379. }
  380. }
  381. else
  382. {
  383. throw new Exception("(" + result.err_code + ")" + result.err_code_des);
  384. }
  385. }
  386. }
  387. /// <summary>
  388. /// 退款通知处理
  389. /// </summary>
  390. /// <returns></returns>
  391. public static RefundNodifyView RefundNotify()
  392. {
  393. ResponseHandler resHandler = new ResponseHandler(null);
  394. string return_code = resHandler.GetParameter("return_code");
  395. string return_msg = resHandler.GetParameter("return_msg");
  396. if (return_code == "SUCCESS")
  397. {
  398. string appId = resHandler.GetParameter("appid");
  399. string mch_id = resHandler.GetParameter("mch_id");
  400. string nonce_str = resHandler.GetParameter("nonce_str");
  401. string req_info = resHandler.GetParameter("req_info");
  402. var decodeReqInfo = TenPayV3Util.DecodeRefundReqInfo(req_info, TenPayV3_Key);
  403. var decodeDoc = XDocument.Parse(decodeReqInfo);
  404. //获取接口中需要用到的信息
  405. var refundNodifyView = new RefundNodifyView();
  406. refundNodifyView.WechatOrderID = decodeDoc.Root.Element("transaction_id").Value;
  407. refundNodifyView.OrderID = decodeDoc.Root.Element("out_trade_no").Value;
  408. refundNodifyView.WechatRefundOrderID = decodeDoc.Root.Element("refund_id").Value;
  409. refundNodifyView.RefundOrderID = decodeDoc.Root.Element("out_refund_no").Value;
  410. refundNodifyView.Fee = decimal.Parse(decodeDoc.Root.Element("refund_fee").Value) / 100;
  411. return refundNodifyView;
  412. }
  413. else
  414. {
  415. throw new Exception(return_msg);
  416. }
  417. }
  418. #endregion
  419. public static PayNotifyView SearchWechatOrderStatus()
  420. {
  421. ResponseHandler resHandler = new ResponseHandler(null);
  422. resHandler.Init();
  423. resHandler.SetKey(TenPayV3_Key);
  424. var response = HttpContext.Current.Response;
  425. response.Clear();
  426. //判断签名
  427. if (resHandler.IsTenpaySign())
  428. {
  429. PayNotifyView payNotifyView = new PayNotifyView();
  430. //商户在收到后台通知后根据通知ID向财付通发起验证确认,采用后台系统调用交互模式
  431. payNotifyView.NotifyID = resHandler.GetParameter("notify_id");
  432. //取结果参数做业务处理
  433. payNotifyView.OrderID = resHandler.GetParameter("out_trade_no");
  434. //财付通订单号
  435. payNotifyView.WechatOrderID = resHandler.GetParameter("transaction_id");
  436. //金额,以分为单位
  437. payNotifyView.TotalFee = resHandler.GetParameter("total_fee");
  438. //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
  439. payNotifyView.Discount = resHandler.GetParameter("discount");
  440. //支付结果
  441. payNotifyView.ResultCode = resHandler.GetParameter("result_code");
  442. //范例上有个trade_state参数,估计是旧版接口……
  443. //即时到账
  444. if ("SUCCESS".Equals(payNotifyView.ResultCode))
  445. {
  446. return payNotifyView;
  447. }
  448. else
  449. {
  450. string exceptionMessage = "支付失败";
  451. response.Write("<xml><return_code>FAIL</return_code><return_msg>exceptionMessage</return_msg></xml>");
  452. response.End();
  453. throw new Exception(exceptionMessage);
  454. }
  455. }
  456. else
  457. {//md5签名失败
  458. string exceptionMessage = "MD5签名失败:" + resHandler.GetDebugInfo();
  459. response.Write("<xml><return_code>FAIL</return_code><return_msg>exceptionMessage</return_msg></xml>");
  460. response.End();
  461. throw new Exception(exceptionMessage);
  462. }
  463. }
  464. }
  465. }