Ejemplo n.º 1
0
        /// <summary>
        /// Finalizes the sale and performs the redirection.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="attempt">
        /// The attempt.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        /// <remarks>
        /// This overrides the default behavior to redirect to PayPal
        /// </remarks>
        protected override ActionResult FinalizeSale(CheckoutConfirmationForm model, IPaymentResult attempt)
        {
            if (attempt.Payment.Success)
            {
                CustomerContext.SetValue("invoiceKey", attempt.Invoice.Key.ToString());

                // Trigger the order confirmation notification
                var    billingAddress = attempt.Invoice.GetBillingAddress();
                string contactEmail;
                if (string.IsNullOrEmpty(billingAddress.Email) && !CurrentCustomer.IsAnonymous)
                {
                    contactEmail = ((ICustomer)CurrentCustomer).Email;
                }
                else
                {
                    contactEmail = billingAddress.Email;
                }

                if (!string.IsNullOrEmpty(contactEmail))
                {
                    Notification.Trigger("OrderConfirmation", attempt, new[] { contactEmail });
                }

                return(Redirect(attempt.RedirectUrl));
            }

            throw new NotImplementedException();
        }
        public ActionResult ConfirmSale(CheckoutConfirmationForm model)
        {
            if (!ModelState.IsValid)
            {
                return(this.CurrentUmbracoPage());
            }

            var preparation = Basket.SalePreparation();

            preparation.RaiseCustomerEvents = false;


            preparation.ClearShipmentRateQuotes();
            var shippingAddress = Basket.SalePreparation().GetShipToAddress();

            // Get the shipment again
            var shipment = Basket.PackageBasket(shippingAddress).FirstOrDefault();

            // get the quote using the "approved shipping method"
            var quote = shipment.ShipmentRateQuoteByShipMethod(model.ShipMethodKey);

            // save the quote
            Basket.SalePreparation().SaveShipmentRateQuote(quote);

            var paymentMethod = GatewayContext.Payment.GetPaymentGatewayMethodByKey(model.PaymentMethodKey).PaymentMethod;

            preparation.SavePaymentMethod(paymentMethod);

            // AuthorizePayment will save the invoice with an Invoice Number.
            var attempt = preparation.AuthorizePayment(paymentMethod.Key);

            if (!attempt.Payment.Success)
            {
                return(this.CurrentUmbracoPage());
            }

            // Trigger the order confirmation notification
            var billingAddress = attempt.Invoice.GetBillingAddress();

            if (!string.IsNullOrEmpty(billingAddress.Email))
            {
                Notification.Trigger("OrderConfirmation", attempt.Payment, new[] { billingAddress.Email });
            }

            // store the invoice key in the CustomerContext for use on the receipt page.
            CustomerContext.SetValue("invoiceKey", attempt.Invoice.Key.ToString());

            return(RedirectToUmbracoPage(model.ReceiptPageId));
        }
 public override ActionResult RenderForm(CheckoutConfirmationForm model)
 {
     return(this.PartialView(PathHelper.GetThemePartialViewPath(BazaarContentHelper.GetStoreTheme(), "BraintreePayPalOneTime"), model));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Responsible for rendering the Cash Payment Method Form.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <returns>
 /// The <see cref="ActionResult"/>.
 /// </returns>
 public override ActionResult RenderForm(CheckoutConfirmationForm model)
 {
     return(this.PartialView(PathHelper.GetThemePartialViewPath(model.ThemeName, "CashPaymentMethodForm"), model));
 }
Ejemplo n.º 5
0
 public override ActionResult RenderForm(CheckoutConfirmationForm model)
 {
     return(this.PartialView(this.GetPartialPath("PurchaseOrderPaymentMethodForm"), model));
 }
Ejemplo n.º 6
0
 public override ActionResult RenderForm(CheckoutConfirmationForm model)
 {
     return(this.PartialView(BraintreePartial("BraintreeStandardTransaction"), model));
 }