Limiting payment methods to specific user roles.
Hi, is there a way to limit a user's choice of payment methods in checkout based on their user role?
Hi,
You could achieve the desired functionality by replacing the EcommercePaymentMethodService. This service implements an interface IEcommercePaymentMethodService and it has one very important method GetApplicablePaymentMethods(CheckoutState checkoutState, CartOrder cartOrder). This method returns which are the payment methods for a particular client. In this method you could add a filter by role. After you extend it you need to override our default implementation by adding the following code in Global.asax file in your project:
private
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
if
(e.CommandName ==
"Bootstrapped"
)
// Register the new Type of the IEcommercePaymentMethodService
ObjectFactory.Container.RegisterType
<IEcommercePaymentMethodService, CustomBensEcommercePaymentMethodService>(
new
ContainerControlledLifetimeManager(),
new
InjectionConstructor());
That worked quite well thank you.