Exemple #1
0
        public ManagerResponse <GetPaymentMethodsResult, IEnumerable <PaymentMethod> > GetPaymentMethods(string userId, PaymentOption paymentOption)
        {
            Assert.ArgumentNotNull(paymentOption, nameof(paymentOption));

            var result = new GetPaymentMethodsResult {
                Success = false
            };
            var cartResult = CartManager.GetCart(userId);

            if (!cartResult.ServiceProviderResult.Success || cartResult.Result == null)
            {
                result.SystemMessages.ToList().AddRange(cartResult.ServiceProviderResult.SystemMessages);
                return(new ManagerResponse <GetPaymentMethodsResult, IEnumerable <PaymentMethod> >(result, null));
            }

            var request = new GetPaymentMethodsRequest(cartResult.Result, paymentOption);

            result = PaymentServiceProvider.GetPaymentMethods(request);
            result.WriteToSitecoreLog();

            return(new ManagerResponse <GetPaymentMethodsResult, IEnumerable <PaymentMethod> >(result, result.PaymentMethods.ToList()));
        }