/// <summary>
        /// Initializes a new instance of the <see cref="BraintreeSubscriptionRecordPaymentMethod"/> class.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="paymentMethod">
        /// The payment method.
        /// </param>
        /// <param name="braintreeApiService">The <see cref="IBraintreeApiService"/></param>
        public BraintreeSubscriptionRecordPaymentMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IBraintreeApiService braintreeApiService)
            : base(gatewayProviderService, paymentMethod)
        {
            Mandate.ParameterNotNull(braintreeApiService, "braintreeApiService");

            _braintreeApiService = braintreeApiService;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BraintreePaymentGatewayMethodBase"/> class.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="paymentMethod">
        /// The payment method.
        /// </param>
        /// <param name="braintreeApiService">
        /// The braintree api service.
        /// </param>
        protected BraintreePaymentGatewayMethodBase(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IBraintreeApiService braintreeApiService)
            : base(gatewayProviderService, paymentMethod)
        {
            Mandate.ParameterNotNull(braintreeApiService, "braintreeApiService");

            _braintreeApiService = braintreeApiService;
        }
        protected override IPaymentResult PerformProcessPayment(SalePreparationBase preparation, IPaymentMethod paymentMethod)
        {
            // We have to use the CheckoutConfirmationModel in this implementation.  If this were to be used
            // outside of a demo, you could consider writing your own base controller that inherits directly from
            // Merchello.Web.Mvc.PaymentMethodUiController<TModel> and complete the transaction there in which case the
            // BazaarPaymentMethodFormControllerBase would be a good example.

            var form = UmbracoContext.HttpContext.Request.Form;
            var DebitOrderNumber = form.Get("DebitOrderNumber");

            if (string.IsNullOrEmpty(DebitOrderNumber))
            {
                var invalidData = new InvalidDataException("The Purchase Order Number cannot be an empty string");
                return new PaymentResult(Attempt<IPayment>.Fail(invalidData), null, false);
            }

            // You need a ProcessorArgumentCollection for this transaction to store the payment method nonce
            // The braintree package includes an extension method off of the ProcessorArgumentCollection - SetPaymentMethodNonce([nonce]);
            var args = new ProcessorArgumentCollection();
            args.SetDebitOrderNumber(DebitOrderNumber);

            // We will want this to be an Authorize(paymentMethod.Key, args);
            // -- Also in a real world situation you would want to validate the PO number somehow.
            return preparation.AuthorizePayment(paymentMethod.Key, args);
        }
Пример #4
0
        protected PaymentGatewayMethodBase(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod)
        {
            Mandate.ParameterNotNull(gatewayProviderService, "gatewayProviderService");
            Mandate.ParameterNotNull(paymentMethod, "paymentMethod");

            _gatewayProviderService = gatewayProviderService;
            _paymentMethod = paymentMethod;
        }
Пример #5
0
 public void MakePayment(decimal amount, IPaymentMethod paymentMethod=null)
 {
     if (paymentMethod != null)
     {
         PaymentMethod = paymentMethod;
     }
     Console.WriteLine("{0} will paid with {1}", Name, PaymentMethod.Name);
     PaymentMethod.Pay(amount);
 }
Пример #6
0
        public static AutoOrderPaymentType GetAutoOrderPaymentType(IPaymentMethod paymentMethod)
        {
            if (!(paymentMethod is IAutoOrderPaymentMethod)) throw new Exception("The provided payment method does not implement IAutoOrderPaymentMethod.");

            if (paymentMethod is CreditCard) return ((CreditCard)paymentMethod).AutoOrderPaymentType;
            if (paymentMethod is BankAccount) return ((BankAccount)paymentMethod).AutoOrderPaymentType;
            if (paymentMethod is Ideal) return ((Ideal)paymentMethod).AutoOrderPaymentType;

            return AutoOrderPaymentType.WillSendPayment;
        }
        // AuthorizeCapturePayment will save the invoice with an Invoice Number.
        private IPaymentResult ProcessPayment(SalePreparationBase preparation, IPaymentMethod paymentMethod, string paymentMethodNonce)
        {
            // You need a ProcessorArgumentCollection for this transaction to store the payment method nonce
            // The braintree package includes an extension method off of the ProcessorArgumentCollection - SetPaymentMethodNonce([nonce]);
            var args = new ProcessorArgumentCollection();
            args.SetPaymentMethodNonce(paymentMethodNonce);

            // We will want this to be an AuthorizeCapture(paymentMethod.Key, args);
            return preparation.AuthorizeCapturePayment(paymentMethod.Key, args);
        }
        /// <summary>
        /// Responsible for actually processing the payment with the PaymentProvider
        /// </summary>
        /// <param name="preparation">
        /// The preparation.
        /// </param>
        /// <param name="paymentMethod">
        /// The payment method.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentResult"/>.
        /// </returns>
        protected override IPaymentResult PerformProcessPayment(SalePreparationBase preparation, IPaymentMethod paymentMethod)
        {
            // ----------------------------------------------------------------------------
            // WE NEED TO GET THE PAYMENT METHOD "NONCE" FOR BRAINTREE

            var form = UmbracoContext.HttpContext.Request.Form;
            var paymentMethodNonce = form.Get("payment_method_nonce");

            // ----------------------------------------------------------------------------

            return this.ProcessPayment(preparation, paymentMethod, paymentMethodNonce);
        }
Пример #9
0
        public IPaymentProcessor Get(IPaymentMethod paymentMethod)
        {
            #region Preconditions

            if (paymentMethod == null) throw new ArgumentNullException("paymentMethod");

            #endregion

            var processor = processors.FirstOrDefault(p => p.Accepts(paymentMethod));

            if (processor == null)
            {
                throw new Exception("No registered processors accept '{0}'.".FormatWith(paymentMethod.GetType().ToString()));
            }

            return processor;
        }
Пример #10
0
 public HomeController(IDbContext context, IAuthenticationService authenticationService, IWorkContext workContext, ICustomerService customerService,
     IQuestionAnswerEntityData questionAnswerEntityDataService, HttpContextBase httpContext,
     IPaymentMethod paymentMethod, IOrderService orderService, IWebHelper webHelper,
     IWorkflowMessageService workflowMessageService, IZipCodeService zipCodeService,
     IDbContext dbContext)
 {
     this._context = context;
     this._authenticationService = authenticationService;
     this._customerService = customerService;
     this._workContext = workContext;
     this._questionAnswerEntityDataService = questionAnswerEntityDataService;
     this._httpContext = httpContext;
     this._paymentMethod = paymentMethod;
     this._orderService = orderService;
     this._webHelper = webHelper;
     this._workflowMessageService = workflowMessageService;
     this._zipCodeService = zipCodeService;
     this._dbContext = dbContext;
 }
Пример #11
0
        /// <summary>
        /// Check out a shopping cart
        /// </summary>
        /// <param name="purchaseItemList"></param>
        /// <param name="customer"></param>
        /// <param name="payment"></param>
        /// <param name="shippingMethod"></param>
        public static CustomerOrder Checkout(IPurchaseItemList purchaseItemList, CustomerBase customer, IPaymentMethod payment, IShippingMethod shippingMethod)
        {
            var customerOrder = new CustomerOrder();
            customerOrder.OrderDateTime = DateTime.Now;
            purchaseItemList.Items.ForEach(i => customerOrder.Items.Add(i.Clone()));
            customerOrder.Customer = customer;
            customerOrder.Status = EOrderStatus.Processing;
            customerOrder.ShippingMethod = shippingMethod.MethodName();
            customerOrder.PaymentMethod = payment.PaymentName();
            customerOrder.ProductCost = purchaseItemList.GetTotalPrice();
            customerOrder.ShippingCost = GetShippingCost(customer, shippingMethod);
            customerOrder.TotalCost = customerOrder.ProductCost + customerOrder.ShippingCost;

            payment.Charge(customerOrder.TotalCost);

            //todo : persist order

            return customerOrder;
        }
Пример #12
0
        /// <summary>
        /// Deletes a single <see cref="IPaymentMethod"/>
        /// </summary>
        /// <param name="paymentMethod">The <see cref="IPaymentMethod"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IPaymentMethod paymentMethod, bool raiseEvents = true)
        {
            if (raiseEvents)
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<IPaymentMethod>(paymentMethod), this))
                {
                    ((PaymentMethod)paymentMethod).WasCancelled = true;
                    return;
                }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreatePaymentMethodRepository(uow))
                {
                    repository.Delete(paymentMethod);
                    uow.Commit();
                }
            }

            if (raiseEvents) Deleted.RaiseEvent(new DeleteEventArgs<IPaymentMethod>(paymentMethod), this);
        }
