use of com.salesmanager.shop.model.system.IntegrationModuleConfiguration in project shopizer by shopizer-ecommerce.
the class PaymentApi method configure.
@PostMapping(value = "/private/modules/payment")
public void configure(@RequestBody IntegrationModuleConfiguration configuration, @ApiIgnore MerchantStore merchantStore) {
try {
List<IntegrationModule> modules = paymentService.getPaymentMethods(merchantStore);
Map<String, IntegrationModule> map = modules.stream().collect(Collectors.toMap(IntegrationModule::getCode, module -> module));
IntegrationModule config = map.get(configuration.getCode());
if (config == null) {
throw new ResourceNotFoundException("Payment module [" + configuration.getCode() + "] not found");
}
Map<String, IntegrationConfiguration> configuredModules = paymentService.getPaymentModulesConfigured(merchantStore);
IntegrationConfiguration integrationConfiguration = configuredModules.get(configuration.getCode());
if (integrationConfiguration == null) {
integrationConfiguration = new IntegrationConfiguration();
integrationConfiguration.setModuleCode(configuration.getCode());
}
integrationConfiguration.setActive(configuration.isActive());
integrationConfiguration.setDefaultSelected(configuration.isDefaultSelected());
integrationConfiguration.setIntegrationKeys(configuration.getIntegrationKeys());
integrationConfiguration.setIntegrationOptions(configuration.getIntegrationOptions());
paymentService.savePaymentModuleConfiguration(integrationConfiguration, merchantStore);
} catch (ServiceException e) {
LOGGER.error("Error getting payment modules", e);
throw new ServiceRuntimeException("Error saving payment module", e);
}
}
use of com.salesmanager.shop.model.system.IntegrationModuleConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingConfigurationApi method configure.
@PostMapping(value = "/private/modules/shipping")
public void configure(@RequestBody IntegrationModuleConfiguration configuration, @ApiIgnore MerchantStore merchantStore) {
try {
List<IntegrationModule> modules = shippingService.getShippingMethods(merchantStore);
Map<String, IntegrationModule> map = modules.stream().collect(Collectors.toMap(IntegrationModule::getCode, module -> module));
IntegrationModule config = map.get(configuration.getCode());
if (config == null) {
throw new ResourceNotFoundException("Shipping module [" + configuration.getCode() + "] not found");
}
Map<String, IntegrationConfiguration> configuredModules = shippingService.getShippingModulesConfigured(merchantStore);
IntegrationConfiguration integrationConfiguration = configuredModules.get(configuration.getCode());
if (integrationConfiguration == null) {
integrationConfiguration = new IntegrationConfiguration();
}
/**
* Build return object for now this is a read copy
*/
integrationConfiguration.setActive(configuration.isActive());
integrationConfiguration.setDefaultSelected(configuration.isDefaultSelected());
integrationConfiguration.setIntegrationKeys(configuration.getIntegrationKeys());
integrationConfiguration.setIntegrationOptions(configuration.getIntegrationOptions());
shippingService.saveShippingQuoteModuleConfiguration(integrationConfiguration, merchantStore);
} catch (ServiceException e) {
LOGGER.error("Error saving shipping modules", e);
throw new ServiceRuntimeException("Error saving shipping module", e);
}
}
use of com.salesmanager.shop.model.system.IntegrationModuleConfiguration in project shopizer by shopizer-ecommerce.
the class PaymentApi method paymentModule.
/**
* Get merchant payment module details
*
* @param code
* @param merchantStore
* @param language
* @return
*/
@GetMapping("/private/modules/payment/{code}")
@ApiOperation(httpMethod = "GET", value = "Payment module by code", produces = "application/json", response = List.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT") })
public IntegrationModuleConfiguration paymentModule(@PathVariable String code, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
try {
// get module
IntegrationModule integrationModule = paymentService.getPaymentMethodByCode(merchantStore, code);
if (integrationModule == null) {
throw new ResourceNotFoundException("Payment module [" + code + "] not found");
}
IntegrationModuleConfiguration returnConfig = new IntegrationModuleConfiguration();
returnConfig.setConfigurable(integrationModule.getConfigurable());
returnConfig.setActive(false);
returnConfig.setDefaultSelected(false);
returnConfig.setCode(code);
// configured modules
IntegrationConfiguration config = paymentService.getPaymentConfiguration(code, merchantStore);
if (config == null) {
return returnConfig;
}
/**
* Build return object for now this is a read copy
*/
returnConfig.setActive(config.isActive());
returnConfig.setDefaultSelected(config.isDefaultSelected());
returnConfig.setCode(code);
returnConfig.setIntegrationKeys(config.getIntegrationKeys());
returnConfig.setIntegrationOptions(config.getIntegrationOptions());
return returnConfig;
} catch (ServiceException e) {
LOGGER.error("Error getting payment module [" + code + "]", e);
throw new ServiceRuntimeException("Error getting payment module [" + code + "]", e);
}
}
Aggregations