コード例 #1
0
 private bool IsPayPalExpressCheckout(PaymentMethodBaseModel activePaymentMethod, bool havePayPalExpress)
 {
     if (activePaymentMethod != null && activePaymentMethod.PaymentType == PaymentType.PayPalExpress)
     {
         var paymentModel = (PaypalExpressPaymentModel)activePaymentMethod;
         return(paymentModel.ExpressLoginComplete && havePayPalExpress);
     }
     return(false);
 }
コード例 #2
0
 public void SetModel(PaymentMethodBaseModel model)
 {
     this.PaymentMethodModel = model;
     this.CreditCardPaymentForm1.StringResourceProvider = this.StringResourceProvider;
     this.BillingAddressUKEdit1.StringResourceProvider  = this.StringResourceProvider;
     this.CreditCardPaymentForm1.SetModel(model);
     this.CreditCardPaymentForm1.PaymentFormSubmitted    += new EventHandler(OPCControls_CreditCardAndBillingAddress_PaymentFormSubmitted);
     this.CreditCardPaymentForm1.SecurityCodeTextChanged += new EventHandler(OPCControls_CreditCardAndBillingAddress_SecurityCodeChanged);
 }
コード例 #3
0
    private void SetActivePaymentMethodFromForm(PaymentType paymentType)
    {
        PaymentMethodBaseModel method = this.PaymentModel.PaymentMethods
                                        .FirstOrDefault(pm => pm.Key == paymentType).Value;

        ToggleCheckoutByAmazonForm(false);

        this.PaymentModel.SetActivePaymentMethod(method.MethodId);
    }
コード例 #4
0
    public void SetModel(PaymentMethodBaseModel model)
    {
        this.PaymentMethodModel = model;

        if (!AppLogic.SecureNetVaultIsEnabled())
        {
            return;
        }

        if (rblSecureNetVaultMethods.Items.Count != 0)
        {
            return;
        }

        var  vaultPaymentInfo = SecureNetModel.GetCustomerVault();
        bool defaultToNewCard = true;

        rblSecureNetVaultMethods.Items.Clear();
        foreach (var paymentInfo in vaultPaymentInfo)
        {
            string text     = String.Format("<strong>{0}</strong>: {1} <strong>{2}</strong>: {3}", "account.creditcardprompt".StringResource(), paymentInfo.CardNumberPadded, "account.expires".StringResource(), paymentInfo.ExpDateFormatted);
            string value    = paymentInfo.PaymentId;
            bool   selected = value == (SecureNetModel.SelectedVaultPayment ?? SecureNetModel.GetCustomersSelectedSecureNetVault());

            if (selected)
            {
                defaultToNewCard = false;
            }

            rblSecureNetVaultMethods.Items.Add(
                new ListItem
            {
                Text     = text,
                Value    = value,
                Selected = selected
            });
        }

        rblSecureNetVaultMethods.Items.Add(
            new ListItem
        {
            Text     = "Use a new credit card",
            Value    = "-1",
            Selected = defaultToNewCard,
        });
    }
コード例 #5
0
 private void DefaultToPayPalEmbedded(PaymentMethodBaseModel activePaymentMethod, bool expressLoginComplete, bool havePayPalEmbedded)
 {
     if (havePayPalEmbedded)
     {
         if (activePaymentMethod != null)
         {
             if (activePaymentMethod.PaymentType == PaymentType.PayPalExpress || activePaymentMethod.PaymentType == PaymentType.PayPal)
             {
                 if (!expressLoginComplete)
                 {
                     var embeddedModel = this.Model.PaymentMethods.FirstOrDefault(s => s.Value.PaymentType == PaymentType.PayPalEmbeddedCheckout);
                     Model.SetActivePaymentMethod(embeddedModel.Value.MethodId);
                 }
             }
         }
     }
 }
コード例 #6
0
        public void SubmitOrder_OnClick(object sender, EventArgs e)
        {
            if (this.CreateAccountView.Visible)
            {
                ApplyAccountCreation();
            }

            if (this.ShoppingCartModel.Total > 0)
            {
                this.PaymentView.SaveViewToModel();
            }
            else
            {
                // Force CC payment on zero dollar checkout
                PaymentMethodBaseModel method = this.PaymentModel.PaymentMethods
                                                .FirstOrDefault(pm => pm.Key == PaymentType.CreditCard).Value;
                this.PaymentModel.SetActivePaymentMethod(method.MethodId);
            }

            if (Page.IsValid)
            {
                this.PaymentModel.ProcessPayment();
            }
        }
 public void SetModel(PaymentMethodBaseModel model)
 {
     this.PaymentMethodModel = model;
 }
