Пример #1
0
        /// <summary>
        /// Places the order.
        /// </summary>
        public bool FullfilPayment()
        {
            // find selected payment gateway:
            IPaymentOption selectedPayment = null;

            Mediachase.Commerce.Orders.Dto.PaymentMethodDto.PaymentMethodRow paymentMethodRow = null;
            var payments = PaymentManager.GetPaymentMethods("en");

            for (int i = 0; i < PaymentContent.Controls.Count; i++)
            {
                Control control = PaymentContent.Controls[i];

                var radioButton = control.Controls[0] as GlobalRadioButton;
                if (radioButton.Checked)
                {
                    selectedPayment  = control.Controls[2] as IPaymentOption;
                    paymentMethodRow = payments.PaymentMethod[i];
                    break;
                }
            }

            if (selectedPayment == null)
            {
                ErrorManager.GenerateError("Fatal error, system administrator has been notified.");
                return(false);
            }
            try
            {
                var payment = selectedPayment.PreProcess(_cartHelper.OrderForm);
                if (payment != null)
                {
                    payment.PaymentMethodId   = paymentMethodRow.PaymentMethodId;
                    payment.PaymentMethodName = paymentMethodRow.Name;
                    payment.BillingAddressId  = _cartHelper.OrderForm.BillingAddressId;
                    payment.Amount            = _cartHelper.OrderForm.Total;
                    _cartHelper.Cart.OrderForms[0].Payments.Add(payment);
                    // Save changes

                    _cartHelper.Cart.AcceptChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ErrorManager.GenerateError(ex.Message);
                return(false);
            }

            ErrorManager.GenerateError("Please choose a payment method.");
            return(false);
        }
        public void ProcessPayment(IPaymentOption method)
        {
            var cart = CartHelper.Cart;

            if (!cart.OrderForms.Any())
            {
                cart.OrderForms.AddNew();
            }

            var payment = method.PreProcess(cart.OrderForms[0]);

            if (payment == null)
            {
                throw new PreProcessException();
            }

            cart.OrderForms[0].Payments.Add(payment);
            cart.AcceptChanges();

            method.PostProcess(cart.OrderForms[0]);
        }
Пример #3
0
        public void ProcessPayment(IPaymentOption method)
        {
            var cart = _cartHelper(Mediachase.Commerce.Orders.Cart.DefaultName).Cart;

            if (!cart.OrderForms.Any())
            {
                cart.OrderForms.AddNew();
            }

            var payment = method.PreProcess(cart.OrderForms[0]);

            if (payment == null)
            {
                throw new PreProcessException();
            }

            cart.OrderForms[0].Payments.Add(payment);
            cart.AcceptChanges();

            method.PostProcess(cart.OrderForms[0]);
        }
Пример #4
0
        public void ProcessPayment(IPaymentOption method)
        {
            var cart = _cartHelper(Mediachase.Commerce.Orders.Cart.DefaultName).Cart;

            if (!cart.OrderForms.Any())
            {
                cart.OrderForms.AddNew();
            }

            var payment = method.PreProcess(cart.OrderForms[0]);

            if (payment == null)
            {
                throw new PreProcessException();
            }

            cart.OrderForms[0].Payments.Add(payment);
            cart.AcceptChanges();

            method.PostProcess(cart.OrderForms[0]);
        }