Ejemplo n.º 1
0
        /// <summary>
        /// The checkout payment manager base on finalizing.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void CheckoutPaymentManagerBaseOnFinalizing(CheckoutPaymentManagerBase sender, CheckoutEventArgs <IPaymentResult> e)
        {
            var result = e.Item;

            result.Invoice.AuditCreated();

            if (result.Payment.Success)
            {
                // Reset the Customer's CheckoutManager
                e.Customer.Basket().GetCheckoutManager().Reset();

                if (result.Invoice.InvoiceStatusKey == Core.Constants.InvoiceStatus.Paid)
                {
                    result.Payment.Result.AuditPaymentCaptured(result.Payment.Result.Amount);
                }
                else
                {
                    result.Payment.Result.AuditPaymentAuthorize(result.Invoice);
                }
            }
            else
            {
                result.Payment.Result.AuditPaymentDeclined();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Records the redemption of a coupon offer.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void CheckoutPaymentManagerBaseOnFinalizing(CheckoutPaymentManagerBase sender, CheckoutEventArgs <IPaymentResult> e)
        {
            var invoice = e.Item.Invoice;

            // get the collection of redemptions to be record
            var visitor = new CouponRedemptionLineItemVisitor(invoice.CustomerKey);

            invoice.Items.Accept(visitor);

            if (!visitor.Redemptions.Any())
            {
                return;
            }

            if (MerchelloContext.Current != null)
            {
                ((ServiceContext)MerchelloContext.Current.Services).OfferRedeemedService.Save(visitor.Redemptions);
            }
            else
            {
                LogHelper.Debug <CouponRedemptionEventHandler>("MerchelloContext was null.  Could not record coupon redemption.");
            }
        }