예제 #1
0
 public function subscribeNewsletter()
 {
     $errors = $this->validator->validate($this->blaster);
     if (count($errors) > 0) {
         //some errors found, log the errors
         $this->logger->addError((string) $errors);
     }
     $this->em->persist($this->blaster);
     $this->em->flush();
 }
예제 #2
0
 public function onCorrectedEvent(CorrectedEvent $event)
 {
     $test = $event->getTest();
     $mail = $this->generateMail($test, "CorrigeatonMailerBundle:Mail:mail-corrected.html.twig", $test->getClassroomsEmails());
     if ($this->mailer->send($mail) == 1) {
         $this->log->addInfo("Mail send : " . $test);
     } else {
         $this->log->addError("Error in send mail : " . $test);
     }
 }
 /**
  * @param PaymentMethodInterface $method
  * @param integer $amount
  *
  * @throws PaymentException
  */
 public function processPayment(PaymentMethodInterface $method, $amount)
 {
     /**
      * @var AdyenMethod $method
      */
     $paymentData = [];
     $paymentData['additionalData'] = ['card.encrypted.json' => $method->getAdditionalData()];
     $paymentData['amount'] = ['value' => $amount, 'currency' => $this->currency];
     $paymentData['reference'] = $method->getTransactionId();
     $paymentData['merchantAccount'] = $this->merchantCode;
     try {
         $r = $this->callApi($paymentData);
     } catch (\Exception $e) {
         /*
          * The Soap call failed
          */
         $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method);
         $this->logger->addError('PaymentException: ' . $e->getMessage());
         $this->paymentBridge->setError($e->getMessage());
         $this->paymentBridge->setErrorCode($e->getCode());
         throw new PaymentException($e->getMessage());
     }
     $r['amount'] = $amount;
     $this->storeTransaction($r);
     if (!$this->isAuthorized($r)) {
         $this->paymentBridge->setError($this->getError($r));
         $this->paymentBridge->setErrorCode($this->getErrorCode($r));
         /**
          * The payment was not successful
          */
         $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method);
         throw new PaymentException($this->getErrorCode($r));
     }
     $this->eventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $method);
     /*
      * Everything is ok, emitting the
      * payment.order.create event
      */
     $method->setTransactionId($r['pspReference'])->setTransactionStatus('paid');
     $this->eventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $method);
     /**
      * Payment process has returned control
      */
     $this->eventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $method);
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->eventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $method);
 }
예제 #4
0
 /**
  * @param string $url
  *   The URL to POST to
  * @param SiteDocument $site
  *   The site being posted to
  * @param array $params
  *   An array of keys and values to be posted
  *
  * @return mixed
  *   The content of the response
  *
  * @throws WardenRequestException
  *   If any error occurs
  */
 public function post($url, SiteDocument $site, array $params = array())
 {
     try {
         $this->setClientTimeout($this->connectionTimeout);
         // Don't verify SSL certificate.
         // @TODO make this optional
         $this->buzz->getClient()->setVerifyPeer(FALSE);
         if ($site->getAuthUser() && $site->getAuthPass()) {
             $headers = array(sprintf('Authorization: Basic %s', base64_encode($site->getAuthUser() . ':' . $site->getAuthPass())));
             $this->setConnectionHeaders($headers);
         }
         $params['token'] = $this->sslEncryptionService->generateRequestToken();
         $content = http_build_query($params);
         /** @var \Buzz\Message\Response $response */
         $response = $this->buzz->post($url, $this->connectionHeaders, $content);
         if (!$response->isSuccessful()) {
             $this->logger->addError("Unable to request data from {$url}\nStatus code: " . $response->getStatusCode() . "\nHeaders: " . print_r($response->getHeaders(), TRUE));
             throw new WardenRequestException("Unable to request data from {$url}. Check log for details.");
         }
         $site->setLastSuccessfulRequest();
         $this->siteManager->updateDocument();
         return $response->getContent();
     } catch (ClientException $clientException) {
         throw new WardenRequestException($clientException->getMessage());
     }
 }
예제 #5
0
 public function testCountErrorsWithoutDebugHandler()
 {
     $logger = new Logger('test');
     $logger->pushHandler(new TestHandler());
     $logger->addInfo('test');
     $logger->addError('uh-oh');
     $this->assertEquals(0, $logger->countErrors());
 }