Пример #1
0
        public PayNotify GetPayNotify(string xml)
        {
            DataTable dataTable = this.ErrorTable("Notify");
            DataRow   dataRow   = dataTable.NewRow();

            dataRow["OperTime"] = DateTime.Now;
            try
            {
                if (string.IsNullOrEmpty(xml))
                {
                    return(null);
                }
                PayNotify notifyObject = Utils.GetNotifyObject <PayNotify>(xml);
                string    sign         = "";
                if (notifyObject == null || !this.ValidPaySign(notifyObject, out sign))
                {
                    dataTable.Rows.Add(dataRow);
                    IDictionary <string, string> dictionary = new Dictionary <string, string>();
                    dictionary.Add("ErrorMsg", (notifyObject == null) ? "Notify Null" : "Valid pay Sign Error");
                    dictionary.Add("result", xml);
                    WxPayLog.AppendLog(dictionary, sign, "", "签名验证失败", LogType.PayNotify);
                    return(null);
                }
                notifyObject.PayInfo = new PayInfo
                {
                    SignType      = "MD5",
                    Sign          = notifyObject.sign,
                    TradeMode     = 0,
                    BankType      = notifyObject.bank_type,
                    BankBillNo    = "",
                    TotalFee      = (decimal)notifyObject.total_fee / 100m,
                    FeeType       = ((notifyObject.fee_type == "CNY") ? 1 : 0),
                    NotifyId      = "",
                    TransactionId = notifyObject.transaction_id,
                    OutTradeNo    = notifyObject.out_trade_no,
                    TransportFee  = 0m,
                    ProductFee    = 0m,
                    Discount      = 1m,
                    BuyerAlias    = "",
                    Attach        = notifyObject.attach
                };
                return(notifyObject);
            }
            catch (Exception ex)
            {
                IDictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary.Add("result", xml);
                WxPayLog.WriteExceptionLog(ex, dictionary, LogType.Error);
                return(null);
            }
        }