예제 #1
0
 /**
  * @dataProvider factoryProvider
  */
 public function testFactory($notificationType, $expectedClass, $isUserValidation, $isPayment, $isRefund)
 {
     $userId = 'USER_ID';
     $user = array('id' => 'USER_ID');
     $request = array('notification_type' => $notificationType, 'user' => $user);
     $message = Message\Message::fromArray($request);
     static::assertInstanceOf($expectedClass, $message);
     static::assertSame($userId, $message->getUserId());
     static::assertSame($user, $message->getUser());
     static::assertSame($request, $message->toArray());
     static::assertSame($notificationType, $message->getNotificationType());
     static::assertSame($isUserValidation, $message->isUserValidation());
     static::assertSame($isPayment, $message->isPayment());
     static::assertSame($isRefund, $message->isRefund());
 }
예제 #2
0
 /**
  * @param WebhookRequest $webhookRequest
  * @param bool           $authenticateClientIp
  *
  * @return Response
  */
 public function getSymfonyResponse(WebhookRequest $webhookRequest = null, $authenticateClientIp = true)
 {
     try {
         if (!$webhookRequest) {
             $webhookRequest = WebhookRequest::fromGlobals();
         }
         $this->webhookAuthenticator->authenticate($webhookRequest, $authenticateClientIp);
         $message = Message::fromArray($webhookRequest->toArray());
         call_user_func($this->webhookCallback, $message);
         $webhookResponse = new WebhookResponse();
         return $webhookResponse->getSymfonyResponse();
     } catch (\Exception $e) {
         return WebhookResponse::fromException($e)->getSymfonyResponse();
     }
 }