private static EntrustPaymentApi CreateEntrustPaymentApi()
        {
            var factory = XDI.Resolve <IHttpClientFactory>();
            var client  = factory.CreateClient("EntrustPaymentApiHttpClient");

            return(new EntrustPaymentApi(client, GlobalConfig.X99bill_EntrustPay_Hehua_MerchantId, GlobalConfig.X99bill_EntrustPay_Hehua_TerminalId));
        }
Beispiel #2
0
        /// <summary>
        /// 初始化TransactionScope类的实例
        /// </summary>
        /// <param name="isolationLevel">事务隔离级别</param>
        public TransactionScope(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
        {
            var db = XDI.Resolve <CPIDbContext>();

            if (db == null)
            {
                _logger.Error(TraceType.DAL.ToString(), CallResultStatus.ERROR.ToString(), $"{nameof(XDI)}.{nameof(XDI.Resolve)}<{nameof(CPIDbContext)}>", "事务TransactionScope初始化失败", "解析CPIDbContext类型的实例失败");
                throw new ArgumentNullException(nameof(db));
            }

            _transaction = db.Database.BeginTransaction(isolationLevel);
            _logger.Trace(TraceType.DAL.ToString(), CallResultStatus.OK.ToString(), SERVICE, $"tx_{_transaction.TransactionId.ToString()}", LogPhase.BEGIN, "开始数据库事务");
        }
Beispiel #3
0
 public Bill99AgreePayInvocation(GatewayCommonRequest request)
 {
     _request         = request;
     _agreePayService = XDI.Resolve <IAgreementPaymentService>();
     _bindInfoService = XDI.Resolve <IAgreePayBankCardBindInfoService>();
 }
 public Bill99AllotAmountInvocation(GatewayCommonRequest request)
 {
     _request = request;
     _service = XDI.Resolve <IAllotAmountService>();
 }
Beispiel #5
0
 public Bill99WithdrawInvocation(GatewayCommonRequest request)
 {
     _request                    = request;
     _withdrawService            = XDI.Resolve <IWithdrawService>();
     _allotAmountWithdrawService = XDI.Resolve <IAllotAmountWithdrawService>();
 }
Beispiel #6
0
        public static IInvocation GetInvocation(GatewayCommonRequest request)
        {
            if (request == null || !request.IsValid)
            {
                return(null);
            }

            String service = $"{typeof(ProxyActivator).FullName}.GetInvocation()";
            String tag     = $"{request.Method}.{request.Version}";

            if (request.Method.IndexOf("cpi.fundout.single.99bill.") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99SinglePayInvocation");
                return(new Bill99SinglePayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.fundout.single.95epay.") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 EPay95SinglePayInvocation");
                return(new EPay95SinglePayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.fundout.single.yeepay.") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 YeePaySinglePayInvocation");
                return(new YeePaySinglePayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.settle.personal.") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99PersonalInvocation");
                return(new Bill99PersonalInvocation(request));
            }

            if (request.Method.IndexOf("cpi.settle.allot.") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99AllotAmountInvocation");
                return(new Bill99AllotAmountInvocation(request));
            }

            if (request.Method.IndexOf("cpi.settle.allotamount.withdraw.") == 0 ||
                request.Method.IndexOf("cpi.settle.withdraw.") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99WithdrawInvocation");
                return(new Bill99WithdrawInvocation(request));
            }

            if (request.Method.IndexOf("cpi.settle.account.") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99AccountInvocation");
                return(new Bill99AccountInvocation(request));
            }

            if (request.Method.IndexOf("cpi.agreepay.apply.99bill") == 0 ||
                request.Method.IndexOf("cpi.agreepay.bindcard.99bill") == 0 ||
                request.Method.IndexOf("cpi.agreepay.pay.99bill") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99AgreePayInvocation");
                return(new Bill99AgreePayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.agreepay.apply.yeepay") == 0 ||
                request.Method.IndexOf("cpi.agreepay.bindcard.yeepay") == 0 ||
                request.Method.IndexOf("cpi.agreepay.pay.yeepay") == 0 ||
                request.Method.IndexOf("cpi.agreepay.refund.yeepay") == 0 ||
                request.Method.IndexOf("cpi.agreepay.payresult.pull.yeepay") == 0 ||
                request.Method.IndexOf("cpi.agreepay.refundresult.pull.yeepay") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99AgreePayInvocation");
                return(new YeePayAgreePayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.entrust.pay.99bill") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99EntrustPayInvocation");
                return(new Bill99EntrustPayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.unified.querystatus") == 0 ||
                request.Method.IndexOf("cpi.unified.querydetail") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 AgreePayInvocation");
                return(new AgreePayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.unified.payresult.pull") == 0)
            {
                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99AgreePayInvocation");
                return(new Bill99AgreePayInvocation(request));
            }

            if (request.Method.IndexOf("cpi.unified.pay") == 0)
            {
                // 根据AppId从数据库中查出默认通道编码,如果没有指定则默认使用快钱
                var appChannelRouteService = XDI.Resolve <IAppChannelRouteService>();
                if (appChannelRouteService == null)
                {
                    _logger.Error(TraceType.ROUTE.ToString(), CallResultStatus.ERROR.ToString(), service, tag, "未能初始化IAppChannelRouteService的实例", null, request);
                    return(null);
                }

                var channelRouteInfo = appChannelRouteService.GetPayChannel(request.AppId);
                request.Method += $".{(channelRouteInfo != null ? channelRouteInfo.ChannelCode : GlobalConfig.DefaultPayChannelCode)}";

                // 确定通道之后取出所有通道的费率,
                // 然后根据当前支付金额算出每个通道的费用,
                // 然后得到费用最小的一个通道,
                // 然后对于这个费用最小的通道,通道费用大于阈值的用代扣,否则用协议支付。

                var paymentRequest = JsonUtil.DeserializeObject <CommonPayRequest>(request.BizContent);
                if (!paymentRequest.Success)
                {
                    _logger.Error(TraceType.ROUTE.ToString(), CallResultStatus.ERROR.ToString(), service, tag, "解析支付金额失败", paymentRequest.FirstException, request);
                    return(null);
                }

                #region 关闭协议支付
                //var payChannelService = XDI.Resolve<IPayChannelService>();
                //var channels = payChannelService.GetAllChannels();
                //if (channels != null && channels.Count() > 0)
                //{
                //    var cheapestChannel = (from ch in channels
                //                           let cost = paymentRequest.Value.GetPayAmount() * ch.PayRate
                //                           orderby cost
                //                           select new
                //                           {
                //                               ch.ChannelCode,
                //                               Cost = cost
                //                           }).FirstOrDefault();

                //    if (cheapestChannel.Cost > GlobalConfig.PayChannelFeeThreshold)
                //    {
                //        _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99EntrustPayInvocation");
                //        return CreateEntrustPayInvocation(cheapestChannel.ChannelCode, request);
                //    }

                //    return CreateAgreePayInvocation(cheapestChannel.ChannelCode, request);
                //}
                #endregion

                _logger.Trace(TraceType.ROUTE.ToString(), CallResultStatus.OK.ToString(), service, tag, LogPhase.ACTION, "创建 Bill99AgreePayInvocation");
                return(CreateEntrustPayInvocation(GlobalConfig.X99BILL_PAYCHANNEL_CODE, request));
            }

            return(null);
        }
        private static HttpClient CreateHttpClient()
        {
            var factory = XDI.Resolve <IHttpClientFactory>();

            return(factory.CreateClient());
        }
Beispiel #8
0
 public EPay95SinglePayInvocation(GatewayCommonRequest request)
 {
     _request = request;
     _service = XDI.Resolve <IEPay95SinglePaymentService>();
 }
Beispiel #9
0
 public Bill99PersonalInvocation(GatewayCommonRequest request)
 {
     _request   = request;
     _service   = XDI.Resolve <IPersonalService>();
     _serviceV1 = XDI.Resolve <IPersonalServiceV1>();
 }
Beispiel #10
0
 protected EFRepository() : this(XDI.Resolve <CPIDbContext>())
 {
 }