protected function updatePaymentState(PaymentInterface $payment, $nextState)
    {
        if ($payment->getState() !== $nextState) {
            /** @var \Ekyna\Bundle\PaymentBundle\StateMachine\StateMachineInterface $stateMachine */
            $stateMachine = $this->factory->get($payment);
            if (null !== $transition = $stateMachine->getTransitionToState($nextState)) {
                $stateMachine->apply($transition);

                $this->objectManager->flush();
            }
        }
    }