Пример #13
0
 /// <summary>
 /// Saves a <see cref="IPaymentMethod"/> to <see cref="ICustomerBase"/> extended data
 /// </summary>
 /// <param name="paymentMethod">
 /// The payment Method.
 /// </param>
 public void SavePaymentMethod(IPaymentMethod paymentMethod)
 {
     _customer.ExtendedData.AddPaymentMethod(paymentMethod);
     SaveCustomer(_merchelloContext, _customer, RaiseCustomerEvents);
 }
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BraintreePaymentGatewayMethodBase"/> class.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="paymentMethod">
        /// The payment method.
        /// </param>
        /// <param name="braintreeApiService">
        /// The braintree api service.
        /// </param>
        protected BraintreePaymentGatewayMethodBase(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IBraintreeApiService braintreeApiService)
            : base(gatewayProviderService, paymentMethod)
        {
            Mandate.ParameterNotNull(braintreeApiService, "braintreeApiService");

            _braintreeApiService = braintreeApiService;
        }
        public ActionResult UsePaymentMethod(IPaymentMethod paymentMethod, int PaymentTypeID = 0)
        {
            try
            {
                // Check for redirect payment type : 999 = Ideal
                if (PaymentTypeID == 999)
                {
                    var ideal = paymentMethod.As<Ideal>();
                    PropertyBag.PaymentMethod = ideal;
                    PropertyBag.PaymentTypeID = 999;
                    PropertyBag.IsRedirectPayment = true;
                    Exigo.PropertyBags.Update(PropertyBag);

                }
                else
                {
                    var message = "";

                    if (paymentMethod.CanBeParsedAs<CreditCard>())
                    {
                        var creditCard = paymentMethod.As<CreditCard>();
                        PropertyBag.PaymentMethod = creditCard;
                        PropertyBag.IsRedirectPayment = false;
                        Exigo.PropertyBags.Update(PropertyBag);

                        if (creditCard.IsExpired)
                        {
                            message = "Please enter a card that is not expired before proceeding.";

                            return new JsonNetResult(new
                            {
                                success = false,
                                message = message
                            });
                        }

                        if (!creditCard.IsComplete)
                        {
                            message = "Please enter a card that is complete before proceeding.";

                            return new JsonNetResult(new
                            {
                                success = false,
                                message = message
                            });
                        }

                        //if (paymentMethod.IsValid)
                        //{
                        //    PropertyBag.PaymentMethod = paymentMethod;
                        //    Exigo.PropertyBags.Update(PropertyBag);

                        //}
                    }
                }

                return new JsonNetResult(new
                {
                    success = true
                });
            }
            catch (Exception ex)
            {
                return new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                });
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChasePaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 /// <param name="providerExtendedData">
 /// The provider extended data.
 /// </param>
 public ChasePaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, ExtendedDataCollection providerExtendedData)
     : base(gatewayProviderService, paymentMethod)
 {
     _processor = new ChasePaymentProcessor(providerExtendedData.GetProcessorSettings());
 }
 /// <summary>
 /// Responsible for actually processing the payment with the PaymentProvider
 /// </summary>
 /// <param name="checkoutManager">
 /// The preparation.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 /// <returns>
 /// The <see cref="IPaymentResult"/>.
 /// </returns>
 protected abstract IPaymentResult PerformProcessPayment(ICheckoutManagerBase checkoutManager, IPaymentMethod paymentMethod);
Пример #18
0
 private CheckoutViewModel CreateCheckoutViewModel(CheckoutPage currentPage, IPaymentMethod paymentOption = null) => _checkoutViewModelFactory.CreateCheckoutViewModel(CartWithValidationIssues.Cart, currentPage, paymentOption);
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeVaultPaymentGatewayMethodBase"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 /// <param name="braintreeApiService">
 /// The braintree api service.
 /// </param>
 protected BraintreeVaultPaymentGatewayMethodBase(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IBraintreeApiService braintreeApiService)
     : base(gatewayProviderService, paymentMethod, braintreeApiService)
 {
 }
