// SANITY CHECK : CHECK IF THE OPTIN ALREADY EXIST FOR THE MARKET AREA
if(customer != null){
CustomerMarketArea customerMarketArea = customer.getCurrentCustomerMarketArea(marketArea.getId());
if(customerMarketArea != null){
CustomerOptin customerOptin = customerMarketArea.getOptins(CustomerOptin.OPTIN_TYPE_WWW_NEWSLETTER);
if(customerOptin != null){
throw new UniqueNewsletterSubscriptionException();
}
}
}
CustomerOptin customerOptin = new CustomerOptin();
customerOptin.setType(CustomerOptin.OPTIN_TYPE_WWW_NEWSLETTER);
customerOptin.setOrigin("MCOMMERCE");
// HANDLE OPTIN
if(customer != null){
customer = checkCustomerMarketArea(requestData, customer);
CustomerMarketArea customerMarketArea = customer.getCurrentCustomerMarketArea(marketArea.getId());