/// <summary>
        /// PrepareRequest
        /// </summary>
        /// <exception cref="SveaWebPayValidationException"></exception>
        /// <returns>CreateOrderEuRequest</returns>
        public CreateOrderEuRequest PrepareRequest()
        {
            var errors = ValidateOrder();
            if (errors.Length > 0)
            {
                throw new SveaWebPayValidationException(errors);
            }

            var sveaOrder = new CreateOrderEuRequest {Auth = GetPasswordBasedAuthorization()};

            var formatter = new WebServiceRowFormatter<CreateOrderBuilder>(CrOrderBuilder);
            List<OrderRow> formattedOrderRows = formatter.FormatRows();

            // make order rows and put in CreateOrderInformation
            OrderInfo = new CreateOrderInformation
                {
                    CustomerIdentity = CrOrderBuilder.GetSoapPurifiedCustomer(),
                    ClientOrderNumber = CrOrderBuilder.GetClientOrderNumber(),
                    CreatePaymentPlanDetails = CrOrderBuilder.GetCampaignCode() != null
                                                   ? new CreatePaymentPlanDetails
                                                       {
                                                           CampaignCode = CrOrderBuilder.GetCampaignCode(),
                                                           SendAutomaticGiroPaymentForm =
                                                               CrOrderBuilder.GetSendAutomaticGiroPaymentForm()
                                                       }
                                                   : null,
                    OrderDate = CrOrderBuilder.GetOrderDate(),
                    CustomerReference = CrOrderBuilder.GetCustomerReference(),
                    OrderRows = formattedOrderRows.ToArray()
                };

            sveaOrder.CreateOrderInformation = SetOrderType(OrderInfo);

            return sveaOrder;
        }
Exemple #2
0
        private DeliverOrderEuRequest PrepareRequestInternal(bool useIncVatRequestIfPossible)
        {
            var errors = ValidateOrder();

            if (errors.Length > 0)
            {
                throw new SveaWebPayValidationException(errors);
            }

            var formatter = new WebServiceRowFormatter <DeliverOrderBuilder>(_order, useIncVatRequestIfPossible);

            DeliverInvoiceDetails deliverInvoiceDetails = null;

            if (_order.GetOrderType() == CONST.OrderType.INVOICE)
            {
                deliverInvoiceDetails = new DeliverInvoiceDetails
                {
                    InvoiceDistributionType = ConvertInvoiceDistributionType(_order.GetInvoiceDistributionType()),
                    InvoiceIdToCredit       = _order.GetCreditInvoice(),
                    IsCreditInvoice         = _order.GetCreditInvoice().HasValue,
                    NumberOfCreditDays      = _order.GetNumberOfCreditDays(),
                    OrderRows = formatter.FormatRows().ToArray()
                };
            }

            _orderInformation = new DeliverOrderInformation
            {
                DeliverInvoiceDetails = deliverInvoiceDetails,
                OrderType             = ConvertOrderType(_order.GetOrderType()),
                SveaOrderId           = _order.GetOrderId()
            };

            _sveaDeliverOrder = new DeliverOrderEuRequest
            {
                Auth = GetStoreAuthorization(),
                DeliverOrderInformation = _orderInformation
            };

            return(_sveaDeliverOrder);
        }
        /// <summary>
        /// PrepareRequest
        /// </summary>
        /// <exception cref="SveaWebPayValidationException"></exception>
        /// <returns>CreateOrderEuRequest</returns>
        public CreateOrderEuRequest PrepareRequest()
        {
            var errors = ValidateOrder();

            if (errors.Length > 0)
            {
                throw new SveaWebPayValidationException(errors);
            }

            var sveaOrder = new CreateOrderEuRequest {
                Auth = GetPasswordBasedAuthorization()
            };

            var             formatter          = new WebServiceRowFormatter <CreateOrderBuilder>(CrOrderBuilder);
            List <OrderRow> formattedOrderRows = formatter.FormatRows();

            // make order rows and put in CreateOrderInformation
            OrderInfo = new CreateOrderInformation
            {
                CustomerIdentity         = CrOrderBuilder.GetSoapPurifiedCustomer(),
                ClientOrderNumber        = CrOrderBuilder.GetClientOrderNumber(),
                CreatePaymentPlanDetails = CrOrderBuilder.GetCampaignCode() != null
                                                   ? new CreatePaymentPlanDetails
                {
                    CampaignCode = CrOrderBuilder.GetCampaignCode(),
                    SendAutomaticGiroPaymentForm =
                        CrOrderBuilder.GetSendAutomaticGiroPaymentForm()
                }
                                                   : null,
                OrderDate         = CrOrderBuilder.GetOrderDate(),
                CustomerReference = CrOrderBuilder.GetCustomerReference(),
                OrderRows         = formattedOrderRows.ToArray(),
                PeppolId          = CrOrderBuilder.GetPeppolId()
            };

            sveaOrder.CreateOrderInformation = SetOrderType(OrderInfo);

            return(sveaOrder);
        }
        /// <summary>
        /// PrepareRequest
        /// </summary>
        /// <exception cref="SveaWebPayValidationException"></exception>
        /// <returns>SveaRequest</returns>
        public DeliverOrderEuRequest PrepareRequest()
        {
            var errors = ValidateOrder();
            if (errors.Length > 0)
            {
                throw new SveaWebPayValidationException(errors);
            }

            var formatter = new WebServiceRowFormatter<DeliverOrderBuilder>(_order);

            DeliverInvoiceDetails deliverInvoiceDetails = null;
            if (_order.GetOrderType() == OrderType.INVOICE)
            {
                deliverInvoiceDetails = new DeliverInvoiceDetails
                    {
                        InvoiceDistributionType = ConvertInvoiceDistributionType(_order.GetInvoiceDistributionType()),
                        InvoiceIdToCredit = _order.GetCreditInvoice(),
                        IsCreditInvoice = _order.GetCreditInvoice().HasValue,
                        NumberOfCreditDays = _order.GetNumberOfCreditDays(),
                        OrderRows = formatter.FormatRows().ToArray()
                    };
            }

            _orderInformation = new DeliverOrderInformation
                {
                    DeliverInvoiceDetails = deliverInvoiceDetails,
                    OrderType = ConvertOrderType(_order.GetOrderType()),
                    SveaOrderId = _order.GetOrderId()
                };

            _sveaDeliverOrder = new DeliverOrderEuRequest
                {
                    Auth = GetStoreAuthorization(),
                    DeliverOrderInformation = _orderInformation
                };

            return _sveaDeliverOrder;
        }