コード例 #8
0
    public void BindView()
    {
        bool hasPayPal = false;
        List <PaymentMethodBaseModel> payPalOptions = new List <PaymentMethodBaseModel>();

        PanelError.Visible = false;
        CreditCardPaymentViewForm.StringResourceProvider            = this.StringResourceProvider;
        SecureNetPaymentView.StringResourceProvider                 = this.StringResourceProvider;
        CheckPaymentView.StringResourceProvider                     = this.StringResourceProvider;
        RequestQuoteView.StringResourceProvider                     = this.StringResourceProvider;
        PayPalPaymentView.StringResourceProvider                    = this.StringResourceProvider;
        PurchaseOrderPaymentView.StringResourceProvider             = this.StringResourceProvider;
        PayPalExpressView.StringResourceProvider                    = this.StringResourceProvider;
        MicroPayPaymentView.StringResourceProvider                  = this.StringResourceProvider;
        CodPaymentView.StringResourceProvider                       = this.StringResourceProvider;
        CheckOutByAmazonPaymentView.StringResourceProvider          = this.StringResourceProvider;
        PayPalEmbeddedCheckoutPaymentView.StringResourceProvider    = this.StringResourceProvider;
        MoneybookersQuickCheckoutPaymentView.StringResourceProvider = this.StringResourceProvider;

        if (PaymentModel != null)
        {
            foreach (var kvp in this.PaymentModel.PaymentMethods)
            {
                PaymentMethodBaseModel method = kvp.Value;
                switch (method.PaymentType)
                {
                case PaymentType.CreditCard:
                {
                    PanelCreditCardMethod.Visible = true;
                    CreditCardPaymentViewForm.SetModel(method);
                    CreditCardPaymentViewForm.Initialize();
                    CreditCardPaymentViewForm.Hide();

                    IEnumerable <CreditCardType> cardTypes = ((CreditCardPaymentModel)method).AllowedCardTypes;

                    ImageCardTypeVisa.Visible       = cardTypes.Contains(CreditCardType.Visa);
                    ImageCardTypeMastercard.Visible = cardTypes.Contains(CreditCardType.MasterCard);
                    ImageCardTypeAmex.Visible       = cardTypes.Contains(CreditCardType.AmericanExpress);
                    ImageCardTypeDiscover.Visible   = cardTypes.Contains(CreditCardType.Discover);
                    ImageCardTypeSolo.Visible       = cardTypes.Contains(CreditCardType.Solo);
                    ImageCardTypeMaestro.Visible    = cardTypes.Contains(CreditCardType.Maestro);

                    RadioCreditCard.Visible = true;
                    RadioCreditCard.Enabled = true;
                    RadioCreditCard.Checked = false;
                }; break;

                case PaymentType.SecureNet:
                {
                    SecureNetPaymentView.SetModel(method);
                    SecureNetPaymentView.Initialize();
                    SecureNetPaymentView.Hide();
                } break;

                case PaymentType.CheckByMail:
                {
                    PanelCheckMoneyOrderMethod.Visible = true;
                    CheckPaymentView.SetModel(method);
                    CheckPaymentView.Initialize();
                    CheckPaymentView.Hide();

                    RadioCheckByMail.Visible = true;
                    RadioCheckByMail.Enabled = true;
                    RadioCheckByMail.Checked = false;
                }; break;

                case PaymentType.RequestAQuote:
                {
                    PanelRequestQuote.Visible = true;

                    RequestQuoteView.SetModel(method);
                    RequestQuoteView.Initialize();
                    RequestQuoteView.Hide();

                    RadioRequestQuote.Visible = true;
                    RadioRequestQuote.Enabled = true;
                    RadioRequestQuote.Checked = false;
                }; break;

                case PaymentType.PurchaseOrder:
                {
                    PanelPurchaseOrderMethod.Visible = true;
                    PurchaseOrderPaymentView.SetModel(method);
                    PurchaseOrderPaymentView.Initialize();
                    PurchaseOrderPaymentView.Hide();

                    RadioPurchaseOrder.Visible = true;
                    RadioPurchaseOrder.Enabled = true;
                    RadioPurchaseOrder.Checked = false;
                }; break;

                case PaymentType.PayPalEmbeddedCheckout:
                case PaymentType.PayPalExpress:
                case PaymentType.PayPal:
                    hasPayPal = true;
                    payPalOptions.Add(method);
                    break;

                case PaymentType.MicroPay:
                {
                    PanelMicroPayMethod.Visible = true;

                    MicroPayPaymentView.SetModel(method);
                    MicroPayPaymentView.Initialize();
                    MicroPayPaymentView.Hide();

                    RadioMicroPay.Visible = true;
                    RadioMicroPay.Enabled = true;
                    RadioMicroPay.Checked = false;
                }; break;

                case PaymentType.COD:
                {
                    PanelCodMethod.Visible = true;

                    CodPaymentView.SetModel(method);
                    CodPaymentView.Initialize();
                    CodPaymentView.Hide();

                    RadioCod.Visible = true;
                    RadioCod.Enabled = true;
                    RadioCod.Checked = false;
                }; break;

                case PaymentType.CheckoutByAmazon:
                {
                    CheckOutByAmazonPaymentView.SetModel(method);
                    CheckOutByAmazonPaymentView.Initialize();
                    CheckOutByAmazonPaymentView.Hide();

                    if (((CheckOutByAmazonPaymentModel)CheckOutByAmazonPaymentView.PaymentMethodModel).IsCheckingOut)
                    {
                        PanelCheckoutByAmazon.Visible = true;
                        RadioCheckoutByAmazon.Visible = true;
                        RadioCheckoutByAmazon.Enabled = true;
                        RadioCheckoutByAmazon.Checked = false;
                    }
                }; break;

                case PaymentType.MoneybookersQuickCheckout:
                {
                    MoneybookersQuickCheckoutPaymentView.SetModel(method);
                    MoneybookersQuickCheckoutPaymentView.Initialize();
                    MoneybookersQuickCheckoutPaymentView.Hide();

                    PanelMoneybookersQuickCheckout.Visible = true;
                    RadioMoneybookersQuickCheckout.Visible = true;
                    RadioMoneybookersQuickCheckout.Enabled = true;
                    RadioMoneybookersQuickCheckout.Checked = false;
                } break;
                }
            }
            //PayPal options are mutually exclusive so this will ensure only one shows
            if (hasPayPal)
            {
                HandlePayPalOptions(payPalOptions);
            }
        }

        SetSelectedPaymentMethod();
    }
