protected void btnContinue_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            var tbCardNumber = BillingInfoWidget.FindControl("tbCardNumber") as TextBox;
            if (tbCardNumber != null)
            {
                tbCardNumber.Text = string.Empty;
            }
            return;
        }

        var payment = BillingInfoWidget.GetPaymentInfo();

        targetPayment.PaymentMethod = payment.PaymentMethod;
        // MSIV-330
        targetPayment.Total = targetPayment.LineItems.Sum(x => x.Total);

        processPayment(payment);

        MultiStepWizards.MakePayment.Clear();

        // Clear any cached Membership checks since a payment could trigger a Membership Update.
        MembershipLogic.ClearMemberCaches();

        QueueBannerMessage(string.Format("Your payment for {0:C} has been processed.", targetPayment.Total));

        GoHome();
    }
    /// <summary>
    /// Initializes the target object for the page
    /// </summary>
    /// <remarks>Many pages have "target" objects that the page operates on. For instance, when viewing
    /// an event, the target object is an event. When looking up a directory, that's the target
    /// object. This method is intended to be overriden to initialize the target object for
    /// each page that needs it.</remarks>
    protected override void InitializeTargetObject()
    {
        base.InitializeTargetObject();

        targetPayment = MultiStepWizards.MakePayment.Payment;

        hfOrderBillToId.Value = ConciergeAPI.CurrentEntity.ID;

        dvPriorityData.InnerHtml = GetPriorityPaymentsConfig(hfOrderBillToId.Value);

        if (!IsPostBack)
        {
            using (var api = GetServiceAPIProxy())
                BillingInfoWidget.AllowableMethods = api.DetermineAllowableInvoicePaymentMethods(targetPayment).ResultValue;

            BillingInfoWidget.SetBillingAddress(new Address());
        }
    }
    protected void btnUpdatePaymentInfo_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        string orderID      = Convert.ToString(targetSchedule["Order"]);
        string orderLocalID = GetSearchResult(targetSchedule, "Order.LocalID", null);

        var paymentManifest = BillingInfoWidget.GetPaymentInfo();

        using (var api = GetServiceAPIProxy())
        {
            api.UpdateBillingInfo(orderID, paymentManifest);
            QueueBannerMessage(string.Format("Order #{0} updated successfully.", orderLocalID));
        }
        Response.Redirect("/financial/ViewInstallmentPlan.aspx?contextID=" + ContextID);
    }
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        var ePayment = BillingInfoWidget.GetPaymentInfo();


        if (ePayment == null)
        {
            throw new ApplicationException("No payment type selected.");    // this should be caught during validation
        }
        msSavedPaymentMethod spi;


        switch (ePayment.OrderPaymentMethod)
        {
        case OrderPaymentMethod.CreditCard:
            spi = CreateNewObject <msSavedCreditCard>();
            ((msSavedCreditCard)spi).Card = (CreditCard)ePayment;
            break;

        case OrderPaymentMethod.ElectronicCheck:
            spi = CreateNewObject <msSavedElectronicCheck>();
            ((msSavedElectronicCheck)spi).Check = (ElectronicCheck)ePayment;
            break;

        case OrderPaymentMethod.SavedPaymentMethod:
            string savedPaymentMethodID = ((SavedPaymentInfo)ePayment).SavedPaymentMethodID;

            msSavedPaymentMethod existingMethod = LoadObjectFromAPI <msSavedPaymentMethod>(savedPaymentMethodID);
            spi    = existingMethod.Clone().ConvertTo <msSavedPaymentMethod>();
            spi.ID = spi.SystemTimestamp = null;

            break;

        default:
            throw new NotSupportedException("Unable to deal with order payment method " +
                                            ePayment.OrderPaymentMethod);
        }


        bool shouldSaveTargetObject = false;

        switch (targetObject.ClassType)
        {
        case msGift.CLASS_NAME:

            spi.Type = SavedPaymentMethodType.Gift;

            targetObject[msGift.FIELDS.DateOfInstallmentSuspension] = null;     // clear the suspension
            shouldSaveTargetObject = true;
            break;

        default:
            throw new NotSupportedException("Unable to update a record of type " + targetObject.ClassType);
        }

        spi.Owner = null;   // always to this, so it's not linked to the entity

        using (var api = GetServiceAPIProxy())
        {
            string id = api.Save(spi).ResultValue.SafeGetValue <string>("ID");

            targetObject["SavedPaymentMethod"] = id;

            if (shouldSaveTargetObject)
            {
                api.Save(targetObject);
            }
        }

        QueueBannerMessage("Payment information has been updated successfully.");

        goBackToReturnUrl();
    }
