private function config(MvcEvent $e)
 {
     $routeMatch = $e->getRouteMatch();
     if ($routeMatch) {
         $headerContent = $e->getRequest()->getHeaders();
         $merchantId = $headerContent->get('MERCHANT-ID');
         $merchantLanguage = $headerContent->get('MERCHANT-LANGUAGE');
         $mainKey = $headerContent->get('MAIN-KEY');
         if (!$e->getRequest()->isPost() && $mainKey) {
             $mainKey = null;
         }
         if ($mainKey && !in_array($mainKey->getFieldValue(), Module::getMainKeys()) || !$mainKey && !$merchantId) {
             $e->getResponse()->setStatusCode(403);
             throw new \Exception('Request Not Authenticated');
         }
         if ($mainKey) {
             Module::setMainKey($mainKey->getFieldValue());
         }
         if ($merchantLanguage) {
             $systemLanguage = Module::getRepository('SystemLanguage')->findOneBy(array('name' => $merchantLanguage->getFieldValue()));
             if ($systemLanguage) {
                 Module::setMerchantLanguage($merchantLanguage->getFieldValue());
             } else {
                 $e->getResponse()->setStatusCode(404);
                 throw new \Exception('MERCHANT-LANGUAGE Is Not Found');
             }
         } else {
             $e->getResponse()->setStatusCode(401);
             throw new \Exception('MERCHANT-LANGUAGE Not Specified');
         }
         if ($merchantId) {
             $currentMerchant = Module::getRepository('Merchant')->findOneBy(array('language' => Module::getRepository('SystemLanguage')->findOneBy(array('name' => Module::getMerchantLanguage())), 'apiPublicKey' => $merchantId->getFieldValue()));
             if ($currentMerchant) {
                 Module::setApiPublicKey($currentMerchant->getApiPublicKey());
             } else {
                 $e->getResponse()->setStatusCode(403);
                 throw new \Exception('Request Not Authenticated');
             }
         }
     }
 }