public RequestDocumentCreationTests()
        {
            _payment = FakePayment.CreatePayment(125m, PaymentType.CreditCard, Guid.NewGuid());
            _payment.Properties[DataCashPaymentGateway.DataCashReferencePropertyName]         = "DataCashReferencePropertyValue";
            _payment.Properties[DataCashPaymentGateway.DataCashAuthenticateCodePropertyName]  = "DataCashAuthenticateCodePropertyValue";
            _payment.Properties[DataCashPaymentGateway.DataCashMerchantReferencePropertyName] = "DataCashMerchantReferencePropertyValue";
            _payment.ProviderTransactionID = "ProviderTransactionIDValue";

            var orderForm = FakeOrderForm.CreateOrderForm();
            var shipment  = new FakeShipment();

            shipment.ShippingAddress = FakeOrderAddress.CreateOrderAddress();

            orderForm.Shipments.Add(shipment);
            orderForm.Payments.Add(_payment);

            _cart = new FakeOrderGroup();
            _cart.Forms.Add(orderForm);

            var _orderGroupCalculatorMock = new Mock <IOrderGroupCalculator>();

            _orderGroupCalculatorMock.Setup(x => x.GetTotal(It.IsAny <IOrderGroup>())).Returns(new Money(125m, Currency.USD));
            var _lineItemCalculatorMock = new Mock <ILineItemCalculator>();

            _lineItemCalculatorMock.Setup(x => x.GetExtendedPrice(It.IsAny <ILineItem>(), It.IsAny <Currency>())).Returns(new Money(115.33m, Currency.USD));

            _subject = new RequestDocumentCreation(_orderGroupCalculatorMock.Object, _lineItemCalculatorMock.Object, new FakeDataCashConfiguration());
        }
 public static FakePayment CreatePayment(decimal amount,
                                         PaymentType paymentType,
                                         Guid paymentMethodId,
                                         string authorizationCode     = "",
                                         string customerName          = "",
                                         string implementationClass   = "",
                                         string paymentMethodName     = "",
                                         string providerTransactionID = "",
                                         string status                = "",
                                         string transactionID         = "",
                                         string transactionType       = "",
                                         string validationCode        = "",
                                         IOrderAddress billingAddress = null,
                                         Hashtable properties         = null)
 {
     return(new FakePayment
     {
         Amount = amount,
         AuthorizationCode = authorizationCode,
         BillingAddress = billingAddress ?? FakeOrderAddress.CreateOrderAddress(),
         CustomerName = customerName,
         ImplementationClass = implementationClass,
         PaymentMethodId = paymentMethodId,
         PaymentMethodName = paymentMethodName,
         PaymentType = paymentType,
         ProviderTransactionID = providerTransactionID,
         Status = status,
         TransactionID = transactionID,
         TransactionType = transactionType,
         ValidationCode = validationCode,
         Properties = properties ?? new Hashtable()
     });
 }
        private IOrderAddress CreateOrderAddress()
        {
            var address = FakeOrderAddress.CreateOrderAddress("FakeAddress", "FakeAddress", "Los Angeles", "90001", "California", "USA");

            address.DaytimePhoneNumber = "99999999";
            return(address);
        }
        public void GetPaymentDetailsType_ShouldReturnCorrectly()
        {
            var itemCode         = "TestCode";
            var itemName         = "TestName";
            var orderNumber      = "PO9999";
            var notifyUrl        = "NotifyURL";
            var itemPrice        = 100m;
            var quantiy          = 1;
            var taxAmount        = 20m;
            var shippingSubTotal = 10m;
            var orderTotal       = itemPrice * quantiy + taxAmount + shippingSubTotal;

            var factory    = new FakeOrderGroupBuilderFactory();
            var orderGroup = new FakeOrderGroup();
            var orderForm  = factory.CreateOrderForm(orderGroup);
            var shipment   = factory.CreateShipment(orderGroup);
            var lineItem   = factory.CreateLineItem(itemCode, orderGroup);

            lineItem.DisplayName = itemName;
            lineItem.Quantity    = quantiy;
            lineItem.PlacedPrice = itemPrice;
            shipment.LineItems.Add(lineItem);

            shipment.ShippingAddress = FakeOrderAddress.CreateOrderAddress();
            orderForm.Shipments.Add(shipment);

            var payment = factory.CreatePayment();

            payment.Amount = orderTotal;
            orderForm.Payments.Add(payment);
            orderGroup.Forms.Add(orderForm);

            _orderGroupCalculatorMock.Setup(s => s.GetTaxTotal(It.IsAny <IOrderGroup>())).Returns(new Money(taxAmount, Currency.USD));
            _orderGroupCalculatorMock.Setup(s => s.GetShippingSubTotal(It.IsAny <IOrderGroup>())).Returns(new Money(shippingSubTotal, Currency.USD));

            var lineItemCalculatorMock = new Mock <ILineItemCalculator>();

            lineItemCalculatorMock.Setup(s => s.GetExtendedPrice(It.IsAny <ILineItem>(), It.IsAny <Currency>())).Returns(new Money(itemPrice, Currency.USD));

            var serviceLocatorMock = new Mock <IServiceLocator>();

            serviceLocatorMock.Setup(s => s.GetInstance <ILineItemCalculator>()).Returns(lineItemCalculatorMock.Object);
            ServiceLocator.SetLocator(serviceLocatorMock.Object);

            var result = _subject.GetPaymentDetailsType(payment, orderGroup, orderNumber, notifyUrl);

            Assert.Equal("Episerver_Cart_EC", result.ButtonSource);
            Assert.Equal(orderNumber, result.InvoiceID);
            Assert.Equal(notifyUrl, result.NotifyURL);
            Assert.Equal(orderTotal.ToString("0.00", CultureInfo.InvariantCulture), result.OrderTotal.value);
            Assert.Equal(shippingSubTotal.ToString("0.00", CultureInfo.InvariantCulture), result.ShippingTotal.value);
            Assert.Equal(0m.ToString("0.00", CultureInfo.InvariantCulture), result.HandlingTotal.value);
            Assert.Equal(taxAmount.ToString("0.00", CultureInfo.InvariantCulture), result.TaxTotal.value);
            Assert.Equal((itemPrice * quantiy).ToString("0.00", CultureInfo.InvariantCulture), result.ItemTotal.value);
            Assert.Equal((itemPrice * quantiy).ToString("0.00", CultureInfo.InvariantCulture), result.PaymentDetailsItem.First().Amount.value);
            Assert.Equal(itemCode, result.PaymentDetailsItem.First().Number);
            Assert.Equal(quantiy, result.PaymentDetailsItem.First().Quantity);
            Assert.Equal(itemName, result.PaymentDetailsItem.First().Name);
        }
