Пример #1
0
        /// <summary>
        /// 提交支付
        /// </summary>
        /// <param name="order"></param>
        public static void Submit(IPayHistory 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;
            }
        }
Пример #2
0
 /// <summary>
 /// 订单取消,退款
 /// 只要提交成功就一定能成功,特殊情况除外
 /// </summary>
 /// <param name="order"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public static bool RefundOrder(IPayHistory order, out string message)
 {
     if (order.Status != OrderStatus.已确认)
     {
         message = "此订单状态为" + order.Status.Discription();
         return(false);
     }
     Company.CompanyBase company = GetCompany(order.CompanyType);
     return(company.RefundOrder(order, out message));
 }
Пример #3
0
        /// <summary>
        /// 生成订单
        /// </summary>
        /// <param name="amount"></param>
        /// <param name="user"></param>
        /// <param name="companyType"></param>
        /// <returns></returns>
        public static IPayHistory CreateOrder(decimal amount, string user, CompanyType companyType)
        {
            Company.CompanyBase company = GetCompany(companyType);
            IPayHistory         order   = null;

            lock (lockObj)
            {
                order = company.CreateOrder(amount, user);
            }
            return(order);
        }
Пример #4
0
        private static Company.CompanyBase GetCompany(CompanyType companyType)
        {
            #region 实例化
            Company.CompanyBase company = null;
            switch (companyType)
            {
            case CompanyType.支付宝:
                company = new Company.Alipay.AlipayCompany();
                break;

            case CompanyType.财付通:
                company = new Company.Tenpay.TenpayCompany();
                break;

            case CompanyType.银联托管:
                company = new Business.OnlinePay.Company.ChinaPay.ChinaPayCompany();
                break;

            case CompanyType.快钱:
                company = new Business.OnlinePay.Company.Bill99.Bill99Company();
                break;

            case CompanyType.连连:
                company = new Business.OnlinePay.Company.Lianlian.LianlianCompany();
                break;

            case CompanyType.汇付天下:
                company = new Business.OnlinePay.Company.Chinapnr.ChinapnrCompany();
                break;
                //case CompanyType.UMPayBank:
                //    company = new Company.UMpay.UMCompanyBank();
                //    break;
                throw new Exception("错误的CompanyType");
            }

            if (company == null)
            {
                throw new Exception("实例化company错误");
            }
            return(company);

            #endregion
        }
Пример #5
0
 /// <summary>
 /// 接口转向页执行此方法
 /// </summary>
 /// <param name="order"></param>
 public static void Redirect(IPayHistory order)
 {
     Company.CompanyBase company = GetCompany(order.CompanyType);
     company.Redirect(order);
 }
Пример #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));
        }