Пример #20
0
        public async Task <ActionResult> Purchase(CheckoutViewModel viewModel, IPaymentMethod paymentOption)
        {
            if (CartIsNullOrEmpty())
            {
                return(Redirect(Url.ContentUrl(ContentReference.StartPage)));
            }

            // Since the payment property is marked with an exclude binding attribute in the CheckoutViewModel
            // it needs to be manually re-added again.
            //viewModel.Payments = paymentOption;

            if (User.Identity.IsAuthenticated)
            {
                _checkoutService.CheckoutAddressHandling.UpdateAuthenticatedUserAddresses(viewModel);

                var validation = _checkoutService.AuthenticatedPurchaseValidation;

                if (!validation.ValidateModel(ModelState, viewModel) ||
                    !validation.ValidateOrderOperation(ModelState, _cartService.ValidateCart(CartWithValidationIssues.Cart)) ||
                    !validation.ValidateOrderOperation(ModelState, _cartService.RequestInventory(CartWithValidationIssues.Cart)))
                {
                    return(View(viewModel));
                }
            }
            else
            {
                _checkoutService.CheckoutAddressHandling.UpdateAnonymousUserAddresses(viewModel);

                var validation = _checkoutService.AnonymousPurchaseValidation;

                if (!validation.ValidateModel(ModelState, viewModel) ||
                    !validation.ValidateOrderOperation(ModelState, _cartService.ValidateCart(CartWithValidationIssues.Cart)) ||
                    !validation.ValidateOrderOperation(ModelState, _cartService.RequestInventory(CartWithValidationIssues.Cart)))
                {
                    return(View(viewModel));
                }
            }

            if (!paymentOption.ValidateData())
            {
                return(View(viewModel));
            }

            _checkoutService.UpdateShippingAddresses(CartWithValidationIssues.Cart, viewModel);

            _checkoutService.CreateAndAddPaymentToCart(CartWithValidationIssues.Cart, viewModel);

            var purchaseOrder = _checkoutService.PlaceOrder(CartWithValidationIssues.Cart, ModelState, viewModel);

            if (purchaseOrder == null)
            {
                return(View(viewModel));
            }

            if (Request.IsAuthenticated)
            {
                var contact      = _customerContext.GetCurrentContact().Contact;
                var organization = contact.ContactOrganization;
                if (organization != null)
                {
                    purchaseOrder.Properties[Constant.Customer.CustomerFullName]            = contact.FullName;
                    purchaseOrder.Properties[Constant.Customer.CustomerEmailAddress]        = contact.Email;
                    purchaseOrder.Properties[Constant.Customer.CurrentCustomerOrganization] = organization.Name;
                    _orderRepository.Save(purchaseOrder);
                }
            }

            var confirmationSentSuccessfully = _checkoutService.SendConfirmation(viewModel, purchaseOrder);
            //await _checkoutService.CreateOrUpdateBoughtProductsProfileStore(CartWithValidationIssues.Cart);
            //await _checkoutService.CreateBoughtProductsSegments(CartWithValidationIssues.Cart);
            await _recommendationService.TrackOrder(HttpContext, purchaseOrder);

            return(Redirect(_checkoutService.BuildRedirectionUrl(viewModel, purchaseOrder, confirmationSentSuccessfully)));
        }
Пример #21
0
        public ActionResult RemovePayment(CheckoutPage currentPage, CheckoutViewModel viewModel, IPaymentMethod paymentOption)
        {
            if (!paymentOption.ValidateData())
            {
                return(View(viewModel));
            }

            viewModel.Payment = paymentOption;
            _checkoutService.RemovePaymentFromCart(CartWithValidationIssues.Cart, viewModel);
            _orderRepository.Save(CartWithValidationIssues.Cart);

            var model = CreateCheckoutViewModel(currentPage);

            model.OrderSummary = _orderSummaryViewModelFactory.CreateOrderSummaryViewModel(CartWithValidationIssues.Cart);
            if (Request.IsAuthenticated)
            {
                model.BillingAddressType = 1;
            }
            else
            {
                model.BillingAddressType = 0;
            }
            return(PartialView("_AddPayment", model));
        }
Пример #22
0
 public BankPaymentBuilder WithPaymentMethod(IPaymentMethod value)
 {
     PaymentMethod = value;
     return(this);
 }
Пример #23
0
 internal ManagementBuilder WithPaymentMethod(IPaymentMethod value)
 {
     PaymentMethod = value;
     return(this);
 }
 internal AuthorizationBuilder(TransactionType type, IPaymentMethod payment = null) : base(type)
 {
     WithPaymentMethod(payment);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SagePayFormPaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The <see cref="GatewayProviderService"/>.
 /// </param>
 /// <param name="paymentMethod">
 /// The <see cref="IPaymentMethod"/>.
 /// </param>
 /// <param name="extendedData">
 /// The SagePay providers <see cref="ExtendedDataCollection"/>
 /// </param>
 public SagePayFormPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, ExtendedDataCollection extendedData)
     : base(gatewayProviderService, paymentMethod, extendedData)
 {
     // New instance of the SagePay payment processor
     _processor = new SagePayFormPaymentProcessor(extendedData.GetProcessorSettings());
 }
