/** * @param OrderEvent $event * * Check if we're the payment module, and send the payment confirmation email to the customer if it's the case. */ public function sendConfirmationEmail(OrderEvent $event) { if ($event->getOrder()->getPaymentModuleId() === Cheque::getModuleId()) { if ($event->getOrder()->isPaid(true)) { $order = $event->getOrder(); $this->mailer->sendEmailToCustomer('order_confirmation_cheque', $order->getCustomer(), ['order_id' => $order->getId(), 'order_ref' => $order->getRef()]); } } }
public function testGetI18nVariable() { Cheque::setConfigValue('testI18N', 'test-value-i18n', 'fr_FR', true); $this->instance->initializeArgs(array("type" => "foo", "name" => "foo", "module" => "cheque", "variable" => "testI18N", "locale" => "fr_FR")); $dummy = null; $loopResults = $this->instance->exec($dummy); $this->assertEquals(1, $loopResults->getCount()); $substitutions = $loopResults->current()->getVarVal(); $this->assertEquals('test-value-i18n', $substitutions['VALUE']); }
public function configure() { if (null !== ($response = $this->checkAuth(AdminResources::MODULE, 'Cheque', AccessManager::UPDATE))) { return $response; } // Initialize the potential exception $ex = null; // Create the Form from the request $configurationForm = new ConfigurationForm($this->getRequest()); try { // Check the form against constraints violations $form = $this->validateForm($configurationForm, "POST"); // Get the form field values $data = $form->getData(); Cheque::setConfigValue('instructions', $data['instructions'], $this->getCurrentEditionLocale()); Cheque::setConfigValue('payable_to', $data['payable_to']); // Log configuration modification $this->adminLogAppend("cheque.configuration.message", AccessManager::UPDATE, sprintf("Cheque instructions configuration updated")); // Everything is OK. return new RedirectResponse(URL::getInstance()->absoluteUrl('/admin/module/Cheque')); } catch (FormValidationException $ex) { // Form cannot be validated. Create the error message using // the BaseAdminController helper method. $error_msg = $this->createStandardFormValidationErrorMessage($ex); } catch (\Exception $ex) { // Any other error $error_msg = $ex->getMessage(); } // At this point, the form has errors, and should be redisplayed. We don not redirect, // just redisplay the same template. // Setup the Form error context, to make error information available in the template. $this->setupFormErrorContext($this->getTranslator()->trans("Cheque instructions configuration", [], Cheque::MESSAGE_DOMAIN), $error_msg, $configurationForm, $ex); // Do not redirect at this point, or the error context will be lost. // Just redisplay the current template. return $this->render('module-configure', array('module_code' => 'Cheque')); }