예제 #1
0
 public function listen()
 {
     $message = $this->messageFactory->createMessage();
     try {
         $result = $this->verifier->verify($message);
         if ($result) {
             $eventName = self::IPN_VERIFIED_EVENT;
             $event = new MessageVerifiedEvent($message);
         } else {
             $eventName = self::IPN_INVALID_EVENT;
             $event = new MessageInvalidEvent($message);
         }
     } catch (\UnexpectedValueException $e) {
         $eventName = self::IPN_VERIFICATION_FAILURE_EVENT;
         $event = new MessageVerificationFailureEvent($message, $e->getMessage());
     } catch (ServiceException $e) {
         $eventName = self::IPN_VERIFICATION_FAILURE_EVENT;
         $event = new MessageVerificationFailureEvent($message, $e->getMessage());
     }
     $this->eventDispatcher->dispatch($eventName, $event);
 }
 function let(MessageFactory $messageFactory, Message $message, Verifier $verifier, EventDispatcher $eventDispatcher)
 {
     $messageFactory->createMessage()->willReturn($message);
     $this->beConstructedWith($messageFactory, $verifier, $eventDispatcher);
 }