/** * {@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(); }
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); }