Beispiel #5
0
    /// <summary>
    /// Initializes the target object for the page
    /// </summary>
    /// <remarks>Many pages have "target" objects that the page operates on. For instance, when viewing
    /// an event, the target object is an event. When looking up a directory, that's the target
    /// object. This method is intended to be overriden to initialize the target object for
    /// each page that needs it.</remarks>
    protected override void InitializeTargetObject()
    {
        hfOrderBillToId.Value = ConciergeAPI.CurrentEntity.ID;

        dvPriorityData.InnerHtml = GetPriorityPaymentsConfig(hfOrderBillToId.Value);

        base.InitializeTargetObject();

        if (IsTransient)
        {
            targetOrder = MultiStepWizards.PlaceAnOrder.TransientShoppingCart;
        }
        else
        {
            targetOrder = MultiStepWizards.PlaceAnOrder.ShoppingCart;
        }

        if (targetOrder == null)
        {
            QueueBannerError("Unable to checkout without an active shopping cart.");
            GoHome();
            return;
        }

        //MS-2823
        if (targetOrder.BillTo == null)
        {
            targetOrder.BillTo = hfOrderBillToId.Value;
        }

        if (targetOrder.ShipTo == null)
        {
            targetOrder.ShipTo = targetOrder.BillTo;
        }


        if (!IsPostBack)
        {
            // let's preprocess and figure out whether we need shipping information
            var completeOrder = targetOrder.Clone().ConvertTo <msOrder>();
            var csi           = MultiStepWizards.PlaceAnOrder.CrossSellItems;
            if (csi != null && csi.Count > 0)
            {
                completeOrder.LineItems.AddRange(csi.FindAll(x => x.Quantity != 0)); // add any cross sell items
            }
            if (completeOrder.Date == DateTime.MinValue)
            {
                completeOrder.Date = DateTime.Now;
            }

            using (var api = GetConciegeAPIProxy())
            {
                preProcessedOrderPacket = api.PreProcessOrder(completeOrder).ResultValue;
            }

            // no billing, but we want to test Total, and not AmountDueNow
            // because even if nothing is due now we need to capture credit card info
            if (preProcessedOrderPacket.Total == 0)
            {
                GoTo("ConfirmOrder.aspx?useTransient=" + IsTransient);
            }

            lblAmountDue.Text = preProcessedOrderPacket.AmountDueNow.ToString("C");

            using (var api = GetServiceAPIProxy())
                BillingInfoWidget.AllowableMethods = api.DetermineAllowableOrderPaymentMethods(preProcessedOrderPacket.FinalizedOrder.ConvertTo <msOrder>()).ResultValue;

            // let's set default payment info
            switch (targetOrder.PaymentMethod)
            {
            case OrderPaymentMethod.None:
                break;     // do nothing

            case OrderPaymentMethod.CreditCard:
                var cc = new CreditCard();
                // Do NOT keep the credit card information on the page unpon refreshes
                cc.SavePaymentMethod = targetOrder.SavePaymentMethod;
                cc.NameOnCard        = targetOrder.SafeGetValue <string>("NameOnCreditCard");
                BillingInfoWidget.SetPaymentInfo(cc);
                break;

            case OrderPaymentMethod.ElectronicCheck:
                var ec = new ElectronicCheck();
                ec.BankAccountNumber = targetOrder.ACHAccountNumber;
                ec.RoutingNumber     = targetOrder.ACHRoutingNumber;
                ec.SavePaymentMethod = targetOrder.SavePaymentMethod;
                BillingInfoWidget.SetPaymentInfo(ec);
                break;

            case OrderPaymentMethod.SavedPaymentMethod:
                var spi = new SavedPaymentInfo();
                spi.SavedPaymentMethodID = targetOrder.SavedPaymentMethod;
                BillingInfoWidget.SetPaymentInfo(spi);
                break;

            default:
                var nep = new NonElectronicPayment();
                nep._OrderPaymentMethod = targetOrder.PaymentMethod;
                nep.ReferenceNumber     = targetOrder.PaymentReferenceNumber;
                BillingInfoWidget.SetPaymentInfo(nep);
                break;
            }

            BillingInfoWidget.SetBillingAddress(targetOrder.BillingAddress);
        }
    }
Beispiel #6
0
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            var tbCardNumber = BillingInfoWidget.FindControl("tbCardNumber") as TextBox;
            if (tbCardNumber != null)
            {
                tbCardNumber.Text = string.Empty;
            }
            return;
        }

        var ePayment = BillingInfoWidget.GetPaymentInfo();

        if (ePayment == null)
        {
            cvCustom.IsValid      = false;
            cvCustom.ErrorMessage = "You have not selected a payment method.";
            return;
        }

        targetOrder.PaymentMethod = ePayment.OrderPaymentMethod;

        switch (targetOrder.PaymentMethod)
        {
        case OrderPaymentMethod.CreditCard:

            var cc = ePayment as CreditCard;
            if (cc == null)
            {
                throw new ApplicationException(
                          "Payment is of type credit card, but no credit card manifest provided");
            }
            targetOrder.CreditCardNumber         = cc.CardNumber;
            targetOrder.CreditCardExpirationDate = cc.CardExpirationDate;
            targetOrder.CCVCode             = cc.CCVCode;
            targetOrder["NameOnCreditCard"] = cc.NameOnCard;
            break;

        case OrderPaymentMethod.ElectronicCheck:

            var ec = ePayment as ElectronicCheck;
            if (ec == null)
            {
                throw new ApplicationException(
                          "Payment is of type electronic check, but no check  manifest provided");
            }

            targetOrder.ACHAccountNumber = ec.BankAccountNumber;
            targetOrder.ACHRoutingNumber = ec.RoutingNumber;
            break;

        case OrderPaymentMethod.SavedPaymentMethod:
            var spi = ePayment as SavedPaymentInfo;
            if (spi == null)
            {
                throw new ApplicationException(
                          "Payment is of type saved method, but not method manifest provided");
            }

            targetOrder.SavedPaymentMethod = spi.SavedPaymentMethodID;
            break;
        }

        targetOrder["BillingMethodFriendlyName"] = ePayment.ToString();

        targetOrder.SavePaymentMethod = ePayment.SavePaymentMethod;

        targetOrder.BillingAddress      = BillingInfoWidget.GetBillingAddress();
        targetOrder.PurchaseOrderNumber = BillingInfoWidget.GetReferenceNumber();

        GoTo("ConfirmOrder.aspx?useTransient=" + IsTransient);
    }