public function updateStatus(OrderEvent $event) { $order = $event->getOrder(); if ($order->isPaid() && $order->getPaymentModuleId() == Atos::getModuleId()) { if (Atos::getConfigValue('send_payment_confirmation_message')) { $this->mailer->sendEmailToCustomer(Atos::CONFIRMATION_MESSAGE_NAME, $order->getCustomer(), ['order_id' => $order->getId(), 'order_ref' => $order->getRef()]); } // Send confirmation email if required. if (Atos::getConfigValue('send_confirmation_message_only_if_paid')) { $event->getDispatcher()->dispatch(TheliaEvents::ORDER_SEND_CONFIRMATION_EMAIL, $event); } Tlog::getInstance()->debug("Confirmation email sent to customer " . $order->getCustomer()->getEmail()); } }
public function update($currentVersion, $newVersion, ConnectionInterface $con = null) { // Migrate old configuration if (null === self::getConfigValue('atos_merchantId', null)) { if (null !== ($atosConfigs = ConfigQuery::create()->filterByName('atos_%', Criteria::LIKE)->find())) { /** @var Config $atosConfig */ foreach ($atosConfigs as $atosConfig) { Atos::setConfigValue($atosConfig->getName(), $atosConfig->getValue()); $atosConfig->delete($con); } } } parent::update($currentVersion, $newVersion, $con); }
public function configure() { if (null !== ($response = $this->checkAuth(AdminResources::MODULE, 'atos', AccessManager::UPDATE))) { return $response; } $configurationForm = $this->createForm('atos_configuration'); $message = null; try { $form = $this->validateForm($configurationForm); // Get the form field values $data = $form->getData(); foreach ($data as $name => $value) { if (is_array($value)) { $value = implode(';', $value); } Atos::setConfigValue($name, $value); } $merchantId = $data['atos_merchantId']; $this->checkExecutable('request'); $this->checkExecutable('response'); $this->copyDistFile('parmcom', $merchantId); $certificateFile = $this->copyDistFile('certif.fr', $merchantId); // Write certificate if (!@file_put_contents($certificateFile, $data['atos_certificate'])) { throw new FileException($this->getTranslator()->trans("Failed to write certificate data in file '%file'. Please check file permission", ['%file' => $certificateFile], Atos::MODULE_DOMAIN)); } // Log configuration modification $this->adminLogAppend("atos.configuration.message", AccessManager::UPDATE, "Atos configuration updated"); // Redirect to the success URL, if ($this->getRequest()->get('save_mode') == 'stay') { // If we have to stay on the same page, redisplay the configuration page/ $url = '/admin/module/Atos'; } else { // If we have to close the page, go back to the module back-office page. $url = '/admin/modules'; } return $this->generateRedirect(URL::getInstance()->absoluteUrl($url)); } catch (FormValidationException $ex) { $message = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { $message = $ex->getMessage(); } $this->setupFormErrorContext($this->getTranslator()->trans("Atos configuration", [], Atos::MODULE_DOMAIN), $message, $configurationForm, $ex); // Before 2.2, the errored form is not stored in session if (Version::test(Thelia::THELIA_VERSION, '2.2', false, "<")) { return $this->render('module-configure', ['module_code' => 'Atos']); } else { return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/Atos')); } }
public function processAtosRequest() { $this->getLog()->addInfo($this->getTranslator()->trans("Atos-SIPS platform request received.", [], Atos::MODULE_DOMAIN)); $binResponse = Atos::getBinDirectory() . 'response'; if (!empty($_POST['DATA'])) { $data = escapeshellcmd($_POST['DATA']); $pathfile = Atos::getPathfilePath(); $resultRaw = exec(sprintf("%s message=%s pathfile=%s", $binResponse, $data, $pathfile)); if (!empty($resultRaw)) { $result = explode('!', $resultRaw); $result = $this->parseResult($result); $this->getLog()->addInfo($this->getTranslator()->trans('Response parameters : %resp', ['%resp' => print_r($result, true)], Atos::MODULE_DOMAIN)); if ($result['code'] == '' && $result['error'] == '') { $this->getLog()->addError($this->getTranslator()->trans('Response request not found in %response', ['%response' => $binResponse], Atos::MODULE_DOMAIN)); } elseif (intval($result['code']) != 0) { $this->getLog()->addError($this->getTranslator()->trans('Error %code while processing response, with message %message', ['%code' => intval($result['code']), '%message' => $result['error']], Atos::MODULE_DOMAIN)); } elseif ($result['response_code'] == '00') { $atos = new Atos(); $order = OrderQuery::create()->filterByTransactionRef($result['transaction_id'])->filterByPaymentModuleId($atos->getModuleModel()->getId())->findOne(); if ($order) { $this->confirmPayment($order->getId()); $this->getLog()->addInfo($this->getTranslator()->trans("Order ID %id is confirmed.", ['%id' => $order->getId()], Atos::MODULE_DOMAIN)); } else { $this->getLog()->addError($this->getTranslator()->trans('Cannot find an order for transaction ID "%trans"', ['%trans' => $result['transaction_id']], Atos::MODULE_DOMAIN)); } } else { $this->getLog()->addError($this->getTranslator()->trans('Cannot validate order. Response code is %resp', ['%resp' => $result['response_code']], Atos::MODULE_DOMAIN)); } } else { $this->getLog()->addError($this->getTranslator()->trans('Got empty response from executable %binary, check path and permissions', ['%binary' => $binResponse], Atos::MODULE_DOMAIN)); } } else { $this->getLog()->addError($this->getTranslator()->trans('Request does not contains any data', [], Atos::MODULE_DOMAIN)); } $this->getLog()->info($this->getTranslator()->trans("Atos platform request processing terminated.", [], Atos::MODULE_DOMAIN)); return Response::create(); }
public function onModuleConfigure(HookRenderEvent $event) { $logFilePath = sprintf(THELIA_ROOT . "log" . DS . "%s.log", Atos::MODULE_DOMAIN); $traces = @file_get_contents($logFilePath); if (false === $traces) { $traces = $this->translator->trans("The log file '%log' does not exists yet.", ['%log' => $logFilePath], Atos::MODULE_DOMAIN); } elseif (empty($traces)) { $traces = $this->translator->trans("The log file is currently empty.", [], Atos::MODULE_DOMAIN); } $vars = ['trace_content' => nl2br($traces)]; if (null !== ($params = ModuleConfigQuery::create()->findByModuleId(Atos::getModuleId()))) { /** @var ModuleConfig $param */ foreach ($params as $param) { $vars[$param->getName()] = $param->getValue(); } } $event->add($this->render('atos/module-configuration.html', $vars)); }