public function validate(ValidationEvent $event)
 {
     /* @var \Hatimeria\DotpayBundle\Response\Response $response */
     $response = $event->getSubject();
     if (!$response instanceof DotpayResponse) {
         return;
     }
     $payment = $this->pm->findDotpayPaymentByControl($response->getControl());
     if (is_object($payment)) {
         $event->markAsValid();
         return;
     }
     $event->markAsInvalid();
 }
 public function validate(ValidationEvent $event)
 {
     /* @var \Hatimeria\DotpayBundle\Request\PremiumTc $request */
     $request = $event->getSubject();
     if (!$request instanceof PremiumTc) {
         return;
     }
     $code = $request->code;
     $number = $request->number;
     // checkin if code is not already in our database [unique]
     if (is_object($this->sm->findSmsPaymentByCode($code))) {
         $event->markAsInvalid();
         return;
     }
     // checking the number where sms was sent
     if (array_key_exists($number, $this->sm->getConfiguration())) {
         $event->markAsValid();
         return;
     }
     $event->markAsInvalid();
 }