Ejemplo n.º 1
0
        /// <summary>
        /// 微信退支付解密结果
        /// </summary>
        /// <param name="xml">xml</param>
        /// <returns>微信退支付解密结果</returns>
        public static RefundPayNotifyResult ConvertToRefundPayNotifyResult(string xml)
        {
            RefundPayNotifyResult refundPayNotifyResult = new RefundPayNotifyResult();
            XElement doc          = XElement.Parse(xml);
            var      refundStatus = doc.Element("refund_status").GetString();

            if (refundStatus.Trim() == "SUCCESS")
            {
                refundPayNotifyResult.IsSuccess           = refundStatus;
                refundPayNotifyResult.TransactionId       = doc.Element("transaction_id").GetString();
                refundPayNotifyResult.OutTradeNo          = doc.Element("out_trade_no").GetString();
                refundPayNotifyResult.RefundId            = doc.Element("refund_id").GetString();
                refundPayNotifyResult.OutRefundNo         = doc.Element("out_refund_no").GetString();
                refundPayNotifyResult.TotalFee            = doc.Element("total_fee").GetInt();
                refundPayNotifyResult.RefundFee           = doc.Element("refund_fee").GetInt();
                refundPayNotifyResult.SettlementRefundFee = doc.Element("settlement_refund_fee").GetInt();
                refundPayNotifyResult.SuccessTime         = doc.Element("success_time").GetString();
                refundPayNotifyResult.RefundRecvAccout    = doc.Element("refund_recv_accout").GetString();
                refundPayNotifyResult.RefundAccount       = doc.Element("refund_account").GetString();
                refundPayNotifyResult.RefundRequestSource = doc.Element("refund_request_source").GetString();
            }
            else
            {
                refundPayNotifyResult.IsSuccess = refundStatus;
                refundPayNotifyResult.Message   = doc.Element("refund_status").GetString();
            }
            return(refundPayNotifyResult);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 退款通知结果解析
        /// </summary>
        /// <param name="xml">xml</param>
        /// <param name="config">config</param>
        /// <returns>退款结果</returns>
        public static RefundPayNotifyResult RefundPayNotify(string xml, Config config)
        {
            RefundPayNotifyResult refundPayNotifyResult = new RefundPayNotifyResult();
            var reqInfo = TenpayUtil.GetRefunPayNotifyReqInfo(xml);

            if (reqInfo.Key != null)
            {
                var stringA    = Security.Encrypt32(config.GetKey()).ToLower();
                var reqInfoXml = Security.AesDecrypt(reqInfo.Key, stringA);
                refundPayNotifyResult = TenpayUtil.ConvertToRefundPayNotifyResult(reqInfoXml);
            }
            else
            {
                refundPayNotifyResult.IsSuccess = "CHANGE";
                refundPayNotifyResult.Message   = reqInfo.Value;
            }
            return(refundPayNotifyResult);
        }