コード例 #9
0
    public void SetModel(IPaymentModel model)
    {
        this.PaymentModel = (IPaymentModel)model;
        foreach (var kvp in this.PaymentModel.PaymentMethods)
        {
            PaymentMethodBaseModel method = kvp.Value;
            switch (method.PaymentType)
            {
            case PaymentType.CreditCard:
            {
                CreditCardPaymentViewForm.StringResourceProvider = this.StringResourceProvider;
                CreditCardPaymentViewForm.SetModel(method);
            }; break;

            case PaymentType.SecureNet:
            {
                SecureNetPaymentView.StringResourceProvider = this.StringResourceProvider;
                SecureNetPaymentView.SetModel(method);

                SecureNetPaymentView.ExistingCreditCardSelected += (o, e) => CreditCardPaymentViewForm.Hide();
                SecureNetPaymentView.NewCreditCardSelected      += (o, e) => CreditCardPaymentViewForm.Show();

                PaymentModel.ProcessingPayment += (o, e) =>
                {
                    if (!(e.PaymentMethod is CreditCardPaymentModel) && !(e.PaymentMethod is SecureNetPaymentModel))
                    {
                        return;
                    }

                    ((SecureNetPaymentModel)method).SwitchPaymentMethod();
                };
            } break;

            case PaymentType.CheckByMail:
            {
                CheckPaymentView.StringResourceProvider = this.StringResourceProvider;
                CheckPaymentView.SetModel(method);
            }; break;

            case PaymentType.RequestAQuote:
            {
                RequestQuoteView.StringResourceProvider = this.StringResourceProvider;
                RequestQuoteView.SetModel(method);
            }; break;

            case PaymentType.PurchaseOrder:
            {
                PurchaseOrderPaymentView.StringResourceProvider = this.StringResourceProvider;
                PurchaseOrderPaymentView.SetModel(method);
            }; break;

            case PaymentType.PayPal:
            {
                PayPalPaymentView.StringResourceProvider = this.StringResourceProvider;
                PayPalPaymentView.SetModel(method);
            }; break;

            case PaymentType.PayPalExpress:
            {
                PayPalExpressView.StringResourceProvider = this.StringResourceProvider;
                PayPalExpressView.SetModel(method);
            } break;

            case PaymentType.MicroPay:
            {
                MicroPayPaymentView.StringResourceProvider = this.StringResourceProvider;
                MicroPayPaymentView.SetModel(method);
            } break;

            case PaymentType.COD:
            {
                CodPaymentView.StringResourceProvider = this.StringResourceProvider;
                CodPaymentView.SetModel(method);
            } break;

            case PaymentType.CheckoutByAmazon:
            {
                CheckOutByAmazonPaymentView.StringResourceProvider = this.StringResourceProvider;
                CheckOutByAmazonPaymentView.SetModel(method);
            } break;

            case PaymentType.PayPalEmbeddedCheckout:
            {
                PayPalEmbeddedCheckoutPaymentView.StringResourceProvider = this.StringResourceProvider;
                PayPalEmbeddedCheckoutPaymentView.SetModel(method);
            } break;

            case PaymentType.MoneybookersQuickCheckout:
            {
                MoneybookersQuickCheckoutPaymentView.StringResourceProvider = this.StringResourceProvider;
                MoneybookersQuickCheckoutPaymentView.SetModel(method);
            } break;
            }
        }
    }
コード例 #10
0
    private void SetSelectedPaymentMethod()
    {
        if (this.PaymentModel != null)
        {
            PaymentMethodBaseModel method = this.PaymentModel.ActivePaymentMethod;
            if (method != null)
            {
                switch (method.PaymentType)
                {
                case PaymentType.CreditCard:
                case PaymentType.SecureNet:
                {
                    ToggleCreditCardForm(true);
                }; break;

                case PaymentType.CheckByMail:
                {
                    ToggleForm(CheckPaymentView, RadioCheckByMail, true);
                }; break;

                case PaymentType.PurchaseOrder:
                {
                    ToggleForm(PurchaseOrderPaymentView, RadioPurchaseOrder, true);
                }; break;

                case PaymentType.RequestAQuote:
                {
                    ToggleForm(RequestQuoteView, RadioRequestQuote, true);
                }; break;

                case PaymentType.PayPal:
                {
                    ToggleForm(PayPalPaymentView, RadioPayPal, true);
                } break;

                case PaymentType.PayPalExpress:
                {
                    TogglePayPalExpressForm(true);
                } break;

                case PaymentType.MicroPay:
                {
                    ToggleForm(MicroPayPaymentView, RadioMicroPay, true);
                } break;

                case PaymentType.COD:
                {
                    ToggleForm(CodPaymentView, RadioCod, true);
                } break;

                case PaymentType.CheckoutByAmazon:
                {
                    ToggleCheckoutByAmazonForm(true);
                } break;

                case PaymentType.PayPalEmbeddedCheckout:
                {
                    TogglePayPalEmbeddedCheckoutForm(true);
                } break;

                case PaymentType.MoneybookersQuickCheckout:
                {
                    ToggleForm(MoneybookersQuickCheckoutPaymentView, RadioMoneybookersQuickCheckout, true);
                } break;
                }
            }
        }
    }
