Exemple #1
0
        /// <summary>
        /// 退款(航旅版)
        /// </summary>
        /// <param name="request">退款请求参数</param>
        /// <returns>退款申请结果</returns>
        public static RefundResult Refund(RefundRequest request)
        {
            RefundResult refundResult = new RefundResult();
            var          config       = request.Config;
            Submit       submit       = new Submit(config);
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>
            {
                { "partner", config.GetPid() },
                { "_input_charset", Config.InputCharset.ToLower() },
                { "service", "refund_fastpay_by_platform_nopwd" },
                { "notify_url", request.NotifyUrl },
                { "batch_no", request.BatchNo },
                { "refund_date", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") },
                { "batch_num", request.BatchNum.ToString() },
                { "detail_data", request.ToString() }
            };

            string requestStr;
            var    responseStr = submit.BuildRequest(sParaTemp, out requestStr);

            refundResult.RequestStr  = requestStr;
            refundResult.ResponseStr = responseStr;
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(responseStr);
                var selectSingleNode = xmlDoc.SelectSingleNode("/alipay/is_success");
                if (selectSingleNode != null)
                {
                    string strXmlResponse = selectSingleNode.InnerText;
                    refundResult.IsSuccess = strXmlResponse;
                    if (strXmlResponse == "T")
                    {
                        return(refundResult);
                    }
                    else
                    {
                        var singleNode = xmlDoc.SelectSingleNode("/alipay/error");
                        if (singleNode != null)
                        {
                            refundResult.Message = singleNode.InnerText;
                            return(refundResult);
                        }
                        else
                        {
                            refundResult.Message = "/alipay/error节点为空";
                            return(refundResult);
                        }
                    }
                }
                else
                {
                    refundResult.Message = "/alipay/is_success节点为空";
                    return(refundResult);
                }
            }
            catch (Exception exp)
            {
                refundResult.Message = exp.Message;
                return(refundResult);
            }
        }