protected function checkForSentRegistration()
 {
     if (Tools::isSubmit('registration' . $this->name)) {
         $terms_and_conditions = Tools::getIsset('terms_and_conditions');
         if (!$terms_and_conditions) {
             exit(Tools::jsonEncode(array('result' => 'terms_not_accepted')));
         }
         $registration = new YousticeShopRegistration();
         $shop_currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
         $shop_lang = new Language(Configuration::get('PS_LANG_DEFAULT'));
         $registration->setCompanyName(Tools::getValue('company_name', ''))->setEmail(Tools::getValue('email', ''))->setPassword(Tools::getValue('password', ''))->setFirstName(Tools::getValue('first_name', ''))->setLastName(Tools::getValue('last_name', ''))->setVerifyPasswordValue(Tools::getValue('verify_password', ''))->setShopUrl(Tools::getValue('shop_url', ''))->setCompanyIsInFrance(Tools::getIsset('company_is_in_france'))->setIsFrenchForm(Tools::getIsset('is_french_form'))->setAdminLang($this->context->language->iso_code)->setDefaultCountry($this->context->country->iso_code)->setShopName(Configuration::get('PS_SHOP_NAME'))->setShopCurrency($shop_currency->iso_code)->setShopLang($shop_lang->iso_code)->setShopLogoPath(_PS_IMG_DIR_ . Configuration::get('PS_LOGO'));
         try {
             $api_key = $this->y_api->runWithoutUpdates()->register($registration);
         } catch (YousticeShopRegistrationValidationException $e) {
             $response = Tools::jsonEncode(array('result' => $e->getMessage()));
             exit($response);
         } catch (YousticeShopRegistrationShopAlreadyRegistered $e) {
             $this->saveErrorMessage($this->l('Registration failed: Email is already in use.'));
             $response = Tools::jsonEncode(array('result' => true));
             exit($response);
         } catch (YousticeFailedRemoteConnectionException $e) {
             $response = Tools::jsonEncode(array('result' => 'request_failed'));
             exit($response);
         }
         Configuration::updateValue('YRS_API_KEY', $api_key);
         Configuration::updateValue('YRS_SANDBOX', false);
         $this->saveConfirmMessage($this->l('Settings saved. Integration with Youstice successfully configured.'));
         $response = Tools::jsonEncode(array('result' => true));
         exit($response);
     }
 }