コード例 #11
0
 public void SetModel(PaymentMethodBaseModel model)
 {
     this.PaymentMethodModel = model;
     this.RequestQuoteModel  = (RequestQuotePaymentModel)model;
 }
コード例 #12
0
 public void SetModel(PaymentMethodBaseModel model)
 {
     this.PaymentMethodModel   = model;
     this.MicroPayPaymentModel = (MicroPayPaymentModel)model;
 }
コード例 #13
0
    private void BindPaymentMethods()
    {
        if (Model != null)
        {
            var activePaymentMethod = this.Model.ActivePaymentMethod;
            PaymentFormAndBillingAddress.BindView();

            var havePayPalEmbedded = this.Model.PaymentMethods.Any(s => s.Value.PaymentType == PaymentType.PayPalEmbeddedCheckout);
            var havePayPalExpress  = this.Model.PaymentMethods.Any(s => s.Value.PaymentType == PaymentType.PayPalExpress);
            var havePayPalStandard = this.Model.PaymentMethods.Any(s => s.Value.PaymentType == PaymentType.PayPal);

            bool payPalExpressCheckout = IsPayPalExpressCheckout(activePaymentMethod, havePayPalExpress);

            DefaultToPayPalEmbedded(activePaymentMethod, payPalExpressCheckout, havePayPalEmbedded);

            foreach (var kvp in this.Model.PaymentMethods)
            {
                PaymentMethodBaseModel method = kvp.Value;
                switch (method.PaymentType)
                {
                case PaymentType.CreditCard:
                {
                    // if we have Paypal Advanced, then let them handle CC Processing
                    if (!havePayPalEmbedded)
                    {
                        ActivatePaymentMethodChoice(PanelCreditCardMethod, RadioCreditCard);

                        IEnumerable <CreditCardType> cardTypes = ((CreditCardPaymentModel)method).AllowedCardTypes;

                        ImageCardTypeVisa.Visible       = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Visa);
                        ImageCardTypeMastercard.Visible = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.MasterCard);
                        ImageCardTypeAmex.Visible       = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.AmericanExpress);
                        ImageCardTypeDiscover.Visible   = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Discover);
                        ImageCardTypeSolo.Visible       = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Solo);
                        ImageCardTypeMaestro.Visible    = cardTypes.Any(f => f.CardType == CreditCardTypeEnum.Maestro);
                    }
                }; break;

                case PaymentType.CheckByMail:
                {
                    ActivatePaymentMethodChoice(PanelCheckMoneyOrderMethod, RadioCheckByMail);
                }; break;

                case PaymentType.RequestAQuote:
                {
                    ActivatePaymentMethodChoice(PanelRequestQuote, RadioRequestQuote);
                }; break;

                case PaymentType.PurchaseOrder:
                {
                    ActivatePaymentMethodChoice(PanelPurchaseOrderMethod, RadioPurchaseOrder);
                }; break;

                case PaymentType.MicroPay:
                {
                    ActivatePaymentMethodChoice(PanelMicroPayMethod, RadioMicroPay);
                }; break;

                case PaymentType.COD:
                {
                    ActivatePaymentMethodChoice(PanelCodMethod, RadioCod);
                }; break;

                case PaymentType.CheckoutByAmazon:
                {
                    if (IsCheckoutByAmazonCheckingOut())
                    {
                        PanelCheckoutByAmazon.Visible = true;
                        RadioCheckoutByAmazon.Visible = true;
                        RadioCheckoutByAmazon.Enabled = true;
                        RadioCheckoutByAmazon.Checked = false;
                    }
                }; break;

                case PaymentType.MoneybookersQuickCheckout:
                {
                    ActivatePaymentMethodChoice(PanelMoneybookersQuickCheckout, RadioMoneybookersQuickCheckout);
                } break;

                case PaymentType.PayPalEmbeddedCheckout:
                {
                    // PayPal Advanced enables PayPal Express
                    // So make sure this isn't an express checkout originating from the cart page.
                    if (!payPalExpressCheckout)
                    {
                        ActivatePaymentMethodChoice(PanelPayPalEmbeddedCheckout, RadioPayPalEmbeddedCheckout);
                    }
                } break;

                case PaymentType.PayPalExpress:
                {
                    // Show PayPal Express if Embedded is not enabled or we are using Express to Checkout.
                    if (payPalExpressCheckout || !havePayPalEmbedded)
                    {
                        ActivatePaymentMethodChoice(PanelPaypalExpressMethod, RadioPayPalExpress);
                    }
                } break;

                case PaymentType.PayPal:
                {
                    // Only allow PayPal standard if not using express and embedded
                    if (!havePayPalExpress && !havePayPalEmbedded)
                    {
                        ActivatePaymentMethodChoice(PanelPayPalMethod, RadioPayPal);
                    }
                } break;

                case PaymentType.ECheck:
                {
                    ActivatePaymentMethodChoice(PanelECheck, RadioECheck);
                } break;
                }
            }
        }
    }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IModelFactory modelFactory = Vortx.OnePageCheckout.ObjectFactory.CreateModelFactory();
            IConfigurationProviderFactory configurationFactory = Vortx.OnePageCheckout.ObjectFactory.CreateConfigurationFactory();

            ConfigurationProvider.DefaultProvider = configurationFactory.CreateConfigurationProvider();

            this.StringResourceProvider = modelFactory.CreateStringResourceProvider();

            this.AccountModel = modelFactory.CreateAccountModel();
            this.AccountModel.CreateAccountCompleted         += new CreateAccountHandler(AccountModel_CreateAccountCompleted);
            this.AccountModel.FindAccountCompleted           += new FindAccountHandler(AccountModel_FindAccountCompleted);
            this.AccountModel.LogOnCompleted                 += new LogOnHandler(AccountModel_LogOnCompleted);
            this.AccountModel.LogOutCompleted                += new LogOutHandler(AccountModel_LogOutCompleted);
            this.AccountModel.AccountChanged                 += new AccountChangedHandler(AccountModel_AccountChanged);
            this.AccountModel.BillingAddress.AddressChanged  += new AddressChangedEventHandler(BillingAddressEditModel_AddressChanged);
            this.AccountModel.ShippingAddress.AddressChanged += new AddressChangedEventHandler(ShippingAddressEditModel_AddressChanged);
            this.AccountModel.PasswordChanged                += new PasswordChangedHandler(AccountModel_PasswordChanged);

            this.LoginView.StringResourceProvider = this.StringResourceProvider;
            this.LoginView.SetModel(this.AccountModel);

            this.CreateAccountView.StringResourceProvider = this.StringResourceProvider;
            this.CreateAccountView.SetModel(this.AccountModel);
            this.CreateAccountView.AccountCreationActivated += (o, ea) => ApplyAccountCreation();

            // Create shopping cart models
            this.ShoppingCartModel = modelFactory.CreateShoppingCartModel();
            this.ShoppingCartModel.AccountModel         = this.AccountModel;
            this.ShoppingCartModel.ItemQuantityChanged += new ItemQuantityChangedHandler(ShoppingCartModel_ItemQuantityChanged);
            this.ShoppingCartModel.ItemRemoved         += new ItemRemovedHandler(ShoppingCartModel_ItemRemoved);
            this.ShoppingCartModel.ShipMethodChanged   += new ShipMethodChangedEventHandler(ShipMethodModel_ShipMethodChanged);

            // Create shopping cart views
            this.ShipMethodView.StringResourceProvider = this.StringResourceProvider;
            this.ShipMethodView.SetModel(this.ShoppingCartModel);

            this.MiniCartView.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartView.SetModel(this.ShoppingCartModel);

            this.MiniCartCartSummary.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartCartSummary.SetModel(this.ShoppingCartModel);

            this.AddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.AddressBookView.SetModel(this.AccountModel);
            this.AddressBookView.SetAddressType(AddressType.Shipping);

            this.ShippingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressEditUKView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditUKView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressNoZipEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressNoZipEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressStaticView.SetModel(this.AccountModel.ShippingAddress);
            this.ShippingAddressStaticView.AddressEdit += new AddressEditEventHandler(ShippingAddressStaticView_AddressEdit);

            // Create payment model
            this.PaymentModel = modelFactory.CreatePaymentModel();
            this.PaymentModel.ActivePaymentMethodChanged += new ActivePaymentMethodChangedHandler(PaymentMethodModel_ActivePaymentMethodChanged);
            this.PaymentModel.ProcessPaymentComplete     += new ProcessPaymentCompleteHandler(PaymentModel_ProcessPaymentComplete);

            if (!ConfigurationProvider.DefaultProvider.ShowCreateAccount &&
                !ConfigurationProvider.DefaultProvider.PasswordIsOptionalDuringCheckout)
            {
                throw new Exception(StringResourceProvider.GetString("smartcheckout.aspx.129"));
            }

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            // Setup payment events
            PaymentMethodBaseModel paymentMethod = null;

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && (this.PaymentModel.ActivePaymentMethod == null || this.PaymentModel.ActivePaymentMethod.Name.ToLower() != PaymentType.CheckoutByAmazon.ToString().ToLower()))
            {
                this.PaymentModel.SetActivePaymentMethod(PaymentType.CheckoutByAmazon.ToString());
            }
            else
            {
                paymentMethod = this.PaymentModel.PaymentMethods.FirstOrDefault(pm => pm.Key == PaymentType.CreditCard).Value;
                if (paymentMethod != null)
                {
                    this.CreditCardModel = (CreditCardPaymentModel)paymentMethod;
                    this.CreditCardModel.BillingEqualsShippingChanged += new BillingEqualsShippingChangedHandler(CreditCardModel_BillingEqualsShippingChanged);
                }
            }

            // registered payment data changed events
            foreach (var kvp in this.PaymentModel.PaymentMethods)
            {
                var method = kvp.Value;
                method.PaymentDataChanged += new PaymentDataChangedHandler(PaymentModel_PaymentDataChanged);
            }

            // Create payment views
            this.PaymentView.StringResourceProvider = this.StringResourceProvider;
            this.PaymentView.SetModel(this.PaymentModel);

            this.BillingAddressEditView = this.PaymentView.BillingAddressEditView;
            this.BillingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressEditView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressStaticView = this.PaymentView.BillingAddressStaticView;
            this.BillingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressStaticView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressBookView = this.PaymentView.AddressBookView;
            this.BillingAddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressBookView.SetModel(this.AccountModel);

            this.AccountModel.PrimaryShippingAddressChanged += new PrimaryShippingAddressChangedHandler(AccountModel_PrimaryShippingAddressChanged);
            this.AccountModel.PrimaryBillingAddressChanged  += new PrimaryBillingAddressChangedHandler(AccountModel_PrimaryBillingAddressChanged);

            this.CustomerServiceModel = modelFactory.CreateContentModel();
            this.CustomerServiceModel.LoadContext(Vortx.OnePageCheckout.Settings.ConfigurationProvider.DefaultProvider.CustomerServiceTopic);
            this.CustomerServicePanel.StringResourceProvider = this.StringResourceProvider;
            this.CustomerServicePanel.SetModel(this.CustomerServiceModel);
            this.CustomerServicePanel.Initialize();
            this.CustomerServicePanel.Show();
            this.CustomerServicePanel.BindView();

            // if billing equals shipping then copy the shipping address to the billing address
            // TODO: evaluate whether or not this logic is neccessary
            if (this.PaymentModel.ActivePaymentMethod != null)
            {
                if (this.PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.CreditCard)
                {
                    if (this.CreditCardModel != null)
                    {
                        if (this.ShoppingCartModel.ShippingRequired && this.CreditCardModel.BillingEqualsShipping)
                        {
                            this.AccountModel.CopyShippingAddressToBilling();
                        }
                    }
                }
            }

            if (ConfigurationProvider.DefaultProvider.RequireTermsAndConditions)
            {
                IContentModel termsModel = modelFactory.CreateContentModel();
                termsModel.LoadContext(ConfigurationProvider.DefaultProvider.TermsAndConditionsTopicName);
                ContentPanelTerms.StringResourceProvider = this.StringResourceProvider;
                ContentPanelTerms.SetModel(termsModel);
                ContentPanelTerms.BindView();
            }

            if (!Page.IsPostBack)
            {
                this.InitializePage();

                string error = Request.QueryString["error"];
                if (error != null && error.Equals("true"))
                {
                    this.PaymentView.ShowError(StringResourceProvider.GetString("smartcheckout.aspx.130"));
                }

                Page.DataBind();
            }

            StylesheetLiteral.Text = "<link rel=\"stylesheet\" href=\"OPCControls/" + ConfigurationProvider.DefaultProvider.OPCStyleSheetName + "\" />";

            this.UpdatePanelOnePageCheckoutMain.Update();

            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "registerBuySafeKickers", "try{WriteBuySafeKickers();}catch(err){}", true);
            if (ConfigurationProvider.DefaultProvider.BuySafeEnabled)
            {
                OPC_BuySafeWrap.Attributes.Add("style", "height:102px;");
            }
        }