Beispiel #5
0
        public void Can_Create_Omnium_OrderAddress()
        {
            var orderAddress = FakeOrderAddress.CreateOrderAddress();

            var omniumOrderAddress = DefaultOmniumOrderFactorySubject.MapOrderAddress(orderAddress);

            var result = CompareOrderAddress(orderAddress, omniumOrderAddress);

            Assert.True(result);
        }
Beispiel #6
0
        public void Can_Create_Omnium_Order_Line()
        {
            var lineItem     = FakeLineItem.CreateLineItem();
            var orderAddress = FakeOrderAddress.CreateOrderAddress();

            var omniumOrderLine = DefaultOmniumOrderFactorySubject.MapOrderLine(lineItem, Market, Currency, orderAddress);

            var result =
                lineItem.LineItemId.ToString().Equals(omniumOrderLine.LineItemId) &&
                lineItem.Code.Equals(omniumOrderLine.Code) &&
                lineItem.DisplayName.Equals(omniumOrderLine.DisplayName) &&
                lineItem.Quantity == omniumOrderLine.Quantity;

            Assert.True(result);
        }
        public void CreateExpressCheckoutReqDetailsType_ShouldReturnCorrectly(TransactionType transType, bool allowChangeAddress, bool allowGuest,
                                                                              PaymentActionCodeType?expectedAction, string expectedAddressOverride, SolutionTypeType?expectedSolutionType, LandingPageType?expectedLandingPageType)
        {
            var payment = new FakePayment();

            payment.TransactionType = transType.ToString();
            payment.BillingAddress  = FakeOrderAddress.CreateOrderAddress();

            var config = new PayPalConfigurationForTest();

            config.Setup(allowChangeAddress, allowGuest);

            var result = _subject.CreateExpressCheckoutReqDetailsType(payment, config);

            Assert.Equal(payment.BillingAddress.Email, result.BuyerEmail);
            Assert.Equal(expectedAction, result.PaymentAction);
            Assert.Equal(expectedAddressOverride, result.AddressOverride);
            Assert.Equal(expectedSolutionType, result.SolutionType);
            Assert.Equal(expectedLandingPageType, result.LandingPage);
        }