/**
  * {@inheritDoc}
  *
  * @param Notify $request
  */
 public function execute($request)
 {
     $notification = new NotificationDetails();
     $request->getToken() ? $notification->setGatewayName($request->getToken()->getGatewayName()) : $notification->setGatewayName('unknown');
     $this->gateway->execute($getHttpRequest = new GetHttpRequest());
     $notification->setDetails($getHttpRequest->query);
     $notification->setCreatedAt(new \DateTime());
     $this->doctrine->getManager()->persist($notification);
     $this->doctrine->getManager()->flush();
 }
 /**
  * @test
  */
 public function shouldKeepOrderEvenIfExceptionThrown()
 {
     $details = array('foo' => 'fooVal');
     $order = new Order();
     $order->setDetails($details);
     $paymentMock = $this->createPaymentMock();
     $paymentMock->expects($this->once())->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\Notify'))->will($this->throwException(new \Exception()));
     $action = new NotifyOrderAction();
     $action->setPayment($paymentMock);
     $this->setExpectedException('Exception');
     $action->execute($capture = new Notify($order));
     $this->assertSame($order, $capture->getModel());
 }
 function it_must_dispatch_pre_and_post_payment_state_changed_if_state_changed($factory, Notify $request, OrderInterface $order, PaymentModelInterface $paymentModel, PaymentInterface $payment, ObjectManager $objectManager, StateMachineInterface $sm, Collection $payments, TokenInterface $token)
 {
     $request->getModel()->willReturn($paymentModel);
     $request->getToken()->willReturn($token);
     $order->getPayments()->willReturn($payments);
     $payments->last()->willReturn($payment);
     $paymentModel->getState()->willReturn(Payment::STATE_PENDING);
     $factory->get($paymentModel, PaymentTransitions::GRAPH)->willReturn($sm);
     $sm->getTransitionToState('cancelled')->willReturn(PaymentTransitions::SYLIUS_CANCEL);
     $sm->apply(PaymentTransitions::SYLIUS_CANCEL)->shouldBeCalled()->will(function ($args) use($paymentModel) {
         $paymentModel->getState()->willReturn(Payment::STATE_CANCELLED);
     });
     $payment->execute(Argument::type('Payum\\Core\\Request\\Sync'))->willReturn(null);
     $payment->execute(Argument::type('Sylius\\Bundle\\PayumBundle\\Payum\\Request\\GetStatus'))->will(function ($args) {
         $args[0]->markCanceled();
     });
     $objectManager->flush()->shouldBeCalled();
     $this->execute($request);
 }
 /**
  * @test
  */
 public function shouldSetOkIfVerifyRequestIsOk()
 {
     $gatewayMock = $this->createGatewayMock();
     $gatewayMock->expects($this->once())->method('execute')->with($this->isInstanceOf(GetHttpRequest::class))->will($this->returnCallback(function (GetHttpRequest $request) {
         $request->request = ['merchantReference' => 'SomeReference', 'authResult' => 'result'];
     }));
     $apiMock = $this->createApiMock();
     $apiMock->expects($this->once())->method('verifyNotification')->willReturn(true);
     $action = new NotifyAction();
     $action->setGateway($gatewayMock);
     $action->setApi($apiMock);
     $details = new \ArrayObject(['merchantReference' => 'SomeReference']);
     $action->execute($notify = new Notify($details));
     $model = $notify->getModel();
     $this->assertSame(200, $model['response_status']);
     $this->assertSame('result', $model['authResult']);
 }
Beispiel #5
0
 /**
  * @param array $notification
  * @param TokenInterface $token
  */
 public function __construct(array $notification, TokenInterface $token)
 {
     parent::__construct($notification, $token);
     $this->token = $token;
 }
Beispiel #6
0
 /**
  * @test
  */
 public function shouldAllowGetModelSetInConstructor()
 {
     $expectedModel = new \stdClass();
     $request = new Notify(array(), $expectedModel);
     $this->assertSame($expectedModel, $request->getModel());
 }
 /**
  * @param Notify $request
  *
  * @return boolean
  */
 public function supports($request)
 {
     return $request instanceof Notify && is_array($request->getNotification());
 }