Пример #26
0
        public Transaction ProcessSecure3d(Secure3dBuilder builder)
        {
            TransactionType transType     = builder.TransactionType;
            IPaymentMethod  paymentMethod = builder.PaymentMethod;
            ISecure3d       secure3d      = (ISecure3d)paymentMethod;
            string          timestamp     = DateTime.Now.ToString("yyyy-MM-dd'T'hh:mm:ss.ffffff");

            JsonDoc request = new JsonDoc();

            if (transType.Equals(TransactionType.VerifyEnrolled))
            {
                request.Set("request_timestamp", timestamp);
                request.Set("merchant_id", MerchantId);
                request.Set("account_id", AccountId);
                request.Set("method_notification_url", MethodNotificationUrl);

                string hashValue = string.Empty;
                if (paymentMethod is CreditCardData cardData)
                {
                    request.Set("number", cardData.Number);
                    request.Set("scheme", MapCardScheme(CardUtils.GetBaseCardType(cardData.CardType).ToUpper()));
                    hashValue = cardData.Number;
                }
                else if (paymentMethod is RecurringPaymentMethod storedCard)
                {
                    request.Set("payer_reference", storedCard.CustomerKey);
                    request.Set("payment_method_reference", storedCard.Key);
                    hashValue = storedCard.CustomerKey;
                }

                string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, hashValue);
                SetAuthHeader(hash);

                string rawResponse = DoTransaction(HttpMethod.Post, "protocol-versions", request.ToString());
                return(MapResponse(rawResponse));
            }
            else if (transType.Equals(TransactionType.VerifySignature))
            {
                string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, builder.ServerTransactionId);
                SetAuthHeader(hash);

                var queryValues = new Dictionary <string, string>();
                queryValues.Add("merchant_id", MerchantId);
                queryValues.Add("request_timestamp", timestamp);

                string rawResponse = DoTransaction(HttpMethod.Get, string.Format("authentications/{0}", builder.ServerTransactionId), null, queryValues);
                return(MapResponse(rawResponse));
            }
            else if (transType.Equals(TransactionType.InitiateAuthentication))
            {
                string orderId = builder.OrderId;
                if (string.IsNullOrEmpty(orderId))
                {
                    orderId = GenerationUtils.GenerateOrderId();
                }
                ThreeDSecure secureEcom = secure3d.ThreeDSecure;

                request.Set("request_timestamp", timestamp);
                request.Set("authentication_source", builder.AuthenticationSource.ToString());
                request.Set("authentication_request_type", builder.AuthenticationRequestType.ToString());
                request.Set("message_category", builder.MessageCategory.ToString());
                request.Set("message_version", "2.1.0");
                request.Set("server_trans_id", secureEcom.ServerTransactionId);
                request.Set("merchant_id", MerchantId);
                request.Set("account_id", AccountId);
                request.Set("challenge_notification_url", ChallengeNotificationUrl);
                request.Set("challenge_request_indicator", builder.ChallengeRequestIndicator.ToString());
                request.Set("method_url_completion", builder.MethodUrlCompletion.ToString());
                request.Set("merchant_contact_url", MerchantContactUrl);
                request.Set("merchant_initiated_request_type", builder.MerchantInitiatedRequestType?.ToString());
                request.Set("whitelist_status", builder.WhitelistStatus);
                request.Set("decoupled_flow_request", builder.DecoupledFlowRequest);
                request.Set("decoupled_flow_timeout", builder.DecoupledFlowTimeout);
                request.Set("decoupled_notification_url", builder.DecoupledNotificationUrl);
                request.Set("enable_exemption_optimization", builder.EnableExemptionOptimization);

                // card details
                string  hashValue  = string.Empty;
                JsonDoc cardDetail = request.SubElement("card_detail");
                if (paymentMethod is CreditCardData cardData)
                {
                    hashValue = cardData.Number;
                    cardDetail.Set("number", cardData.Number);
                    cardDetail.Set("scheme", CardUtils.GetBaseCardType(cardData.CardType).ToUpper());
                    cardDetail.Set("expiry_month", cardData.ExpMonth.ToString());
                    cardDetail.Set("expiry_year", cardData.ExpYear.ToString().Substring(2));
                    cardDetail.Set("full_name", cardData.CardHolderName);

                    if (!string.IsNullOrEmpty(cardData.CardHolderName))
                    {
                        string[] names = cardData.CardHolderName.Split(' ');
                        if (names.Length >= 1)
                        {
                            cardDetail.Set("first_name", names[0]);
                        }
                        if (names.Length >= 2)
                        {
                            cardDetail.Set("last_name", string.Join(" ", names.Skip(1)));
                        }
                    }
                }
                else if (paymentMethod is RecurringPaymentMethod storedCard)
                {
                    hashValue = storedCard.CustomerKey;
                    cardDetail.Set("payer_reference", storedCard.CustomerKey);
                    cardDetail.Set("payment_method_reference", storedCard.Key);
                }

                // order details
                JsonDoc order = request.SubElement("order");
                order.Set("amount", builder.Amount.ToNumericCurrencyString());
                order.Set("currency", builder.Currency);
                order.Set("id", orderId);
                order.Set("address_match_indicator", builder.AddressMatchIndicator ? "true" : "false");
                order.Set("date_time_created", builder.OrderCreateDate?.ToString("yyyy-MM-dd'T'hh:mm'Z'"));
                order.Set("gift_card_count", builder.GiftCardCount);
                order.Set("gift_card_currency", builder.GiftCardCurrency);
                order.Set("gift_card_amount", builder.GiftCardAmount.ToNumericCurrencyString());
                order.Set("delivery_email", builder.DeliveryEmail);
                order.Set("delivery_timeframe", builder.DeliveryTimeframe?.ToString());
                order.Set("shipping_method", builder.ShippingMethod?.ToString());
                order.Set("shipping_name_matches_cardholder_name", builder.ShippingNameMatchesCardHolderName);
                order.Set("preorder_indicator", builder.PreOrderIndicator?.ToString());
                order.Set("reorder_indicator", builder.ReorderIndicator?.ToString());
                order.Set("transaction_type", builder.OrderTransactionType?.ToString());
                order.Set("preorder_availability_date", builder.PreOrderAvailabilityDate?.ToString("yyyy-MM-dd"));

                // shipping address
                Address shippingAddress = builder.ShippingAddress;
                if (shippingAddress != null)
                {
                    JsonDoc shippingAddressElement = order.SubElement("shipping_address");
                    shippingAddressElement.Set("line1", shippingAddress.StreetAddress1);
                    shippingAddressElement.Set("line2", shippingAddress.StreetAddress2);
                    shippingAddressElement.Set("line3", shippingAddress.StreetAddress3);
                    shippingAddressElement.Set("city", shippingAddress.City);
                    shippingAddressElement.Set("postal_code", shippingAddress.PostalCode);
                    shippingAddressElement.Set("state", shippingAddress.State);
                    shippingAddressElement.Set("country", shippingAddress.CountryCode);
                }

                // payer
                JsonDoc payer = request.SubElement("payer");
                payer.Set("email", builder.CustomerEmail);
                payer.Set("id", builder.CustomerAccountId);
                payer.Set("account_age", builder.AccountAgeIndicator?.ToString());
                payer.Set("account_creation_date", builder.AccountCreateDate?.ToString("yyyy-MM-dd"));
                payer.Set("account_change_indicator", builder.AccountChangeIndicator?.ToString());
                payer.Set("account_change_date", builder.AccountChangeDate?.ToString("yyyy-MM-dd"));
                payer.Set("account_password_change_indicator", builder.PasswordChangeIndicator?.ToString());
                payer.Set("account_password_change_date", builder.PasswordChangeDate?.ToString("yyyy-MM-dd"));
                payer.Set("payment_account_age_indicator", builder.PaymentAgeIndicator?.ToString());
                payer.Set("payment_account_creation_date", builder.PaymentAccountCreateDate?.ToString("yyyy-MM-dd"));
                payer.Set("purchase_count_last_6months", builder.NumberOfPurchasesInLastSixMonths);
                payer.Set("transaction_count_last_24hours", builder.NumberOfTransactionsInLast24Hours);
                payer.Set("transaction_count_last_year", builder.NumberOfTransactionsInLastYear);
                payer.Set("provision_attempt_count_last_24hours", builder.NumberOfAddCardAttemptsInLast24Hours);
                payer.Set("shipping_address_creation_indicator", builder.ShippingAddressUsageIndicator?.ToString());
                payer.Set("shipping_address_creation_date", builder.ShippingAddressCreateDate?.ToString("yyyy-MM-dd"));

                // suspicious activity
                if (builder.PreviousSuspiciousActivity != null)
                {
                    payer.Set("suspicious_account_activity", builder.PreviousSuspiciousActivity.Value ? "SUSPICIOUS_ACTIVITY" : "NO_SUSPICIOUS_ACTIVITY");
                }

                // home phone
                if (!string.IsNullOrEmpty(builder.HomeNumber))
                {
                    payer.SubElement("home_phone")
                    .Set("country_code", builder.HomeCountryCode.ToNumeric())
                    .Set("subscriber_number", builder.HomeNumber.ToNumeric());
                }

                // work phone
                if (!string.IsNullOrEmpty(builder.WorkNumber))
                {
                    payer.SubElement("work_phone")
                    .Set("country_code", builder.WorkCountryCode.ToNumeric())
                    .Set("subscriber_number", builder.WorkNumber.ToNumeric());
                }

                // payer login data
                if (builder.HasPayerLoginData)
                {
                    request.SubElement("payer_login_data")
                    .Set("authentication_data", builder.CustomerAuthenticationData)
                    .Set("authentication_timestamp", builder.CustomerAuthenticationTimestamp?.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'"))
                    .Set("authentication_type", builder.CustomerAuthenticationMethod?.ToString());
                }

                // prior authentication data
                if (builder.HasPriorAuthenticationData)
                {
                    request.SubElement("payer_prior_three_ds_authentication_data")
                    .Set("authentication_method", builder.PriorAuthenticationMethod?.ToString())
                    .Set("acs_transaction_id", builder.PriorAuthenticationTransactionId)
                    .Set("authentication_timestamp", builder.PriorAuthenticationTimestamp?.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'"))
                    .Set("authentication_data", builder.PriorAuthenticationData);
                }

                // recurring authorization data
                if (builder.HasRecurringAuthData)
                {
                    request.SubElement("recurring_authorization_data")
                    .Set("max_number_of_instalments", builder.MaxNumberOfInstallments)
                    .Set("frequency", builder.RecurringAuthorizationFrequency)
                    .Set("expiry_date", builder.RecurringAuthorizationExpiryDate?.ToString("yyyy-MM-dd"));
                }

                // billing details
                Address billingAddress = builder.BillingAddress;
                if (billingAddress != null)
                {
                    JsonDoc billingAddressElement = payer.SubElement("billing_address");
                    billingAddressElement.Set("line1", billingAddress.StreetAddress1);
                    billingAddressElement.Set("line2", billingAddress.StreetAddress2);
                    billingAddressElement.Set("line3", billingAddress.StreetAddress3);
                    billingAddressElement.Set("city", billingAddress.City);
                    billingAddressElement.Set("postal_code", billingAddress.PostalCode);
                    billingAddressElement.Set("state", billingAddress.State);
                    billingAddressElement.Set("country", billingAddress.CountryCode);
                }

                // mobile phone
                if (!string.IsNullOrEmpty(builder.MobileNumber))
                {
                    JsonDoc mobilePhone = payer.SubElement("mobile_phone");
                    mobilePhone.Set("country_code", builder.MobileCountryCode.ToNumeric());
                    mobilePhone.Set("subscriber_number", builder.MobileNumber.ToNumeric());
                }

                // browser_data
                BrowserData broswerData = builder.BrowserData;
                if (broswerData != null)
                {
                    JsonDoc browserDataElement = request.SubElement("browser_data");
                    browserDataElement.Set("accept_header", broswerData.AcceptHeader);
                    browserDataElement.Set("color_depth", broswerData.ColorDepth.ToString());
                    browserDataElement.Set("ip", broswerData.IpAddress);
                    browserDataElement.Set("java_enabled", broswerData.JavaEnabled);
                    browserDataElement.Set("javascript_enabled", broswerData.JavaScriptEnabled);
                    browserDataElement.Set("language", broswerData.Language);
                    browserDataElement.Set("screen_height", broswerData.ScreenHeight);
                    browserDataElement.Set("screen_width", broswerData.ScreenWidth);
                    browserDataElement.Set("challenge_window_size", broswerData.ChallengeWindowSize.ToString());
                    browserDataElement.Set("timezone", broswerData.Timezone);
                    browserDataElement.Set("user_agent", broswerData.UserAgent);
                }

                // mobile fields
                if (builder.HasMobileFields)
                {
                    JsonDoc sdkInformationElement = request.SubElement("sdk_information")
                                                    .Set("application_id", builder.ApplicationId)
                                                    .Set("ephemeral_public_key", builder.EphemeralPublicKey)
                                                    .Set("maximum_timeout", builder.MaximumTimeout)
                                                    .Set("reference_number", builder.ReferenceNumber)
                                                    .Set("sdk_trans_id", builder.SdkTransactionId)
                                                    .Set("encoded_data", builder.EncodedData)
                    ;

                    // device render options
                    if (builder.SdkInterface != null || builder.SdkUiTypes != null)
                    {
                        var dro = sdkInformationElement.SubElement("device_render_options");
                        dro.Set("sdk_interface", builder.SdkInterface?.ToString());
                        if (builder.SdkUiTypes != null)
                        {
                            var uiTypes = new List <string>();
                            foreach (var sdkuiType in builder.SdkUiTypes)
                            {
                                uiTypes.Add(sdkuiType.ToString());
                            }
                            dro.Set("sdk_ui_type", uiTypes.ToArray());
                        }
                    }
                }

                string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, hashValue, secureEcom.ServerTransactionId);
                SetAuthHeader(hash);

                string rawResponse = DoTransaction(HttpMethod.Post, "authentications", request.ToString());
                return(MapResponse(rawResponse));
            }

            throw new ApiException(string.Format("Unknown transaction type {0}.", transType));
        }
