コード例 #1
0
        public override string Validate(CreateOrderBuilder order)
        {
            if (order.GetCustomerIdentity() == null)
            {
                Errors += "MISSING VALUE - CustomerIdentity must be set.\n";
            }

            var identityValidator = new IdentityValidator();

            switch (order.GetCountryCode())
            {
            case CountryCode.NONE:
                Errors += "MISSING VALUE - CountryCode is required. Use SetCountryCode().\n";
                break;

            case CountryCode.FI:
            case CountryCode.DK:
            case CountryCode.NO:
            case CountryCode.SE:
                Errors += identityValidator.ValidateNordicIdentity(order);
                break;

            case CountryCode.DE:
                Errors += identityValidator.ValidateDeIdentity(order);
                break;

            case CountryCode.NL:
                Errors += identityValidator.ValidateNlIdentity(order);
                break;

            default:
                Errors += "NOT VALID - Given countrycode does not exist in our system.\n";
                break;
            }

            ValidateRequiredFieldsForOrder(order);
            ValidateOrderRow(order);
            if (order.GetOrderDate() == DateTime.MinValue)
            {
                Errors += "MISSING VALUE - OrderDate is required. Use SetOrderDate().\n";
            }

            if (!String.IsNullOrEmpty(order.GetPeppolId()))
            {
                Errors += ValidatePeppolId(order);
            }

            return(Errors);
        }
コード例 #2
0
        public override string Validate(CreateOrderBuilder order)
        {
            if (order.GetCustomerIdentity() == null)
            {
                Errors += "MISSING VALUE - CustomerIdentity must be set.\n";
            }

            var identityValidator = new IdentityValidator();

            switch (order.GetCountryCode())
            {
                case CountryCode.NONE:
                    Errors += "MISSING VALUE - CountryCode is required. Use SetCountryCode().\n";
                    break;
                case CountryCode.FI:
                case CountryCode.DK:
                case CountryCode.NO:
                case CountryCode.SE:
                    Errors += identityValidator.ValidateNordicIdentity(order);
                    break;
                case CountryCode.DE:
                    Errors += identityValidator.ValidateDeIdentity(order);
                    break;
                case CountryCode.NL:
                    Errors += identityValidator.ValidateNlIdentity(order);
                    break;
                default:
                    Errors += "NOT VALID - Given countrycode does not exist in our system.\n";
                    break;
            }

            ValidateRequiredFieldsForOrder(order);
            ValidateOrderRow(order);
            if (order.GetOrderDate() == DateTime.MinValue)
            {
                Errors += "MISSING VALUE - OrderDate is required. Use SetOrderDate().\n";
            }

            return Errors;
        }
コード例 #3
0
        /// <summary>
        /// ValidateOrder
        /// </summary>
        /// <returns>Error message compilation string</returns>
        public string ValidateOrder()
        {
            var errors = "";
            if (string.IsNullOrEmpty(ReturnUrl))
            {
                errors += "MISSING VALUE - Return url is required, SetReturnUrl(...).\n";
            }

            var validator = new HostedOrderValidator();

            //Check if payment method is EU country, PaymentMethod: INVOICE or PAYMENTPLAN
            var payment = this as PaymentMethodPayment;
            if (payment != null
                && (payment.GetPaymentMethod() == PaymentMethod.INVOICE ||
                    payment.GetPaymentMethod() == PaymentMethod.PAYMENTPLAN))
            {
                switch (CrOrderBuilder.GetCountryCode())
                {
                    case CountryCode.NL:
                        errors += new IdentityValidator().ValidateNlIdentity(CrOrderBuilder);
                        break;
                    case CountryCode.DE:
                        errors += new IdentityValidator().ValidateDeIdentity(CrOrderBuilder);
                        break;
                }
            }

            errors += validator.Validate(CrOrderBuilder);

            return errors;
        }