예제 #1
0
        public void TestAuthWithAdvancedFraud()
        {
            authorization auth = new authorization();

            auth.litleTxnId          = 123;
            auth.advancedFraudChecks = new advancedFraudChecksType();
            auth.advancedFraudChecks.threatMetrixSessionId = "800";

            String expectedResult = @"
<authorization id="""" reportGroup="""">
<litleTxnId>123</litleTxnId>
<advancedFraudChecks>
<threatMetrixSessionId>800</threatMetrixSessionId>
</advancedFraudChecks>
</authorization>";

            Assert.AreEqual(expectedResult, auth.Serialize());

            var mock = new Mock <Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsAny <String>(), It.IsAny <Dictionary <String, String> >()))
            .Returns("<litleOnlineResponse version='8.23' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId><fraudResult><advancedFraudResults><deviceReviewStatus>\"ReviewStatus\"</deviceReviewStatus><deviceReputationScore>800</deviceReputationScore></advancedFraudResults></fraudResult></authorizationResponse></litleOnlineResponse>");

            Communications mockedCommunication = mock.Object;

            litle.setCommunication(mockedCommunication);
            authorizationResponse authorizationResponse = litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }
        public void TestAuthWithAdvancedFraud()
        {
            var auth = new authorization();

            auth.orderId             = "123";
            auth.amount              = 10;
            auth.advancedFraudChecks = new advancedFraudChecksType();
            auth.advancedFraudChecks.threatMetrixSessionId = "800";
            auth.advancedFraudChecks.customAttribute1      = "testAttribute1";
            auth.advancedFraudChecks.customAttribute2      = "testAttribute2";
            auth.advancedFraudChecks.customAttribute3      = "testAttribute3";
            auth.advancedFraudChecks.customAttribute4      = "testAttribute4";
            auth.advancedFraudChecks.customAttribute5      = "testAttribute5";


            var expectedResult = @"
<authorization id="""" reportGroup="""">
<orderId>123</orderId>
<amount>10</amount>
<advancedFraudChecks>
<threatMetrixSessionId>800</threatMetrixSessionId>
<customAttribute1>testAttribute1</customAttribute1>
<customAttribute2>testAttribute2</customAttribute2>
<customAttribute3>testAttribute3</customAttribute3>
<customAttribute4>testAttribute4</customAttribute4>
<customAttribute5>testAttribute5</customAttribute5>
</advancedFraudChecks>
</authorization>";
            var test           = auth.Serialize();

            Assert.AreEqual(expectedResult, auth.Serialize());

            var mock = new Mock <Communications>(_memoryStreams);

            mock.Setup(
                Communications => Communications.HttpPost(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Returns(
                "<litleOnlineResponse version='8.23' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><orderId>123</orderId><fraudResult><advancedFraudResults><deviceReviewStatus>\"ReviewStatus\"</deviceReviewStatus><deviceReputationScore>800</deviceReputationScore></advancedFraudResults></fraudResult></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;

            litle.setCommunication(mockedCommunication);
            var authorizationResponse = litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual("123", authorizationResponse.orderId);
        }
        public void TestSimpleAuthWithBillMeLaterRequest()
        {
            var auth = new authorization();

            auth.card               = new cardType();
            auth.card.type          = methodOfPaymentTypeEnum.VI;
            auth.card.number        = "4100000000000001";
            auth.card.expDate       = "1213";
            auth.orderId            = "12344";
            auth.amount             = 2;
            auth.orderSource        = orderSourceType.ecommerce;
            auth.billMeLaterRequest = new billMeLaterRequest();
            auth.billMeLaterRequest.virtualAuthenticationKeyData = "Data";
            auth.billMeLaterRequest.virtualAuthenticationKeyPresenceIndicator = "Presence";

            var expectedResult = @"
<authorization id="""" reportGroup="""">
<orderId>12344</orderId>
<amount>2</amount>
<orderSource>ecommerce</orderSource>
<card>
<type>VI</type>
<number>4100000000000001</number>
<expDate>1213</expDate>
</card>
<billMeLaterRequest>
<virtualAuthenticationKeyPresenceIndicator>Presence</virtualAuthenticationKeyPresenceIndicator>
<virtualAuthenticationKeyData>Data</virtualAuthenticationKeyData>
</billMeLaterRequest>
</authorization>";

            Assert.AreEqual(expectedResult, auth.Serialize());

            var mock = new Mock <Communications>(_memoryStreams);

            mock.Setup(
                Communications =>
                Communications.HttpPost(
                    It.IsRegex(
                        ".*<authorization id=\".*>.*<billMeLaterRequest>\r\n<virtualAuthenticationKeyPresenceIndicator>Presence</virtualAuthenticationKeyPresenceIndicator>\r\n<virtualAuthenticationKeyData>Data</virtualAuthenticationKeyData>\r\n</billMeLaterRequest>.*</authorization>.*",
                        RegexOptions.Singleline), It.IsAny <Dictionary <string, string> >()))
            .Returns(
                "<litleOnlineResponse version='8.14' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;

            litle.setCommunication(mockedCommunication);
            litle.Authorize(auth);

            var authorizationResponse = litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }
        public void testAddAuthorization()
        {
            var authorization = new authorization();
            authorization.reportGroup = "Planets";
            authorization.orderId = "12344";
            authorization.amount = 106;
            authorization.orderSource = orderSourceType.ecommerce;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "4100000000000002";
            card.expDate = "1210";
            authorization.card = card;

            batchRequest.addAuthorization(authorization);

            Assert.AreEqual(1, batchRequest.getNumAuthorization());
            Assert.AreEqual(authorization.amount, batchRequest.getSumOfAuthorization());

            mockLitleFile.Verify(
                litleFile =>
                    litleFile.createRandomFile(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(),
                        mockLitleTime.Object));
            mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, authorization.Serialize()));
        }
        public void TestSimpleAuthWithFraudCheck()
        {
            var auth = new authorization
            {
                card = new cardType
                {
                    type = methodOfPaymentTypeEnum.VI,
                    number = "4100000000000001",
                    expDate = "1213"
                },
                orderId = "12344",
                amount = 2,
                orderSource = orderSourceType.ecommerce,
                cardholderAuthentication = new fraudCheckType {customerIpAddress = "192.168.1.1"}
            };

            const string expectedResult = @"
            <authorization id="""" reportGroup="""">
            <orderId>12344</orderId>
            <amount>2</amount>
            <orderSource>ecommerce</orderSource>
            <card>
            <type>VI</type>
            <number>4100000000000001</number>
            <expDate>1213</expDate>
            </card>
            <cardholderAuthentication>
            <customerIpAddress>192.168.1.1</customerIpAddress>
            </cardholderAuthentication>
            </authorization>";

            Assert.AreEqual(expectedResult, auth.Serialize());

            var mock = new Mock<Communications>();
            mock.Setup(communications => communications.HttpPost(It.IsRegex(".*<authorization id=\".*>.*<customerIpAddress>192.168.1.1</customerIpAddress>.*</authorization>.*", RegexOptions.Singleline), It.IsAny<Dictionary<string, string>>()))
                .Returns("<litleOnlineResponse version='8.14' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            _litle.setCommunication(mockedCommunication);
            _litle.Authorize(auth);

            var authorizationResponse = _litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }
        public void TestSimpleAuthWithBillMeLaterRequest()
        {
            var auth = new authorization
            {
                card = new cardType
                {
                    type = methodOfPaymentTypeEnum.VI,
                    number = "4100000000000001",
                    expDate = "1213"
                },
                orderId = "12344",
                amount = 2,
                orderSource = orderSourceType.ecommerce,
                billMeLaterRequest = new billMeLaterRequest
                {
                    virtualAuthenticationKeyData = "Data",
                    virtualAuthenticationKeyPresenceIndicator = "Presence"
                }
            };

            const string expectedResult = @"
            <authorization id="""" reportGroup="""">
            <orderId>12344</orderId>
            <amount>2</amount>
            <orderSource>ecommerce</orderSource>
            <card>
            <type>VI</type>
            <number>4100000000000001</number>
            <expDate>1213</expDate>
            </card>
            <billMeLaterRequest>
            <virtualAuthenticationKeyPresenceIndicator>Presence</virtualAuthenticationKeyPresenceIndicator>
            <virtualAuthenticationKeyData>Data</virtualAuthenticationKeyData>
            </billMeLaterRequest>
            </authorization>";

            Assert.AreEqual(expectedResult, auth.Serialize());

            var mock = new Mock<Communications>();
            mock.Setup(communications => communications.HttpPost(It.IsRegex(".*<authorization id=\".*>.*<billMeLaterRequest>\r\n<virtualAuthenticationKeyPresenceIndicator>Presence</virtualAuthenticationKeyPresenceIndicator>\r\n<virtualAuthenticationKeyData>Data</virtualAuthenticationKeyData>\r\n</billMeLaterRequest>.*</authorization>.*", RegexOptions.Singleline), It.IsAny<Dictionary<string, string>>()))
                .Returns("<litleOnlineResponse version='8.14' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            _litle.setCommunication(mockedCommunication);
            _litle.Authorize(auth);

            var authorizationResponse = _litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }
        public void TestAuthWithPosCatLevelEnum()
        {
            var auth = new authorization
            {
                pos = new pos{catLevel = posCatLevelEnum.selfservice },
                orderId = "ABC123",
                amount = 98700
            };

            const string expectedResult = @"
            <authorization id="""" reportGroup="""">
            <orderId>ABC123</orderId>
            <amount>98700</amount>
            <pos>
            <catLevel>self service</catLevel>
            </pos>
            </authorization>";

            Assert.AreEqual(expectedResult, auth.Serialize());

            var mock = new Mock<Communications>();
            mock.Setup(communications => communications.HttpPost(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>()))
                .Returns("<litleOnlineResponse version='9.10' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            _litle.setCommunication(mockedCommunication);
            var authorizationResponse = _litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }
        public void TestAuthWithAdvancedFraud()
        {
            var auth = new authorization
            {
                orderId = "123",
                amount = 10,
                advancedFraudChecks = new advancedFraudChecksType
                {
                    threatMetrixSessionId = "800",
                    customAttribute1 = "testAttribute1",
                    customAttribute2 = "testAttribute2",
                    customAttribute3 = "testAttribute3",
                    customAttribute4 = "testAttribute4",
                    customAttribute5 = "testAttribute5"
                }
            };

            const string expectedResult = @"
            <authorization id="""" reportGroup="""">
            <orderId>123</orderId>
            <amount>10</amount>
            <advancedFraudChecks>
            <threatMetrixSessionId>800</threatMetrixSessionId>
            <customAttribute1>testAttribute1</customAttribute1>
            <customAttribute2>testAttribute2</customAttribute2>
            <customAttribute3>testAttribute3</customAttribute3>
            <customAttribute4>testAttribute4</customAttribute4>
            <customAttribute5>testAttribute5</customAttribute5>
            </advancedFraudChecks>
            </authorization>";

            Assert.AreEqual(expectedResult, auth.Serialize());

            var mock = new Mock<Communications>();
            mock.Setup(communications => communications.HttpPost(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>()))
                .Returns("<litleOnlineResponse version='9.10' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><orderId>123</orderId><fraudResult><advancedFraudResults><deviceReviewStatus>\"ReviewStatus\"</deviceReviewStatus><deviceReputationScore>800</deviceReputationScore></advancedFraudResults></fraudResult></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            _litle.setCommunication(mockedCommunication);
            var authorizationResponse = _litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual("123", authorizationResponse.orderId);
        }