Пример #27
0
        /// <summary>
        /// Saves a list of coutnry identifiers in which a certain payment method is now allowed
        /// </summary>
        /// <param name="paymentMethod">Payment method</param>
        /// <param name="countryIds">A list of country identifiers</param>
        public virtual void SaveRestictedCountryIds(IPaymentMethod paymentMethod, List<int> countryIds)
        {
            if (paymentMethod == null)
                throw new ArgumentNullException("paymentMethod");

            //we should be sure that countryIds is of type List<int> (not IList<int>)
            var settingKey = string.Format("PaymentMethodRestictions.{0}", paymentMethod.PluginDescriptor.SystemName);
            _settingService.SetSetting(settingKey, countryIds);
        }
Пример #28
0
        public virtual CheckoutViewModel CreateCheckoutViewModel(ICart cart, CheckoutPage currentPage, IPaymentMethod paymentOption = null)
        {
            if (cart == null)
            {
                return(CreateEmptyCheckoutViewModel(currentPage));
            }

            var currentShippingAddressId = cart.GetFirstShipment()?.ShippingAddress?.Id;
            var currentBillingAdressId   = cart.GetFirstForm().Payments.FirstOrDefault()?.BillingAddress?.Id;

            var shipments = _shipmentViewModelFactory.CreateShipmentsViewModel(cart).ToList();
            var useShippingAddressForBilling = shipments.Count == 1;

            var viewModel = new CheckoutViewModel(currentPage)
            {
                Shipments      = shipments,
                BillingAddress = CreateBillingAddressModel(currentBillingAdressId),
                UseShippingingAddressForBilling = useShippingAddressForBilling,
                AppliedCouponCodes = cart.GetFirstForm().CouponCodes.Distinct(),
                AvailableAddresses = new List <AddressModel>(),
                ReferrerUrl        = GetReferrerUrl(),
                Currency           = cart.Currency,
                CurrentCustomer    = _customerService.GetCurrentContactViewModel(),
                IsOnHoldBudget     = CheckForOnHoldBudgets(),
                Payment            = paymentOption,
                PaymentPlanSetting = new PaymentPlanSetting()
                {
                    CycleMode = Mediachase.Commerce.Orders.PaymentPlanCycle.None,
                    IsActive  = false,
                    StartDate = DateTime.UtcNow
                },
            };

            UpdatePayments(viewModel, cart);

            var availableAddresses = GetAvailableAddresses();

            if (availableAddresses.Any())
            {
                //viewModel.AvailableAddresses.Add(new AddressModel { Name = _localizationService.GetString("/Checkout/MultiShipment/SelectAddress"), AddressId = "" });

                foreach (var address in availableAddresses)
                {
                    viewModel.AvailableAddresses.Add(address);
                }
            }
            else
            {
                viewModel.AvailableAddresses.Add(new AddressModel {
                    Name = _localizationService.GetString("/Checkout/MultiShipment/NoAddressFound"), AddressId = ""
                });
            }

            SetDefaultShipmentAddress(viewModel, currentShippingAddressId);

            _addressBookService.LoadAddress(viewModel.BillingAddress);
            PopulateCountryAndRegions(viewModel);

            return(viewModel);
        }
