示例#1
0
        /// <summary>
        /// 东方支付退款后台回调
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public string EasiPayRefundBack(NameValueCollection collection)
        {
            try
            {
                #region 写系统Log
                ApplicationEventLog log = new ApplicationEventLog()
                {
                    Source           = "B2C site refund",
                    EventType        = 8,
                    HostName         = "B2C",
                    EventTitle       = "Refund callback",
                    EventMessage     = Charges.BuildStringFromNameValueCollection(collection),
                    LanguageCode     = ConstValue.LanguageCode,
                    CompanyCode      = ConstValue.CompanyCode,
                    StoreCompanyCode = ConstValue.StoreCompanyCode
                };
                CommonDA.CreateApplicationEventLog(log);
                #endregion

                CallbackContext context = new CallbackContext();
                context.PaymentModeId = 111;
                context.ResponseForm  = collection;

                Charges charge = Charges.GetInstance(context);
                charge.UpdateCallbackPayment(context);
                if (charge.VerifySign(context))
                {
                    string      trxContent = Charges.Base64Decode(context.ResponseForm["TRX_CONTENT"]);
                    XmlDocument xmlDoc     = new XmlDocument();
                    xmlDoc.LoadXml(trxContent);
                    string code = xmlDoc.SelectSingleNode("EasipayB2CResponse/ResData/RTN_CODE").InnerText;
                    if (code.Equals("000000"))
                    {
                        string serno         = xmlDoc.SelectSingleNode("EasipayB2CResponse/ResData/REFTRX_SERNO").InnerText;
                        string refundStatus  = xmlDoc.SelectSingleNode("EasipayB2CResponse/ResData/REFUND_STATE").InnerText;
                        bool   bRefundStatus = refundStatus.Equals("S") ? true : false;
                        Refund(serno, bRefundStatus);
                    }
                    return(BuildPaymentCallbackReturnResult(111, true));
                }

                ECommerce.Utility.Logger.WriteLog("返回退款回调失败", "RefundCallback", "CheckRefundResult");
                return(BuildPaymentCallbackReturnResult(111, false));
            }
            catch (Exception ex)
            {
                //系统异常,写日志
                ECommerce.Utility.Logger.WriteLog(string.Format("系统异常,异常信息:{0}!", ex.ToString()), "RefundCallback", "RefundBgCallbackFailure");
                return(BuildPaymentCallbackReturnResult(111, false));
            }
        }