Ejemplo n.º 1
0
        private void AddPaymentToOrder(ICart cart, Guid selectedPaymentGuid)
        {
            if (cart.GetFirstForm().Payments.Any())
            {
                // should maybe clean up in the cart here
            }

            var selectedPaymentMethod =
                PaymentManager.GetPaymentMethod(selectedPaymentGuid).PaymentMethod.First();

            var payment = _orderGroupFactory.CreatePayment(cart);

            // check if str "soliciting" still works
            payment.PaymentMethodId = selectedPaymentMethod.PaymentMethodId;
            //payment.PaymentType = PaymentType.Other;
            payment.PaymentMethodName = selectedPaymentMethod.Name;

            // check this thing with "classname"/PaymentType as string

            // usless - crash, doesn't support "Serializable"
            //var type = PaymentTransactionTypeManager.GetPaymentTransactionType((Payment)payment);

            // this one... but not really useful
            var className = selectedPaymentMethod.ClassName;

            // it's a string (as we see it in "Adv" when creating options & methods)

            // ...we also have - cart.GetTotal(_orderGroupCalculator)
            payment.Amount = _orderGroupCalculator.GetTotal(cart).Amount; // need a debug here

            cart.AddPayment(payment);
            // could add payment.BillingAddress = theAddress ... if we had it here
        }
Ejemplo n.º 2
0
        public ActionResult SimulatePurchase(PaymentDemoViewModel viewModel)
        {
            var cart = _orderRepository.LoadOrCreateCart <ICart>(CustomerContext.Current.CurrentContactId, "Default");

            cart.GetFirstShipment().ShippingMethodId = viewModel.SelectedShippingMethodId;

            var primaryPayment = _orderGroupFactory.CreatePayment(cart);

            primaryPayment.PaymentMethodId   = viewModel.SelectedPaymentId;
            primaryPayment.Amount            = _orderGroupCalculator.GetTotal(cart).Amount;
            primaryPayment.PaymentMethodName = PaymentManager.GetPaymentMethod(viewModel.SelectedPaymentId).PaymentMethod[0].Name;

            if (viewModel.UseGiftCard)
            {
                var giftMethod  = PaymentManager.GetPaymentMethodBySystemName("GiftCard", ContentLanguage.PreferredCulture.Name);
                var giftPayment = _orderGroupFactory.CreatePayment(cart);
                giftPayment.PaymentMethodId   = giftMethod.PaymentMethod[0].PaymentMethodId;
                giftPayment.Amount            = viewModel.GiftCardDebitAmt;
                giftPayment.ValidationCode    = viewModel.RedemtionCode;
                giftPayment.PaymentMethodName = giftMethod.PaymentMethod[0].Name;

                PaymentProcessingResult giftPayResult = _paymentProcessor.ProcessPayment(cart, giftPayment, cart.GetFirstShipment());
                if (giftPayResult.IsSuccessful)
                {
                    primaryPayment.Amount -= giftPayment.Amount;
                    cart.AddPayment(giftPayment);
                }
                viewModel.GiftInfoMessage = giftPayResult.Message;
            }

            PaymentProcessingResult payResult = _paymentProcessor.ProcessPayment(cart, primaryPayment, cart.GetFirstShipment());

            if (payResult.IsSuccessful)
            {
                cart.AddPayment(primaryPayment);
                _orderRepository.SaveAsPurchaseOrder(cart);
                _orderRepository.Delete(cart.OrderLink);
            }
            viewModel.MessageOutput = payResult.Message;

            InitializeModel(viewModel);

            return(View("Index", viewModel));
        }
Ejemplo n.º 3
0
        public override IPayment CreatePayment(decimal amount, IOrderGroup orderGroup)
        {
            var payment = _orderGroupFactory.CreatePayment(orderGroup);

            payment.PaymentMethodId   = PaymentMethodId;
            payment.PaymentMethodName = "BudgetPayment";
            payment.Amount            = amount;
            payment.Status            = PaymentStatus.Pending.ToString();
            payment.TransactionType   = TransactionType.Authorization.ToString();
            return(payment);
        }
Ejemplo n.º 4
0
        public override IPayment CreatePayment(decimal amount, IOrderGroup orderGroup)
        {
            var payment = _orderGroupFactory.CreatePayment(orderGroup);

            payment.Properties.Add("GiftCardId", SelectedGiftCardId);
            payment.PaymentMethodId   = PaymentMethodId;
            payment.PaymentMethodName = "GiftCardPayment";
            payment.Amount            = amount;
            payment.Status            = PaymentStatus.Pending.ToString();
            payment.TransactionType   = TransactionType.Authorization.ToString();
            return(payment);
        }
Ejemplo n.º 5
0
        protected virtual IPayment CreatePayment(
            IPurchaseOrder purchaseOrder,
            CustomerContact customerContact,
            SaleViewModel kachingSale,
            decimal amount)
        {
            IPayment payment = _orderGroupFactory.CreatePayment(purchaseOrder);

            payment.Amount          = amount;
            payment.CustomerName    = kachingSale.Summary.Customer?.Name;
            payment.Status          = PaymentStatus.Processed.ToString();
            payment.TransactionType = TransactionType.Sale.ToString();
            payment.PaymentType     = PaymentType.Other;

            return(payment);
        }
Ejemplo n.º 6
0
        private IPayment CreateQuickBuyPayment(QuickBuyModel model, IOrderGroup cart)
        {
            var payment       = _orderGroupFactory.CreatePayment(cart);
            var paymentMethod = PaymentManager.GetPaymentMethodsByMarket(_market.MarketId.Value)
                                .PaymentMethod.Rows.OfType <PaymentMethodDto.PaymentMethodRow>()
                                .FirstOrDefault(x => x.SystemKeyword.Equals("quickbuy", StringComparison.OrdinalIgnoreCase));

            if (paymentMethod != null)
            {
                payment.PaymentMethodId = paymentMethod.PaymentMethodId;
            }

            payment.Amount          = cart.GetTotal().Amount;
            payment.PaymentType     = PaymentType.Other;
            payment.TransactionType = TransactionType.Sale.ToString();

            return(payment);
        }
Ejemplo n.º 7
0
        private void AddPaymentToOrder(ICart cart, Guid selectedPaymentGuid)
        {
            if (cart.GetFirstForm().Payments.Any())
            {
                // should maybe clean up in the cart here
            }

            var selectedPaymentMethod =
                PaymentManager.GetPaymentMethod(selectedPaymentGuid).PaymentMethod.First();

            var payment = _orderGroupFactory.CreatePayment(cart);

            payment.PaymentMethodId   = selectedPaymentMethod.PaymentMethodId;
            payment.PaymentType       = PaymentType.Other;
            payment.PaymentMethodName = selectedPaymentMethod.Name; // check if str "soliciting" still works

            // ...we also have - cart.GetTotal(_orderGroupCalculator)
            payment.Amount = _orderGroupCalculator.GetTotal(cart).Amount; // need a debug here

            cart.AddPayment(payment);
            // could add payment.BillingAddress = theAddress ... if we had it here
        }