コード例 #1
0
        public static PayExAddress OrderAddress(Cart cart, PaymentInformation payment, InitializeResult result)
        {
            PayExAddress payexAddress = new PayExAddress(result.OrderRef.ToString());

            if (cart == null || cart.OrderForms == null || cart.OrderForms.Count == 0)
                return payexAddress;

            OrderForm orderForm = cart.OrderForms[0];

            OrderAddress billingAddress = cart.OrderAddresses.ToArray().FirstOrDefault(x => x.Name == orderForm.BillingAddressId);
            if (billingAddress != null)
                payexAddress.BillingAddress.Populate(billingAddress);

            if (orderForm.Shipments != null && orderForm.Shipments.Count > 0 && orderForm.Shipments[0] != null)
            {
                OrderAddress shippingAddress = cart.OrderAddresses.ToArray().FirstOrDefault(x => x.Name == orderForm.Shipments[0].ShippingAddressId);
                if (shippingAddress != null)
                    payexAddress.ShippingAddress.Populate(shippingAddress);
            }

            return payexAddress;
        }
コード例 #2
0
        private void AddOrderLineItems(Cart cart, PaymentInformation payment, InitializeResult initializeResult)
        {
            Log.InfoFormat("Calling AddOrderLineItems for cart with ID:{0}. PaymentInformation:{1}. InitializeResult:{2}", cart.Id, payment, initializeResult);

            List<OrderLine> orderlines = CartHelper.OrderLines(cart, payment, initializeResult);
            foreach (OrderLine orderline in orderlines)
            {
                string hash = _hasher.Create(_payExSettings.AccountNumber, orderline, _payExSettings.EncryptionKey);
                string result = _orderFacade.AddOrderLine(_payExSettings.AccountNumber, orderline, hash);

                Log.InfoFormat("Added OrderLineItem for cart with ID:{0}. OrderLine:{1}. Result:{2}",
                    cart.Id, orderline, result);
            }
        }
コード例 #3
0
        private void AddOrderAddress(Cart cart, PaymentInformation payment, InitializeResult initializeResult)
        {
            Log.InfoFormat("Calling AddOrderAddress for cart with ID:{0}. PaymentInformation:{1}. InitializeResult:{2}", cart.Id, payment, initializeResult);

            PayExAddress address = CartHelper.OrderAddress(cart, payment, initializeResult);
            string hash = _hasher.Create(_payExSettings.AccountNumber, address, _payExSettings.EncryptionKey);
            string xmlResult = _orderFacade.AddOrderAddress(_payExSettings.AccountNumber, address, hash);

            Log.InfoFormat("Finished calling AddOrderAddress for cart with ID:{0}. PaymentInformation:{1}. InitializeResult:{2}. Result:{3}",
                cart.Id, payment, initializeResult, xmlResult);
        }
コード例 #4
0
        public static List<OrderLine> OrderLines(Cart cart, PaymentInformation payment, InitializeResult result)
        {
            List<OrderLine> orderLines = new List<OrderLine>();
            if (cart == null || cart.OrderForms == null || cart.OrderForms.Count == 0)
                return orderLines;

            OrderForm orderForm = cart.OrderForms[0];
            if (orderForm == null || orderForm.LineItems == null || orderForm.LineItems.Count == 0)
                return orderLines;

            foreach (LineItem lineItem in orderForm.LineItems)
            {
                orderLines.Add(new OrderLine(result.OrderRef.ToString(), lineItem.CatalogEntryId, lineItem.DisplayName, (int)lineItem.Quantity,
                    lineItem.ExtendedPrice.RoundToInt(), GetVatAmount(lineItem), GetVatPercentage(lineItem)));
            }

            decimal shippingVatPercentage = GetShippingVatPercentage();
            foreach (Shipment shipment in orderForm.Shipments)
            {
                decimal shippingVatAmount = cart.ShippingTotal * (shippingVatPercentage / 100);
                orderLines.Add(new OrderLine(result.OrderRef.ToString(), string.Empty, GetShippingMethodName(shipment), 1,
                    cart.ShippingTotal.RoundToInt(), shippingVatAmount, shippingVatPercentage));
            }
            return orderLines;
        }
コード例 #5
0
        private void AddOrderLineItems(Cart cart, PaymentInformation payment, InitializeResult initializeResult)
        {
            Log.Info($"Calling AddOrderLineItems for cart with ID:{cart.Id}. PaymentInformation:{payment}. InitializeResult:{initializeResult}");

            var orderlines = CartHelper.OrderLines(cart, payment, initializeResult);
            foreach (var orderline in orderlines)
            {
                var hash = _hasher.Create(_payExSettings.AccountNumber, orderline, _payExSettings.EncryptionKey);
                var result = _orderFacade.AddOrderLine(_payExSettings.AccountNumber, orderline, hash);

                Log.Info($"Added OrderLineItem for cart with ID:{cart.Id}. OrderLine:{orderline}. Result:{result}");
            }
        }
コード例 #6
0
        private void AddOrderAddress(Cart cart, PaymentInformation payment, InitializeResult initializeResult)
        {
            Log.Info($"Calling AddOrderAddress for cart with ID:{cart.Id}. PaymentInformation:{payment}. InitializeResult:{initializeResult}");

            var address = CartHelper.OrderAddress(cart, payment, initializeResult);
            var hash = _hasher.Create(_payExSettings.AccountNumber, address, _payExSettings.EncryptionKey);
            var xmlResult = _orderFacade.AddOrderAddress(_payExSettings.AccountNumber, address, hash);

            Log.Info($"Finished calling AddOrderAddress for cart with ID:{cart.Id}. PaymentInformation:{payment}. InitializeResult:{initializeResult}. Result:{xmlResult}");
        }