/** * {@inheritDoc} */ public function onPostExecute(Context $context) { $action = $context->getAction(); if ($action instanceof GenericTokenFactoryAwareInterface) { $action->setGenericTokenFactory(null); } }
/** * {@inheritDoc} */ public function onPostExecute(Context $context) { $action = $context->getAction(); if ($action instanceof LoggerAwareInterface) { $action->setLogger($this->nullLogger); } }
/** * @test */ public function shouldDoNothingIfActionNotImplementsGenericTokenFactoryAwareInterfaceOnPostExecute() { $tokenFactory = $this->createGenericTokenFactoryMock(); $extension = new GenericTokenFactoryExtension($tokenFactory); $action = $this->createActionMock(); $context = new Context($this->createGatewayMock(), new \stdClass(), array()); $context->setAction($action); $extension->onPostExecute($context); }
/** * {@inheritDoc} */ public function onPostExecute(Context $context) { $request = $context->getRequest(); if ($request instanceof ModelAggregateInterface) { $this->scheduleForUpdateIfSupported($request->getModel()); } if (false == $context->getPrevious()) { foreach ($this->scheduledForUpdateModels as $modelHash => $model) { $this->storage->update($model); unset($this->scheduledForUpdateModels[$modelHash]); } } }
/** * {@inheritdoc} */ public function onPostExecute(Context $context) { $action = $context->getAction(); if ($action instanceof CaptureAction) { $request = $context->getRequest(); /** @var Payment $payment */ $payment = $request->getFirstModel(); $details = $request->getModel(); $payment->setDetails($details); $this->objectManager->persist($payment); $this->objectManager->flush(); } }
/** * @var Context $context */ public function onPostExecute(Context $context) { /** @var Capture $request */ $request = $context->getRequest(); if (false == $request instanceof ObtainToken) { return; } $model = $request->getModel(); if (false == $model instanceof \ArrayAccess) { return; } $this->createCustomer($context->getGateway(), ArrayObject::ensureArrayObject($model)); }
/** * {@inheritDoc} */ public function onPreExecute(Context $context) { /** @var Notify $request */ $request = $context->getRequest(); if (false == $request instanceof Notify) { return; } if (in_array($request, $this->processedRequests)) { return; } $this->processedRequests[] = $request; $notification = new NotificationDetails(); $request->getToken() ? $notification->setGatewayName($request->getToken()->getGatewayName()) : $notification->setGatewayName('unknown'); $notification->setDetails($_REQUEST); $notification->setCreatedAt(new \DateTime()); $this->doctrine->getManager()->persist($notification); $this->doctrine->getManager()->flush(); }
/** * {@inheritDoc} */ public function onPostExecute(Context $context) { if ($context->getPrevious()) { return; } /** @var Generic $request */ $request = $context->getRequest(); if (false == $request instanceof Generic) { return; } if ($request instanceof GetStatusInterface) { return; } if ($request->getFirstModel() instanceof Payment) { /** @var Payment $payment */ $payment = $request->getFirstModel(); $context->getGateway()->execute($status = new GetHumanStatus($payment)); $payment->setStatus($status->getValue()); } }
/** * {@inheritdoc} */ public function onPostExecute(Context $context) { if ($context->getPrevious()) { return; } /** @var Generic $request */ $request = $context->getRequest(); if (false == $request instanceof Generic || $request instanceof GetStatusInterface) { return; } $payment = $request->getFirstModel(); if ($payment instanceof PaymentInterface) { /* @var Payment $payment */ $status = new GetHumanStatus($payment); $context->getGateway()->execute($status); $this->events->fire(new StatusChanged($status, $payment)); if (method_exists($payment, 'setStatus') === true) { $payment->setStatus($status->getValue()); } } }
/** * {@inheritdoc} */ public function onPostExecute(Context $context) { if ($context->getPrevious()) { return; } /** @var Generic $request */ $request = $context->getRequest(); if (false === $request instanceof Generic) { return; } if (false === $request instanceof GetStatusInterface && false === $request instanceof Notify) { return; } /** @var PaymentInterface $payment */ $payment = $request->getFirstModel(); if (false === $payment instanceof PaymentInterface) { return; } $context->getGateway()->execute($status = new GetStatus($payment)); if ($payment->getState() !== $status->getValue()) { $this->updatePaymentState($payment, $status->getValue()); } }
/** * {@inheritDoc} */ public function onPostExecute(Context $context) { if ($context->getReply()) { $this->logger->debug(sprintf('[Payum] %d# %s::execute(%s) throws reply %s', count($context->getPrevious()) + 1, Humanify::value($context->getAction()), Humanify::request($context->getRequest()), Humanify::request($context->getReply()))); } elseif ($context->getException()) { $this->logger->debug(sprintf('[Payum] %d# %s::execute(%s) throws exception %s', count($context->getPrevious()) + 1, $context->getAction() ? Humanify::value($context->getAction()) : 'Gateway', Humanify::request($context->getRequest()), Humanify::value($context->getException()))); } }
/** * @test */ public function shouldDoNothingOnPreExecute() { $logger = $this->createLoggerMock(); $extension = new LoggerExtension($logger); $action = new LoggerAwareAction(); $context = new Context($this->createGatewayMock(), new \stdClass(), array()); $context->setAction($action); $extension->onPreExecute($context); $this->assertNull($action->logger); }
/** * {@inheritDoc} */ public function onPreExecute(Context $context) { if (count($context->getPrevious()) >= $this->limit) { throw new LogicException(sprintf('Possible endless cycle detected. ::onPreExecute was called %d times before reach the limit.', $this->limit)); } }
protected function onPostExecuteWithException(Context $context) { array_pop($this->stack); $exception = $context->getException(); try { $this->extensions->onPostExecute($context); } catch (\Exception $e) { // logic is similar to one in Symfony's ExceptionListener::onKernelException $wrapper = $e; while ($prev = $wrapper->getPrevious()) { if ($exception === ($wrapper = $prev)) { throw $e; } } $prev = new \ReflectionProperty('Exception', 'previous'); $prev->setAccessible(true); $prev->setValue($wrapper, $exception); throw $e; } if ($context->getException()) { throw $context->getException(); } }
/** * @test */ public function shouldLogExceptionWhenSetButActionNotSetOnPostExecute() { $logger = $this->createLoggerMock(); $logger->expects($this->at(0))->method('debug')->with('[Payum] 1# Gateway::execute(string) throws exception LogicException'); $extension = new LogExecutedActionsExtension($logger); $context = new Context($this->createGatewayMock(), 'string', array()); $context->setException(new \LogicException()); $extension->onPostExecute($context); }