Beispiel #1
0
        public void fraudulentCustomerIsDenied()
        {
            var fraudulentCard = PersonRepository.GetCard("987654");
            var transaction = new Operators.Transaction(Test.Amount, fraudulentCard, Test.Installments);
            var order = new AntiFraud.Order(Test.Store, Test.Items, transaction, Test.OrderId);

            // Antifraud step
            var orders = new List<AntiFraud.Order>() { order };
            var request = new AntiFraud.Request(Test.Store.AntiFraudInfo.ApiKey, Test.Store.AntiFraudInfo.LoginToken, orders, "BRA");
            var jsonRequest = JsonConvert.SerializeObject(request);
            var response = ApiResponseMock.MockClearSaleResponse(orders, jsonRequest);
            var allValid = response.All(r => r.AllValid);

            Assert.False(allValid);
        }
Beispiel #2
0
 /// <summary>
 /// Processes the anti-fraud step if necessary.
 /// </summary>
 /// <returns>
 /// True if the sale is authorized by the anti-fraud system or if the store doesnt use the system.
 /// </returns>
 private bool evaluateAntiFraud(IEnumerable <AntiFraud.Item> items, Operators.Transaction transaction, string orderId)
 {
     if (Store.UseAntiFraud)
     {
         var order  = new AntiFraud.Order(Store, items, transaction, orderId);
         var orders = new List <AntiFraud.Order>()
         {
             order
         };
         var request = new AntiFraud.Request(Store.AntiFraudInfo.ApiKey, Store.AntiFraudInfo.LoginToken, orders, "BRA");
         return(RequestManager.MakeAntiFraudRequest(request));
     }
     else
     {
         return(true);
     }
 }
        public void successfullyCreatesAntiFraudRequest()
        {
            // Setup
            var transaction = new Operators.Transaction(Test.Amount, Test.Card, Test.Installments);
            var order       = new AntiFraud.Order(Test.Store, Test.Items, transaction, Test.OrderId);

            var orders = new List <AntiFraud.Order>()
            {
                order
            };
            var request = new AntiFraud.Request(Test.Store.AntiFraudInfo.ApiKey, Test.Store.AntiFraudInfo.LoginToken, orders, "BRA");

            // Assertions
            Assert.Equal("Carlos Key", request.ApiKey);
            Assert.Equal("Carlos Token", request.LoginToken);
            Assert.NotNull(request.Orders.First().ShippingData);
            Assert.NotNull(request.Orders.First().BillingData);
        }
Beispiel #4
0
        public void validRequestIsAuthorized()
        {
            var transaction = new Operators.Transaction(Test.Amount, Test.Card, Test.Installments);
            var order = new AntiFraud.Order(Test.Store, Test.Items, transaction, Test.OrderId);

            // Antifraud step
            var orders = new List<AntiFraud.Order>() { order };
            var req1 = new AntiFraud.Request(Test.Store.AntiFraudInfo.ApiKey, Test.Store.AntiFraudInfo.LoginToken, orders, "BRA");
            var jsonRequest = JsonConvert.SerializeObject(req1);
            var responseAF = ApiResponseMock.MockClearSaleResponse(orders, jsonRequest);
            var allValid = responseAF.All(r => r.AllValid);

            // Operator step
            var req2 = new Operators.Request(transaction, Test.OrderId);
            var responseOP = RequestManager.MakeCieloRequest(req2);

            // Assertions
            Assert.True(allValid);
            Assert.Equal(1, responseOP.Status);
            Assert.Equal("0", responseOP.ReturnCode);
        }