Пример #29
0
        public virtual CheckoutViewModel CreateCheckoutViewModel(ICart cart, CheckoutPage currentPage, IPaymentMethod paymentMethod = null)
        {
            if (cart == null)
            {
                return(CreateEmptyCheckoutViewModel(currentPage));
            }

            var currentShippingAddressId = cart.GetFirstShipment()?.ShippingAddress?.Id;
            var currentBillingAdressId   = cart.GetFirstForm().Payments.FirstOrDefault()?.BillingAddress?.Id;

            var shipments = _shipmentViewModelFactory.CreateShipmentsViewModel(cart).ToList();
            var useBillingAddressForShipment = shipments.Count == 1 && currentBillingAdressId == currentShippingAddressId && _addressBookService.UseBillingAddressForShipment();

            var payments = _paymentMethodViewModelFactory.CreatePaymentMethodSelectionViewModel(paymentMethod);

            paymentMethod = payments.SelectedPaymentMethod.PaymentMethod;

            var viewModel = new CheckoutViewModel
            {
                CurrentPage    = currentPage,
                Shipments      = shipments,
                BillingAddress = CreateBillingAddressModel(),
                UseBillingAddressForShipment = useBillingAddressForShipment,
                StartPage          = _contentLoader.Get <StartPage>(ContentReference.StartPage),
                AppliedCouponCodes = cart.GetFirstForm().CouponCodes.Distinct(),
                AvailableAddresses = new List <AddressModel>(),
                ReferrerUrl        = GetReferrerUrl(),
                Payment            = paymentMethod,
            };

            var availableAddresses = GetAvailableAddresses();

            if (availableAddresses.Any())
            {
                viewModel.AvailableAddresses.Add(new AddressModel {
                    Name = _localizationService.GetString("/Checkout/MultiShipment/SelectAddress")
                });

                foreach (var address in availableAddresses)
                {
                    viewModel.AvailableAddresses.Add(address);
                }
            }
            else
            {
                viewModel.AvailableAddresses.Add(new AddressModel {
                    Name = _localizationService.GetString("/Checkout/MultiShipment/NoAddressFound")
                });
            }

            SetDefaultShipmentAddress(viewModel, currentShippingAddressId);

            _addressBookService.LoadAddress(viewModel.BillingAddress);
            PopulateCountryAndRegions(viewModel);

            viewModel.KlarnaCheckoutPaymentMethodSelected = viewModel.Payment?.SystemKeyword == Constants.KlarnaCheckoutSystemKeyword;

            return(viewModel);
        }
