Example #1
0
        /// <summary>
        /// 提交支付
        /// </summary>
        /// <param name="order"></param>
        public static void Submit(PayHistory order)
        {
            if (order.OrderType == OrderType.支付)
            {
                if (string.IsNullOrEmpty(order.ProductOrderId))
                {
                    throw new Exception("支付类型订单必须传ProductOrderId");
                }
            }

            Company.CompanyBase company = GetCompany(order.CompanyType);
            try
            {
                company.Submit(order);
            }
            catch (Exception ero)
            {
                if (ero is System.Threading.ThreadAbortException)
                {
                    return;
                }
                CoreHelper.EventLog.Log("提交支付订单时出错:" + ero, true);
                throw ero;
            }
        }
Example #2
0
 /// <summary>
 /// 订单取消,退款
 /// 只要提交成功就一定能成功,特殊情况除外
 /// </summary>
 /// <param name="order"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public static bool RefundOrder(PayHistory order, out string message)
 {
     if (order.Status != OrderStatus.已确认)
     {
         message = "此订单状态为" + order.Status;
         return(false);
     }
     Company.CompanyBase company = GetCompany(order.CompanyType);
     return(company.RefundOrder(order, out message));
 }
Example #3
0
        /// <summary>
        /// 生成订单
        /// </summary>
        /// <param name="amount"></param>
        /// <param name="userId"></param>
        /// <param name="companyType"></param>
        /// <returns></returns>
        public static PayHistory CreateOrder(decimal amount, int userId, CompanyType companyType)
        {
            Company.CompanyBase company = GetCompany(companyType);
            PayHistory          order   = null;

            lock (lockObj)
            {
                order = company.CreateOrder(amount, userId);
            }
            return(order);
        }
Example #4
0
        private static Company.CompanyBase GetCompany(CompanyType companyType)
        {
            #region 实例化
            Company.CompanyBase company = null;
            var dic = new Dictionary <CompanyType, Type>();
            dic.Add(CompanyType.支付宝, typeof(Company.Alipay.AlipayCompany));
            dic.Add(CompanyType.财付通, typeof(Company.Tenpay.TenpayCompany));
            dic.Add(CompanyType.快钱, typeof(OnlinePay.Company.Bill99.Bill99Company));
            dic.Add(CompanyType.连连, typeof(OnlinePay.Company.Lianlian.LianlianCompany));
            dic.Add(CompanyType.汇付天下, typeof(OnlinePay.Company.Chinapnr.ChinapnrCompany));
            dic.Add(CompanyType.微信, typeof(Company.Weixin.WeixinCompany));
            dic.Add(CompanyType.支付宝WAP, typeof(Company.AlipayWap.AlipayWapCompany));
            if (!dic.ContainsKey(companyType))
            {
                throw new Exception("未实现的CompanyType" + companyType);
            }
            company = System.Activator.CreateInstance(dic[companyType]) as Company.CompanyBase;
            return(company);

            #endregion
        }
Example #5
0
 /// <summary>
 /// 接口转向页执行此方法
 /// </summary>
 /// <param name="order"></param>
 public static void Redirect(PayHistory order)
 {
     Company.CompanyBase company = GetCompany(order.CompanyType);
     company.Redirect(order);
 }
Example #6
0
        /// <summary>
        /// 接口回调
        /// </summary>
        /// <param name="companyType"></param>
        /// <param name="context"></param>
        public static string GetNotify(CompanyType companyType, HttpContext context)
        {
            Company.CompanyBase company = GetCompany(companyType);

            return(company.GetNotify(context));
        }