Search in sources :

Example 1 with ReadableConfiguration

use of com.salesmanager.shop.model.configuration.ReadableConfiguration in project shopizer by shopizer-ecommerce.

the class PaymentConfigurationFacadeImpl method configuration.

@Override
public ReadableConfiguration configuration(String module, MerchantStore store) {
    try {
        ReadableConfiguration config = null;
        List<PaymentMethod> methods = paymentService.getAcceptedPaymentMethods(store);
        Optional<ReadableConfiguration> configuration = methods.stream().filter(m -> module.equals(m.getModule().getCode())).map(m -> this.configuration(m.getInformations(), store)).findFirst();
        if (configuration.isPresent()) {
            config = configuration.get();
        }
        return config;
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Error while getting payment configuration [" + module + "]", e);
    }
}
Also used : PersistableConfiguration(com.salesmanager.shop.model.configuration.PersistableConfiguration) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ServiceException(com.salesmanager.core.business.exception.ServiceException) PaymentService(com.salesmanager.core.business.services.payments.PaymentService) PaymentMethod(com.salesmanager.core.model.payments.PaymentMethod) List(java.util.List) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) Service(org.springframework.stereotype.Service) ReadableConfiguration(com.salesmanager.shop.model.configuration.ReadableConfiguration) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) Optional(java.util.Optional) ConfigurationsFacade(com.salesmanager.shop.store.controller.configurations.ConfigurationsFacade) ServiceException(com.salesmanager.core.business.exception.ServiceException) PaymentMethod(com.salesmanager.core.model.payments.PaymentMethod) ReadableConfiguration(com.salesmanager.shop.model.configuration.ReadableConfiguration) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 2 with ReadableConfiguration

use of com.salesmanager.shop.model.configuration.ReadableConfiguration in project shopizer by shopizer-ecommerce.

the class PaymentConfigurationFacadeImpl method configurations.

@Override
public List<ReadableConfiguration> configurations(MerchantStore store) {
    try {
        List<PaymentMethod> methods = paymentService.getAcceptedPaymentMethods(store);
        List<ReadableConfiguration> configurations = methods.stream().map(m -> configuration(m.getInformations(), store)).collect(Collectors.toList());
        return configurations;
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Error while getting payment configurations", e);
    }
}
Also used : PersistableConfiguration(com.salesmanager.shop.model.configuration.PersistableConfiguration) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ServiceException(com.salesmanager.core.business.exception.ServiceException) PaymentService(com.salesmanager.core.business.services.payments.PaymentService) PaymentMethod(com.salesmanager.core.model.payments.PaymentMethod) List(java.util.List) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) Service(org.springframework.stereotype.Service) ReadableConfiguration(com.salesmanager.shop.model.configuration.ReadableConfiguration) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) Optional(java.util.Optional) ConfigurationsFacade(com.salesmanager.shop.store.controller.configurations.ConfigurationsFacade) ServiceException(com.salesmanager.core.business.exception.ServiceException) PaymentMethod(com.salesmanager.core.model.payments.PaymentMethod) ReadableConfiguration(com.salesmanager.shop.model.configuration.ReadableConfiguration) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 3 with ReadableConfiguration

use of com.salesmanager.shop.model.configuration.ReadableConfiguration in project shopizer by shopizer-ecommerce.

the class PaymentConfigurationFacadeImpl method configuration.

private ReadableConfiguration configuration(IntegrationConfiguration source, MerchantStore store) {
    ReadableConfiguration config = new ReadableConfiguration();
    config.setActive(source.isActive());
    config.setCode(source.getModuleCode());
    config.setKeys(source.getIntegrationKeys());
    config.setIntegrationOptions(source.getIntegrationOptions());
    return config;
}
Also used : ReadableConfiguration(com.salesmanager.shop.model.configuration.ReadableConfiguration)

Aggregations

ReadableConfiguration (com.salesmanager.shop.model.configuration.ReadableConfiguration)3 ServiceException (com.salesmanager.core.business.exception.ServiceException)2 PaymentService (com.salesmanager.core.business.services.payments.PaymentService)2 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)2 PaymentMethod (com.salesmanager.core.model.payments.PaymentMethod)2 IntegrationConfiguration (com.salesmanager.core.model.system.IntegrationConfiguration)2 PersistableConfiguration (com.salesmanager.shop.model.configuration.PersistableConfiguration)2 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)2 ConfigurationsFacade (com.salesmanager.shop.store.controller.configurations.ConfigurationsFacade)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2