Kona.Model.Order.ValidateForCheckout C# (CSharp) Method

ValidateForCheckout() public method

public ValidateForCheckout ( ) : void
return void
        public virtual void ValidateForCheckout()
        {
            //Must have 1 or more items
            if (Items.Count <= 0)
                throw new InvalidOperationException("Order must have one or more items");

            //every order must have a shipping address - used for tax calcs
            if (ShippingAddress == null)
                throw new InvalidOperationException("All orders must have a shipping address specified.");

            //make sure there's a payment method
            if (PaymentMethod == null)
                throw new InvalidOperationException("No payment method is set for this order");

            if (PaymentMethod is CreditCard) {
                CreditCard cc = PaymentMethod as CreditCard;

                if (!cc.IsValid())
                    throw new InvalidOperationException("This credit card is invalid. Please check the expiration and card number.");

            }

            if (HasShippableGoods) {

                //All orders with shippable goods must have shipping method
                if (ShippingMethod == null)
                    throw new InvalidOperationException("Must have a shipping method selected when ordering shippable goods");

            }
        }