public override void Process()

in src/Feature/Cart/code/Pipelines/Payments/GetPaymentMethods.cs [50:97]


        public override void Process(Commerce.Pipelines.ServicePipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentCondition(args.Request is CommerceGetPaymentMethodsRequest, "args.Request", "args.Request is CommerceGetPaymentMethodsRequest");
            Assert.ArgumentCondition(args.Result is GetPaymentMethodsResult, "args.Result", "args.Result is GetPaymentMethodsResult");

            var request = (CommerceGetPaymentMethodsRequest)args.Request;
            var result = (GetPaymentMethodsResult)args.Result;

            if (request.PaymentOption.PaymentOptionType == null)
            {
                base.Process(args);
                return;
            }

            Item paymentOptionsItem = this.GetPaymentOptionsItem();

            string query = string.Format(CultureInfo.InvariantCulture, "fast:{0}//*[@{1} = '{2}']", paymentOptionsItem.Paths.FullPath, CommerceServerStorefrontConstants.KnownFieldNames.PaymentOptionValue, request.PaymentOption.PaymentOptionType.Value);
            Item foundOption = paymentOptionsItem.Database.SelectSingleItem(query);
            if (foundOption != null)
            {
                string paymentMethodsIds = foundOption[CommerceServerStorefrontConstants.KnownFieldNames.CommerceServerPaymentMethods];
                if (!string.IsNullOrWhiteSpace(paymentMethodsIds))
                {
                    base.Process(args);
                    if (result.Success)
                    {
                        List<PaymentMethod> currentList = new List<PaymentMethod>(result.PaymentMethods);
                        List<PaymentMethod> returnList = new List<PaymentMethod>();

                        string[] ids = paymentMethodsIds.Split('|');
                        foreach (string id in ids)
                        {
                            string trimmedId = id.Trim();

                            var found2 = currentList.Find(o => o.ExternalId.Equals(trimmedId, StringComparison.OrdinalIgnoreCase));
                            PaymentMethod found = currentList.Find(o => o.ExternalId.Equals(trimmedId, StringComparison.OrdinalIgnoreCase));
                            if (found != null)
                            {
                                returnList.Add(found);
                            }
                        }

                        result.PaymentMethods = new System.Collections.ObjectModel.ReadOnlyCollection<PaymentMethod>(returnList);
                    }
                }
            }
        }