Пример #30
0
 /// <summary>
 /// Gets a list of coutnry identifiers in which a certain payment method is now allowed
 /// </summary>
 /// <param name="paymentMethod">Payment method</param>
 /// <returns>A list of country identifiers</returns>
 public IList <int> GetRestictedCountryIds(IPaymentMethod paymentMethod)
 {
     return(_paymentService.GetRestictedCountryIds(paymentMethod));
 }
Пример #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeStandardPaymentGatewayBase"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 /// <param name="braintreeApiService">
 /// The braintree api service.
 /// </param>
 protected BraintreeStandardPaymentGatewayBase(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IBraintreeApiService braintreeApiService)
     : base(gatewayProviderService, paymentMethod, braintreeApiService)
 {
 }
Пример #32
0
 /// <summary>
 /// Saves a list of coutnry identifiers in which a certain payment method is now allowed
 /// </summary>
 /// <param name="paymentMethod">Payment method</param>
 /// <param name="countryIds">A list of country identifiers</param>
 public void SaveRestictedCountryIds(IPaymentMethod paymentMethod, List <int> countryIds)
 {
     _paymentService.SaveRestictedCountryIds(paymentMethod, countryIds);
 }
 internal static PaymentMethodDisplay ToPaymentMethodDisplay(this IPaymentMethod paymentMethod)
 {
     return(AutoMapper.Mapper.Map <PaymentMethodDisplay>(paymentMethod));
 }
Пример #34
0
 public CashPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod)
     : base(gatewayProviderService, paymentMethod)
 {
 }
 /// <summary>
 /// Saves a <see cref="IPaymentMethod"/> to <see cref="ICustomerBase"/> extended data
 /// </summary>
 /// <param name="paymentMethod">
 /// The payment Method.
 /// </param>
 public override void SavePaymentMethod(IPaymentMethod paymentMethod)
 {
     this.Context.Customer.ExtendedData.AddPaymentMethod(paymentMethod);
     this.SaveCustomer();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeSimpleTransactionPaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 /// <param name="braintreeApiService">
 /// The braintree Api Service.
 /// </param>
 public BraintreeSimpleTransactionPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IBraintreeApiService braintreeApiService)
     : base(gatewayProviderService, paymentMethod, braintreeApiService)
 {
 }
Пример #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RedirectPaymentMethodBase"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 protected RedirectPaymentMethodBase(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod)
     : base(gatewayProviderService, paymentMethod)
 {
 }
        internal static IPaymentMethod ToPaymentMethod(this PaymentMethodDisplay paymentMethodDisplay, IPaymentMethod destination)
        {
            if (paymentMethodDisplay.Key != Guid.Empty)
            {
                destination.Key = paymentMethodDisplay.Key;
            }

            destination.Name        = paymentMethodDisplay.Name;
            destination.PaymentCode = paymentMethodDisplay.PaymentCode;
            destination.Description = paymentMethodDisplay.Description;

            return(destination);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CashPaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 public CashPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod)
     : base(gatewayProviderService, paymentMethod)
 {
 }
Пример #40
0
 public bool HasValidPaymentMethod(IPaymentMethod paymentMethod)
 {
     return(paymentMethod != null &&
            (paymentMethod is CreditCard || paymentMethod is BankAccount));
 }
Пример #41
0
 /// <summary>
 /// Saves a <see cref="IPaymentMethod"/> to an extended data collection
 /// </summary>
 /// <param name="extendedData">
 /// The extended Data.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment Method.
 /// </param>
 internal static void AddPaymentMethod(this ExtendedDataCollection extendedData, IPaymentMethod paymentMethod)
 {
     extendedData.SetValue(Constants.ExtendedDataKeys.PaymentMethod, paymentMethod.Key.ToString());
 }
 public void SelectPaymentMethod(IPaymentMethod paymentMethod)
 {
     _paymentMethod = paymentMethod;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PayPalExpressCheckoutPaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 /// <param name="paypalApiService">
 /// The <see cref="IPayPalApiService"/>.
 /// </param>
 public PayPalExpressCheckoutPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IPayPalApiService paypalApiService)
     : base(gatewayProviderService, paymentMethod)
 {
     Ensure.ParameterNotNull(paypalApiService, "payPalApiService");
     this._paypalApiService = paypalApiService;
 }
Пример #44
0
 public static PaymentMethodModel ToModel(this IPaymentMethod entity)
 {
     return(entity.MapTo <IPaymentMethod, PaymentMethodModel>());
 }
        protected JsonResult OpcLoadStepAfterPaymentMethod(IPaymentMethod paymentMethod, List<ShoppingCartItem> cart)
        {
            if (paymentMethod.SkipPaymentInfo)
            {
                //skip payment info page
                var paymentInfo = new ProcessPaymentRequest();
                //session save
                _httpContext.Session["OrderPaymentInfo"] = paymentInfo;

                var confirmOrderModel = PrepareConfirmOrderModel(cart);
                return Json(new
                {
                    update_section = new UpdateSectionJsonModel()
                    {
                        name = "confirm-order",
                        html = this.RenderPartialViewToString("OpcConfirmOrder", confirmOrderModel)
                    },
                    goto_section = "confirm_order"
                });
            }
            else
            {
                //return payment info page
                var paymenInfoModel = PreparePaymentInfoModel(paymentMethod);
                return Json(new
                {
                    update_section = new UpdateSectionJsonModel()
                    {
                        name = "payment-info",
                        html = this.RenderPartialViewToString("OpcPaymentInfo", paymenInfoModel)
                    },
                    goto_section = "payment_info"
                });
            }
        }
 public PayPalPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, ExtendedDataCollection providerExtendedData)
     : base(gatewayProviderService, paymentMethod)
 {
     _processor = new PayPalPaymentProcessor(providerExtendedData.GetProcessorSettings());
 }
