示例#1
0
        private string GetPaymentMethod(Address BillingAddress)
        {
            var sPmtMethod  = new StringBuilder();
            var paymentInfo = PaymentTermDTO.Find(ThisCustomer.PaymentTermCode);

            //  We should have a default payment method
            //  For debugging purposes, have this check here
            if (string.IsNullOrEmpty(paymentInfo.PaymentMethod))
            {
                throw new InvalidOperationException("No payment method defined!");
            }

            if (!cart.IsSalesOrderDetailBuilt)
            {
                if (cart.IsNoShippingRequired())
                {
                    cart.BuildSalesOrderDetails(false, true);
                }
                else
                {
                    cart.BuildSalesOrderDetails();
                }
            }

            if ((ThisCustomer.PaymentTermCode.Trim().Equals("PURCHASE ORDER", StringComparison.InvariantCultureIgnoreCase)) ||
                (ThisCustomer.PaymentTermCode.Trim().Equals("REQUEST QUOTE", StringComparison.InvariantCultureIgnoreCase)))
            {
                sPmtMethod.Append(ThisCustomer.PaymentTermCode.ToUpperInvariant());
            }
            else
            {
                switch (paymentInfo.PaymentMethod)
                {
                case DomainConstants.PAYMENT_METHOD_CREDITCARD:
                    if ((cart.GetOrderTotal() == decimal.Zero) && (AppLogic.AppConfigBool("SkipPaymentEntryOnZeroDollarCheckout")))
                    {
                        sPmtMethod.Append(AppLogic.GetString("checkoutpayment.aspx.8", SkinID, ThisCustomer.LocaleSetting));
                    }
                    else
                    {
                        sPmtMethod.AppendFormat("{0} ({1})", Security.HtmlEncode(paymentInfo.PaymentMethod), HttpUtility.HtmlEncode(ThisCustomer.PaymentTermCode));
                        sPmtMethod.Append("<br/>");
                        sPmtMethod.Append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
                        sPmtMethod.Append("<tr><td>");
                        sPmtMethod.Append(AppLogic.GetString("checkoutreview.aspx.10", SkinID, ThisCustomer.LocaleSetting));
                        sPmtMethod.Append("</td><td>");
                        sPmtMethod.Append(BillingAddress.CardName);
                        sPmtMethod.Append("</td></tr>");
                        sPmtMethod.Append("<tr><td>");
                        sPmtMethod.Append(AppLogic.GetString("checkoutreview.aspx.11", SkinID, ThisCustomer.LocaleSetting));
                        sPmtMethod.Append("</td><td>");
                        sPmtMethod.Append(BillingAddress.CardType);
                        sPmtMethod.Append("</td></tr>");
                        sPmtMethod.Append("<tr><td>");
                        sPmtMethod.Append(AppLogic.GetString("checkoutreview.aspx.12", SkinID, ThisCustomer.LocaleSetting));
                        sPmtMethod.Append("</td><td>");
                        sPmtMethod.Append(BillingAddress.CardNumberMaskSafeDisplayFormat);
                        sPmtMethod.Append("</td></tr>");
                        sPmtMethod.Append("<tr><td>");
                        sPmtMethod.Append(AppLogic.GetString("checkoutreview.aspx.13", SkinID, ThisCustomer.LocaleSetting));
                        sPmtMethod.Append("</td><td>");
                        sPmtMethod.Append(BillingAddress.CardExpirationMonth.PadLeft(2, '0') + "/" + BillingAddress.CardExpirationYear);
                        sPmtMethod.Append("</td></tr>");
                        sPmtMethod.Append("</table>");
                    }
                    break;

                case DomainConstants.PAYMENT_METHOD_CASH:
                case DomainConstants.PAYMENT_METHOD_CHECK:

                    if ((cart.GetOrderTotal() == decimal.Zero) && (AppLogic.AppConfigBool("SkipPaymentEntryOnZeroDollarCheckout")))
                    {
                        sPmtMethod.Append(AppLogic.GetString("checkoutpayment.aspx.8", SkinID, ThisCustomer.LocaleSetting));
                    }
                    else
                    {
                        sPmtMethod.AppendFormat("{0} ({1})", Security.HtmlEncode(paymentInfo.PaymentMethod), HttpUtility.HtmlEncode(ThisCustomer.PaymentTermCode));
                    }
                    break;

                default:
                    throw new InvalidOperationException("Invalid Payment method!");
                }
            }

            return(sPmtMethod.ToString());
        }