コード例 #15
0
        public PurchaseOrderBillPageViewModel(INavigationService navigationService,
                                              IProductService productService,
                                              IUserService userService,
                                              ITerminalService terminalService,
                                              IWareHousesService wareHousesService,
                                              IAccountingService accountingService,
                                              IPurchaseBillService purchaseBillService,
                                              IManufacturerService manufacturerService,
                                              IMicrophoneService microphoneService,
                                              IDialogService dialogService
                                              ) : base(navigationService, productService, terminalService, userService, wareHousesService, accountingService, dialogService)
        {
            Title = "采购单";

            _purchaseBillService = purchaseBillService;
            _manufacturerService = manufacturerService;

            _microphoneService = microphoneService;


            InitBill();


            //验证
            var valid_IsReversed     = this.ValidationRule(x => x.Bill.ReversedStatus, _isBool, "已红冲单据不能操作");
            var valid_IsAudited      = this.ValidationRule(x => x.Bill.AuditedStatus, _isBool, "已审核单据不能操作");
            var valid_ManufacturerId = this.ValidationRule(x => x.Bill.ManufacturerId, _isZero, "供应商未指定");
            var valid_WareHouseId    = this.ValidationRule(x => x.Bill.WareHouseId, _isZero, "仓库未指定");
            var valid_ProductCount   = this.ValidationRule(x => x.Bill.Items.Count, _isZero, "请添加商品项目");
            var valid_SelectesCount  = this.ValidationRule(x => x.PaymentMethods.Selectes.Count, _isZero, "请选择支付方式");


            //初始化
            this.Load = ReactiveCommand.CreateFromTask(() => Task.Run(async() =>
            {
                var whs = await _wareHousesService.GetWareHousesAsync(this.BillType, force: true);
                if (whs != null && whs.FirstOrDefault() != null)
                {
                    var wh = whs.FirstOrDefault();
                    if (Bill.WareHouseId == 0)
                    {
                        WareHouse        = wh;
                        Bill.WareHouseId = wh.Id;
                    }

                    if (string.IsNullOrEmpty(Bill.WareHouseName))
                    {
                        Bill.WareHouseName = wh.Name;
                    }
                }

                var result = await _purchaseBillService.GetInitDataAsync(calToken: new System.Threading.CancellationToken());
                if (result != null)
                {
                    var defaultAccs = result.PurchaseBillAccountings.Select(s => new AccountingModel()
                    {
                        Default              = true,
                        AccountingOptionId   = s.AccountingOptionId,
                        AccountingOptionName = s.AccountingOptionName,
                        AccountCodeTypeId    = s.AccountCodeTypeId,
                        Name = s.Name
                    }).ToList();

                    PaymentMethods.Selectes = new ObservableCollection <AccountingModel>(defaultAccs);
                }
            }));

            //提交单据
            this.SubmitDataCommand = ReactiveCommand.CreateFromTask <object, Unit>(async _ =>
            {
                //await this.Access(AccessGranularityEnum.PurchaseBillsSave);

                return(await this.Access(AccessGranularityEnum.PurchaseBillsSave, async() =>
                {
                    if (this.Bill.ReversedStatus)
                    {
                        _dialogService.ShortAlert("已红冲单据不能操作");
                        return Unit.Default;
                    }

                    if (this.Bill.AuditedStatus)
                    {
                        _dialogService.ShortAlert("已审核单据不能操作");
                        return Unit.Default;
                    }

                    var dateTime = UtcHelper.ConvertDateTimeInt(DateTime.Now.ToUniversalTime());

                    if (Bill.BusinessUserId == 0)
                    {
                        Bill.BusinessUserId = Settings.UserId;
                    }

                    var postMData = new PurchaseItemUpdateModel()
                    {
                        BillNumber = this.Bill.BillNumber,
                        //供应商
                        ManufacturerId = Bill.ManufacturerId,
                        //业务员
                        BusinessUserId = Bill.BusinessUserId,
                        //仓库
                        WareHouseId = Bill.WareHouseId,
                        //交易日期
                        //TransactionDate = DateTime.Now,
                        TransactionDate = dateTime,
                        //按最小单位采购
                        IsMinUnitPurchase = true,
                        //备注
                        Remark = Bill.Remark,
                        //优惠金额
                        PreferentialAmount = Bill.PreferentialAmount,
                        //优惠后金额
                        PreferentialEndAmount = Bill.SumAmount - Bill.PreferentialAmount,
                        //欠款金额
                        OweCash = Bill.OweCash,
                        //商品项目(保存量大于零的商品)
                        Items = Bill.Items?.Where(i => i.Quantity > 0).ToList(),
                        //收款账户
                        Accounting = PaymentMethods.Selectes.Select(a =>
                        {
                            return new AccountMaping()
                            {
                                AccountingOptionId = a.AccountingOptionId,
                                CollectionAmount = a.CollectionAmount,
                                Name = a.Name,
                                BillId = 0,
                            };
                        }).ToList()
                    };

                    return await SubmitAsync(postMData, Bill.Id, _purchaseBillService.CreateOrUpdateAsync, (result) =>
                    {
                        Bill = new PurchaseBillModel();
                    }, token: new System.Threading.CancellationToken());
                }));
            },
                                                                                   this.IsValid());

            //存储记录
            this.SaveCommand = ReactiveCommand.Create <object>(async e =>
            {
                var c1 = this.Bill.ManufacturerId != 0 && this.Bill.ManufacturerId != (Settings.PurchaseBill?.ManufacturerId ?? 0);
                var c3 = this.Bill.WareHouseId != 0 && this.Bill.WareHouseId != (Settings.PurchaseBill?.WareHouseId ?? 0);
                var c4 = this.Bill.Items?.Count != (Settings.PurchaseBill?.Items?.Count ?? 0);
                if (!this.Bill.AuditedStatus && (c1 || c3 || c4))
                {
                    if (!this.Bill.AuditedStatus && !this.Bill.IsSubmitBill)
                    {
                        var ok = await _dialogService.ShowConfirmAsync("你是否要保存单据?", "提示", "确定", "取消");
                        if (ok)
                        {
                            Settings.PurchaseBill = this.Bill;
                        }
                        else
                        {
                            await _navigationService.GoBackAsync();
                        }
                    }
                }
                else
                {
                    await _navigationService.GoBackAsync();
                }
            });

            //商品编辑
            this.ItemSelectedCommand = ReactiveCommand.Create <CollectionView>(async e =>
            {
                if (this.Bill.ReversedStatus)
                {
                    _dialogService.ShortAlert("已红冲单据不能操作");
                    return;
                }

                if (this.Bill.AuditedStatus)
                {
                    _dialogService.ShortAlert("已审核单据不能操作");
                    return;
                }

                if (this.Bill.IsSubmitBill)
                {
                    _dialogService.ShortAlert("已提交的单据不能编辑");
                    return;
                }

                if (e.SelectedItem != null)
                {
                    var item = Selecter;
                    if (item != null)
                    {
                        var product = ProductSeries.Select(p => p).Where(p => p.Id == item.ProductId).FirstOrDefault();
                        if (product != null)
                        {
                            product.UnitId   = item.UnitId;
                            product.Quantity = item.Quantity;
                            product.Price    = item.Price;
                            product.Amount   = item.Amount;
                            product.Remark   = item.Remark;
                            product.Subtotal = item.Subtotal;
                            product.UnitName = item.UnitName;
                            product.GUID     = item.GUID;
                            if (item.BigUnitId > 0)
                            {
                                product.bigOption.Name        = item.UnitName;
                                product.BigPriceUnit.Quantity = item.Quantity;
                                product.BigPriceUnit.UnitId   = item.BigUnitId ?? 0;
                                product.BigPriceUnit.Amount   = item.Amount;
                                product.BigPriceUnit.Remark   = item.Remark;
                            }

                            if (item.SmallUnitId > 0)
                            {
                                product.bigOption.Name          = item.UnitName;
                                product.SmallPriceUnit.Quantity = item.Quantity;
                                product.SmallPriceUnit.UnitId   = item.SmallUnitId ?? 0;
                                product.SmallPriceUnit.Amount   = item.Amount;
                                product.SmallPriceUnit.Remark   = item.Remark;
                            }

                            await this.NavigateAsync("EditProductPage", ("Product", product), ("Reference", PageName), ("Item", item), ("WareHouse", WareHouse));
                        }
                    }
                }
            });

            //添加商品
            this.AddProductCommand = ReactiveCommand.Create <object>(async e =>
            {
                if (!valid_IsAudited.IsValid)
                {
                    _dialogService.ShortAlert("已审核单据不能操作!");
                    return;
                }

                if (!valid_ManufacturerId.IsValid)
                {
                    _dialogService.ShortAlert("请选择供应商!");
                    ((ICommand)ManufacturerSelected)?.Execute(null);
                    return;
                }

                if (!valid_WareHouseId.IsValid || WareHouse == null)
                {
                    _dialogService.ShortAlert("请选择仓库!");
                    ((ICommand)StockSelected)?.Execute(null);
                    return;
                }

                await this.NavigateAsync("SelectProductPage", ("Reference", this.PageName),
                                         ("WareHouse", WareHouse),
                                         ("ManufacturerId", Bill.ManufacturerId),
                                         ("SerchKey", Filter.SerchKey));
            });

            //审核
            this.AuditingDataCommand = ReactiveCommand.CreateFromTask <object>(async _ =>
            {
                //是否具有审核权限
                await this.Access(AccessGranularityEnum.PurchaseBillsApproved);
                await SubmitAsync(Bill.Id, _purchaseBillService.AuditingAsync, async(result) =>
                {
                    //红冲审核水印
                    this.Bill.AuditedStatus = true;

                    var _conn = App.Resolve <ILiteDbService <MessageInfo> >();
                    var ms    = await _conn.Table.FindByIdAsync(SelecterMessage.Id);
                    if (ms != null)
                    {
                        ms.IsRead = true;
                        await _conn.UpsertAsync(ms);
                    }
                });
            }, this.WhenAny(x => x.Bill.Id, (x) => x.GetValue() > 0));

            //启用麦克风
            this.WhenAnyValue(x => x.EnableMicrophone)
            .Subscribe(async x =>
            {
                var micAccessGranted = await _microphoneService.GetPermissionsAsync();
                if (!micAccessGranted)
                {
                    this.Alert("请打开麦克风");
                }
            }).DisposeWith(DeactivateWith);
            //匹配声音
            this.RecognitionCommand = ReactiveCommand.Create(() =>
            {
                if (!valid_ManufacturerId.IsValid)
                {
                    _dialogService.ShortAlert("请选择供应商!");
                    return;
                }

                if (!valid_WareHouseId.IsValid)
                {
                    _dialogService.ShortAlert("请选择仓库!");
                    return;
                }

                RecognitionSpeech((key) =>
                {
                    Filter.SerchKey = key;
                    ((ICommand)this.AddProductCommand)?.Execute(null);
                });
            });

            //切换语音助手
            this.SpeechCommand = ReactiveCommand.Create(() =>
            {
                if (IsFooterVisible)
                {
                    IsVisible       = true;
                    IsExpanded      = true;
                    IsFooterVisible = false;
                }
                else
                {
                    IsVisible       = false;
                    IsExpanded      = false;
                    IsFooterVisible = true;
                }
            });

            //工具栏打印
            this.PrintCommand = ReactiveCommand.Create(async() =>
            {
                if (Bill.Items.Count == 0)
                {
                    Alert("请添加商品项目");
                    return;
                }
                Bill.BillType = BillTypeEnum.PurchaseBill;
                await SelectPrint(Bill);
            });

            //绑定页面菜单
            _popupMenu = new PopupMenu(this, new Dictionary <MenuEnum, Action <SubMenu, ViewModelBase> >
            {
                //支付方式
                { MenuEnum.PAY, (m, vm) => {
                      if (Bill.SumAmount == 0)
                      {
                          this.Alert("请添加商品项目!"); return;
                      }
                      PaymentMethodBaseModel payments = this.PaymentMethods;
                      SelectPaymentMethods(("PaymentMethods", payments),
                                           ("TBalance", this.TBalance),
                                           ("BillType", this.BillType),
                                           ("Reference", PageName));
                  } },
コード例 #16
0
 public void SetModel(PaymentMethodBaseModel model)
 {
     this.PaymentMethodModel = model;
     this.PurchaseOrderModel = (PurchaseOrderPaymentModel)model;
 }
コード例 #17
0
 public void SetModel(PaymentMethodBaseModel model)
 {
     this.PaymentMethodModel   = model;
     this.CCPaymentMethodModel = (CreditCardPaymentModel)model;
 }