public void LoadMethods(string countryName, string cityName, bool displayCertificateMetod, bool hideCashMetod) { var returnPayment = new List<PaymentMethod>(); if (displayCertificateMetod) { var certificateMethod = PaymentService.GetPaymentMethodByType(PaymentType.GiftCertificate); if (certificateMethod == null) { certificateMethod = new PaymentGiftCertificate() { Enabled = true, Name = Resources.Resource.Client_GiftCertificate, Description = Resources.Resource.Payment_GiftCertificateDescription, SortOrder = 0 }; PaymentService.AddPaymentMethod(certificateMethod); } returnPayment.Add(certificateMethod); } else { foreach (var method in PaymentService.GetAllPaymentMethods(true)) { if (method.Type == PaymentType.GiftCertificate) continue; if (hideCashMetod && (method.Type == PaymentType.Cash || method.Type == PaymentType.CashOnDelivery)) continue; if (ShippingMethodId !=0 && ShippingMethodService.IsPaymentNotUsed(ShippingMethodId, method.PaymentMethodID)) continue; if (method.Type == PaymentType.Kupivkredit) { var shpCart = ShoppingCartService.CurrentShoppingCart; var KvkMethos = (Kupivkredit)PaymentService.GetPaymentMethod(method.PaymentMethodID); if (shpCart.TotalPrice <= KvkMethos.MinimumPrice) continue; } if (Ext == null) { if (method.Type != PaymentType.CashOnDelivery && method.Type != PaymentType.PickPoint) returnPayment.Add(method); } else { switch (method.Type) { case PaymentType.CashOnDelivery: if (Ext.Type == ExtendedType.CashOnDelivery && Ext.ShippingId == int.Parse(method.Parameters[CashOnDelivery.ShippingMethodTemplate])) { method.Description = CashOnDelivery.GetDecription(Ext); returnPayment.Add(method); } break; case PaymentType.PickPoint: if (Ext.Type == ExtendedType.Pickpoint && Ext.ShippingId == int.Parse(method.Parameters[PickPoint.ShippingMethodTemplate])) { method.Description = Ext.PickpointAddress; returnPayment.Add(method); } break; default: returnPayment.Add(method); break; } } } } var paymentMethods = UseGeoMapping(returnPayment, countryName, cityName); _selectedIndex = paymentMethods.FindIndex(item => item.PaymentMethodID == SelectedID); lvPaymentMethod.DataSource = paymentMethods; lvPaymentMethod.SelectedIndex = _selectedIndex != -1 ? _selectedIndex : _selectedIndex = 0; lvPaymentMethod.DataBind(); if (paymentMethods.Count > 0) { hfPaymentMethodId.Value = paymentMethods[_selectedIndex].PaymentMethodID.ToString(); } _loaded = true; }
public static List <PaymentMethod> LoadMethods(int shippingMethodId, ShippingOptionEx ext, bool displayCertificateMetod, bool hideCashMetod) { var returnPayment = new List <PaymentMethod>(); if (displayCertificateMetod) { var certificateMethod = GetPaymentMethodByType(PaymentType.GiftCertificate); if (certificateMethod == null) { certificateMethod = new PaymentGiftCertificate { Enabled = true, Name = Resources.Resource.Client_GiftCertificate, Description = Resources.Resource.Payment_GiftCertificateDescription, SortOrder = 0 }; AddPaymentMethod(certificateMethod); } returnPayment.Add(certificateMethod); } else { foreach (var method in GetAllPaymentMethods(true)) { if (method.Type == PaymentType.GiftCertificate) { continue; } if (hideCashMetod && (method.Type == PaymentType.Cash || method.Type == PaymentType.CashOnDelivery)) { continue; } if (shippingMethodId != 0 && ShippingMethodService.IsPaymentNotUsed(shippingMethodId, method.PaymentMethodId)) { continue; } if (method.Type == PaymentType.Kupivkredit) { var shpCart = ShoppingCartService.CurrentShoppingCart; var kvkMethos = (Kupivkredit)GetPaymentMethod(method.PaymentMethodId); if (shpCart.TotalPrice <= kvkMethos.MinimumPrice) { continue; } } if (ext == null) { if (method.Type != PaymentType.CashOnDelivery && method.Type != PaymentType.PickPoint) { returnPayment.Add(method); } } else { switch (method.Type) { case PaymentType.CashOnDelivery: if ((ext.Type.HasFlag(ExtendedType.CashOnDelivery) || ext.Type.HasFlag(ExtendedType.Cdek) || ext.Type.HasFlag(ExtendedType.Checkout)) && ext.ShippingId == int.Parse(method.Parameters[CashOnDelivery.ShippingMethodTemplate])) { method.Description = CashOnDelivery.GetDecription(ext); returnPayment.Add(method); } break; case PaymentType.PickPoint: if (ext.Type == ExtendedType.Pickpoint && ext.ShippingId == int.Parse(method.Parameters[PickPoint.ShippingMethodTemplate])) { method.Description = ext.PickpointAddress; returnPayment.Add(method); } break; default: returnPayment.Add(method); break; } } } } return(returnPayment); }