Exemplo n.º 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 it_should_dispatch_an_event_when_it_fails_to_verify_a_message_due_to_a_service_failure(Verifier $verifier, EventDispatcher $eventDispatcher)
 {
     $verifier->verify(Argument::type('Mdb\\PayPal\\Ipn\\Message'))->willThrow('Mdb\\PayPal\\Ipn\\Exception\\ServiceException');
     $eventDispatcher->dispatch(Listener::IPN_VERIFICATION_FAILURE_EVENT, Argument::type('Mdb\\PayPal\\Ipn\\Event\\MessageVerificationFailureEvent'))->shouldBeCalled();
     $this->listen();
 }