public ActionResult SelectWallet(WalletSelectViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.CreditCard, ControllerNames.CheckoutCreditCard)); } var customer = HttpContext.GetCustomer(); if (!customer.Owns.Wallet(model.SelectedPaymentProfileId)) { throw new HttpException(403, "Forbidden"); } customer.UpdateCustomer(requestedPaymentMethod: AppLogic.ro_PMCreditCard); customer.ThisCustomerSession["ActivePaymentProfileId"] = model.SelectedPaymentProfileId.ToString(); var paymentProfile = WalletProvider.GetPaymentProfile(customer, model.SelectedPaymentProfileId); var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var expirationDate = new DateTime( year: int.Parse(paymentProfile.ExpirationYear), month: int.Parse(paymentProfile.ExpirationMonth), day: DateTime.Now.Day); PersistedCheckoutContextProvider.SaveCheckoutContext( customer: customer, checkoutContext: new PersistedCheckoutContext( creditCard: new CreditCardDetails( name: string.Format("{0} {1}", customer.FirstName, customer.LastName), number: paymentProfile.CreditCardNumberMasked, issueNumber: null, cardType: paymentProfile.CardType, expirationDate: expirationDate, startDate: null, cvv: string.Empty), payPalExpress: checkoutContext.PayPalExpress, purchaseOrder: checkoutContext.PurchaseOrder, braintree: checkoutContext.Braintree, amazonPayments: null, termsAndConditionsAccepted: checkoutContext.TermsAndConditionsAccepted, over13Checked: checkoutContext.Over13Checked, shippingEstimateDetails: checkoutContext.ShippingEstimateDetails, offsiteRequiresBillingAddressId: null, offsiteRequiresShippingAddressId: null, email: checkoutContext.Email, selectedShippingMethodId: checkoutContext.SelectedShippingMethodId)); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public ActionResult SelectWallet(WalletSelectViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.CreditCard, ControllerNames.CheckoutCreditCard)); } var customer = HttpContext.GetCustomer(); if (!customer.Owns.Wallet(model.SelectedPaymentProfileId)) { throw new HttpException(403, "Forbidden"); } customer.UpdateCustomer(requestedPaymentMethod: AppLogic.ro_PMCreditCard); customer.ThisCustomerSession["ActivePaymentProfileId"] = model.SelectedPaymentProfileId.ToString(); var paymentProfile = WalletProvider.GetPaymentProfile(customer, model.SelectedPaymentProfileId); var expirationDate = new DateTime( year: int.Parse(paymentProfile.ExpirationYear), month: int.Parse(paymentProfile.ExpirationMonth), day: DateTime.Now.Day); PersistedCheckoutContextProvider.SaveCheckoutContext( customer: customer, checkoutContext: new PersistedCheckoutContextBuilder() .From(PersistedCheckoutContextProvider.LoadCheckoutContext(customer)) .WithCreditCard(new CreditCardDetails( name: string.Format("{0} {1}", customer.FirstName, customer.LastName), number: paymentProfile.CreditCardNumberMasked, issueNumber: null, cardType: paymentProfile.CardType, expirationDate: expirationDate, startDate: null, cvv: string.Empty)) .WithoutAmazonPayments() .WithoutOffsiteRequiredBillingAddressId() .WithoutOffsiteRequiredShippingAddressId() .Build()); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }