예제 #1
0
        private void PopulateFraudData(FraudCheckData d, OrderTaskContext context)
        {
            if (context.HccApp.CurrentRequestContext.RoutingContext.HttpContext != null)
            {
                if (context.HccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.UserHostAddress != null)
                {
                    d.IpAddress =
                        context.HccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.UserHostAddress;
                }
            }

            if (context.Order.UserEmail != string.Empty)
            {
                d.EmailAddress = context.Order.UserEmail;
                var parts = d.EmailAddress.Split('@');
                if (parts.Length > 1)
                {
                    d.DomainName = parts[1];
                }
            }

            d.PhoneNumber = context.Order.BillingAddress.Phone;

            foreach (var p in context.HccApp.OrderServices.Transactions.FindForOrder(context.Order.bvin))
            {
                if (p.Action == ActionType.CreditCardInfo)
                {
                    d.CreditCard = p.CreditCard.CardNumber;
                    break;
                }
            }
        }
예제 #2
0
파일: FraudScorer.cs 프로젝트: wncoder/core
        private decimal ScoreSingleRule(FraudCheckData data, FraudRule rule)
        {
            decimal result = 0;

            switch (rule.RuleType)
            {
            case FraudRuleType.CreditCardNumber:
                if (rule.RuleValue == data.CreditCard)
                {
                    result += 7;
                    data.Messages.Add("Credit Card Matched Fraud Rules");
                }
                break;

            case FraudRuleType.DomainName:
                if (rule.RuleValue == data.DomainName)
                {
                    result += 3;
                    data.Messages.Add("Domain Matched Fraud Rules");
                }
                break;

            case FraudRuleType.EmailAddress:
                if (rule.RuleValue == data.EmailAddress)
                {
                    result += 5;
                    data.Messages.Add("Email Address Matched Fraud Rules");
                }
                break;

            case FraudRuleType.IPAddress:
                if (rule.RuleValue == data.IpAddress)
                {
                    result += 1;
                    data.Messages.Add("IP Address Fraud Rules");
                }
                break;

            case FraudRuleType.PhoneNumber:
                if (rule.RuleValue == data.PhoneNumber)
                {
                    result += 3;
                    data.Messages.Add("Phone Number Matched Fraud Rules");
                }
                break;
            }
            return(result);
        }
예제 #3
0
        public override bool Execute(OrderTaskContext context)
        {
            var result = true;

            if (context.Order != null)
            {
                var d = new FraudCheckData();
                PopulateFraudData(d, context);

                var scorer = new FraudScorer(context.HccApp.CurrentRequestContext);

                context.Order.FraudScore = scorer.ScoreData(d);

                if (context.Order.FraudScore >= 5)
                {
                    var s = OrderStatusCode.FindByBvin(OrderStatusCode.OnHold);
                    context.Order.StatusCode = s.Bvin;
                    context.Order.StatusName = s.StatusName;
                    context.HccApp.OrderServices.Orders.Update(context.Order);
                }

                if (d.Messages.Count > 0)
                {
                    var n = new OrderNote();
                    n.IsPublic = false;
                    n.Note     = "Fraud Check Failed";
                    foreach (var m in d.Messages)
                    {
                        n.Note += " | " + m;
                    }
                    context.Order.Notes.Add(n);
                }

                context.HccApp.OrderServices.Orders.Update(context.Order);
            }

            return(result);
        }
예제 #4
0
파일: FraudScorer.cs 프로젝트: wncoder/core
        public decimal ScoreData(FraudCheckData data)
        {
            decimal result = 0;

            var storeRules = _repository.FindForStore(_context.CurrentStore.Id);

            if (storeRules == null)
            {
                return(result);
            }

            foreach (var rule in storeRules)
            {
                result += ScoreSingleRule(data, rule);
            }

            if (result > 10)
            {
                result = 10;
            }

            return(result);
        }