Пример #47
0
        /// <summary>
        /// Gets a list of coutnry identifiers in which a certain payment method is now allowed
        /// </summary>
        /// <param name="paymentMethod">Payment method</param>
        /// <returns>A list of country identifiers</returns>
        public virtual IList<int> GetRestictedCountryIds(IPaymentMethod paymentMethod)
        {
            if (paymentMethod == null)
                throw new ArgumentNullException("paymentMethod");

            var settingKey = string.Format("PaymentMethodRestictions.{0}", paymentMethod.PluginDescriptor.SystemName);
            var restictedCountryIds = _settingService.GetSettingByKey<List<int>>(settingKey);
            if (restictedCountryIds == null)
                restictedCountryIds = new List<int>();
            return restictedCountryIds;
        }
Пример #48
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PaymentGatewayMethodBase"/> class.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="paymentMethod">
        /// The payment method.
        /// </param>
        protected PaymentGatewayMethodBase(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod)
        {
            Mandate.ParameterNotNull(gatewayProviderService, "gatewayProviderService");
            Mandate.ParameterNotNull(paymentMethod, "paymentMethod");

            _gatewayProviderService = gatewayProviderService;
            _paymentMethod          = paymentMethod;
        }
Пример #49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BraintreeVaultTransactionPaymentGatewayMethod"/> class.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="paymentMethod">
 /// The payment method.
 /// </param>
 /// <param name="braintreeApiService">
 /// The braintree api service.
 /// </param>
 public BraintreeVaultTransactionPaymentGatewayMethod(IGatewayProviderService gatewayProviderService, IPaymentMethod paymentMethod, IBraintreeApiService braintreeApiService)
     : base(gatewayProviderService, paymentMethod, braintreeApiService)
 {
 }
 /// <summary>
 /// Deletes a single <see cref="IPaymentMethod"/>
 /// </summary>
 /// <param name="paymentMethod">The <see cref="IPaymentMethod"/> to be deleted</param> 
 public void Delete(IPaymentMethod paymentMethod)
 {
     _paymentMethodService.Delete(paymentMethod);
 }
Пример #51
0
 protected CheckoutPaymentInfoModel PreparePaymentInfoModel(IPaymentMethod paymentMethod)
 {
     var model = new CheckoutPaymentInfoModel();
     string actionName;
     string controllerName;
     RouteValueDictionary routeValues;
     paymentMethod.GetPaymentInfoRoute(out actionName, out controllerName, out routeValues);
     model.PaymentInfoActionName = actionName;
     model.PaymentInfoControllerName = controllerName;
     model.PaymentInfoRouteValues = routeValues;
     model.DisplayOrderTotals = _orderSettings.OnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab;
     return model;
 }
        internal static IPaymentMethod ToPaymentMethod(this PaymentMethodDisplay paymentMethodDisplay, IPaymentMethod destination)
        {
            if (paymentMethodDisplay.Key != Guid.Empty) destination.Key = paymentMethodDisplay.Key;

            destination.Name = paymentMethodDisplay.Name;
            destination.PaymentCode = paymentMethodDisplay.PaymentCode;
            destination.Description = paymentMethodDisplay.Description;

            return destination;
        }
Пример #53
0
        private bool IsValidPaymentForm(IPaymentMethod paymentMethod, FormCollection form)
        {
            var paymentControllerType = paymentMethod.GetControllerType();
            var paymentController = DependencyResolver.Current.GetService(paymentControllerType) as PaymentControllerBase;
            var warnings = paymentController.ValidatePaymentForm(form);

            foreach (var warning in warnings)
            {
                ModelState.AddModelError("", warning);
            }

            if (ModelState.IsValid)
            {
                var paymentInfo = paymentController.GetPaymentInfo(form);
                _httpContext.Session["OrderPaymentInfo"] = paymentInfo;

                _httpContext.GetCheckoutState().PaymentSummary = paymentController.GetPaymentSummary(form);

                return true;
            }

            return false;
        }
Пример #54
0
 /// <summary>
 /// Deletes a single <see cref="IPaymentMethod"/>
 /// </summary>
 /// <param name="paymentMethod">The <see cref="IPaymentMethod"/> to be deleted</param>
 public void Delete(IPaymentMethod paymentMethod)
 {
     _paymentMethodService.Delete(paymentMethod);
 }
Пример #55
0
 public PaymentMethodViewModel(IPaymentMethod method, RenderContext context)
 {
     this.Icon        = method.Icon;
     this.IconType    = method.IconType;
     this.DisplayName = method.Name;
 }
Пример #56
0
 public TransactionBuilder(TransactionType type, IPaymentMethod paymentMethod = null) : base()
 {
     TransactionType = type;
     PaymentMethod   = paymentMethod;
 }
 /// <summary>
 /// Saves a single <see cref="IPaymentMethod"/>
 /// </summary>
 /// <param name="paymentMethod">The <see cref="IPaymentMethod"/> to be saved</param>        
 public void Save(IPaymentMethod paymentMethod)
 {
     _paymentMethodService.Save(paymentMethod);
 }
Пример #58
0
        public ActionResult Update(CheckoutPage currentPage, UpdateShippingMethodViewModel shipmentViewModel, IPaymentMethod paymentOption)
        {
            ModelState.Clear();

            _checkoutService.UpdateShippingMethods(CartWithValidationIssues.Cart, shipmentViewModel.Shipments);
            _checkoutService.ApplyDiscounts(CartWithValidationIssues.Cart);
            _orderRepository.Save(CartWithValidationIssues.Cart);

            var viewModel = CreateCheckoutViewModel(currentPage, paymentOption);

            return(PartialView("Partial", viewModel));
        }
Пример #59
0
 /// <summary>
 /// Saves a <see cref="IPaymentMethod"/> to <see cref="ICustomerBase"/> extended data
 /// </summary>
 /// <param name="paymentMethod">
 /// The payment Method.
 /// </param>
 public void SavePaymentMethod(IPaymentMethod paymentMethod)
 {
     _customer.ExtendedData.AddPaymentMethod(paymentMethod);
 }
Пример #60
0
 /// <summary>
 /// Saves a single <see cref="IPaymentMethod"/>
 /// </summary>
 /// <param name="paymentMethod">The <see cref="IPaymentMethod"/> to be saved</param>
 public void Save(IPaymentMethod paymentMethod)
 {
     _paymentMethodService.Save(paymentMethod);
 }