Esempio n. 1
0
        public void TestMethod_Auth()
        {
            var credentials = _configuration.GetConfigurationSettings();

            var card = new CreditCard("Visa", "4111000000111111", 10, 2014, "123");
            var transaction = new Transaction(80.25M, "USD", merchantRefId: Guid.NewGuid().ToString("N"));
            var billigAddress = new BillingAddress("FirstName", "LastName", "123 Elm Street", "Beverly Hills", "CA", "90210", "US");
            var shippingAddress = new ShippingAddress("FirstName", "LastName", "123 Elm Street", "Beverly Hills", "CA", "90210", "US");
            var customer = new CustomerInfo("*****@*****.**", "hpcitest1", billigAddress, shippingAddress, "173.32.21.248");
            var orderItem1 = new OrderItem("Item1", "ItemName1", "Item Description 1", "1", 2.00M, false);
            var orderItem2 = new OrderItem("Item2", "ItemName2", "Item Description 2", "1", 1.25M, false);
            var orderItems = new[] {orderItem1, orderItem2};
            var order = new Order("Order:", "Test Order", 4.25M, orderItems);

            var request = new AuthRequest(card, transaction, customer, order);
            var response = _service.Send(_converter, credentials, request);

            Assert.AreEqual(Status.Success, response.Status);
        }
        public void TestCreditCardAuthorizationTransaction()
        {
            var credentials = TestHelper.CreateTestCredentials();
            var creditCard = TestHelper.CreateRandomCreditCard();
            var transactionAmount = TestHelper.CreateRandomTransactionAmount();
            var customerInfo = TestHelper.CreateCustomerInfo();
            var order = TestHelper.CreateRandomOrder();
            var threeDSec = TestHelper.CreateRandomThreeDSec();
            var fraudDetection = TestHelper.CreateRandomFraudDetection();

            var request = new AuthRequest(creditCard, transactionAmount, customerInfo, order, threeDSec, new[] { fraudDetection });
            request.SetRequestCredentials(credentials);

            var dictionary = _converter.ConvertToDictionary(request);

            var elementsCount =
                4 + /* credentials */
                5 + /* creadit card */
                13 + /* transaction */
                3 + /* customer info */
                7 + /* billing address */
                7 + /* shipping address */
                3 + /* order */
                order.OrderItems.Length*6 + /* order items */
                4 + /* 3ds */
                threeDSec.AuthSignComboList.Length + /* 3ds items */
                request.FraudDetection.Length * 2; /* fraud items */

            Assert.AreEqual(elementsCount, dictionary.Count);

            Assert.AreEqual(TestValues.Credentials.ApiVersion, dictionary["apiVersion"]);
            Assert.AreEqual(TestValues.Credentials.ApiType, dictionary["apiType"]);
            Assert.AreEqual(TestValues.Credentials.UserName, dictionary["userName"]);
            Assert.AreEqual(TestValues.Credentials.UserPassKey, dictionary["userPassKey"]);

            AssertAreEqualCreditCardValues(dictionary, "pxyCreditCard.");
            AssertAreEqualTransactionValues(dictionary, "pxyTransaction.");
            AssertAreEqualCustomerValues(dictionary, "pxyCustomerInfo.");
            AssertAreEqualAddressValues(dictionary, "pxyCustomerInfo.billingLocation.");
            AssertAreEqualAddressValues(dictionary, "pxyCustomerInfo.shippingLocation.");
            AssertAreEqualOrderValues(dictionary, "pxyOrder.");

            for (int i = 0; i < TestValues.Order.OrderItems.Length; i++)
            {
                var prefix = string.Format("pxyOrder.orderItems[{0}].", i);
                Assert.AreEqual(TestValues.Order.OrderItems[i].Id, dictionary[prefix + "itemId"]);
                Assert.AreEqual(TestValues.Order.OrderItems[i].Name, dictionary[prefix + "itemName"]);
                Assert.AreEqual(TestValues.Order.OrderItems[i].Description, dictionary[prefix + "itemDescription"]);
                Assert.AreEqual(TestValues.Order.OrderItems[i].Quantity, dictionary[prefix + "itemQuantity"]);
                Assert.AreEqual(TestValues.Order.OrderItems[i].Price.ToString(), dictionary[prefix + "itemPrice"]);
                Assert.AreEqual(TestValues.Order.OrderItems[i].Taxable, dictionary[prefix + "itemTaxable"]);
            }
            
            AssertAreEqualThreeDSecValues(dictionary, "pxyThreeDSecAuth.");

            for (int i = 0; i < TestValues.ThreeDSec.AuthSignComboList.Length; i++)
            {
                var name = string.Format("pxyThreeDSecAuth.authSignComboList[{0}]", i);
                Assert.AreEqual(TestValues.ThreeDSec.AuthSignComboList[i], dictionary[name]);
            }

            for (int i = 0; i < request.FraudDetection.Length; i++)
            {
                var prefix = string.Format("fraudChkParamList[{0}]", i);
                Assert.AreEqual(request.FraudDetection[i].Name, dictionary[prefix + ".name"]);
                Assert.AreEqual(request.FraudDetection[i].Value, dictionary[prefix + ".value"]);
            }
        }