/** * @param int $withdrawalId * @param int $hipayId * @param DateTime $date * @param bool $status * * @throws Exception */ protected function withdrawalValidation($hipayId, DateTime $date, $withdrawalId, $status) { $operation = $this->operationManager->findByWithdrawalId($withdrawalId); if (!$operation) { throw new OperationNotFound($withdrawalId); } if ($operation->getStatus() != Status::WITHDRAW_REQUESTED) { throw new WrongOperationStatus($operation); } if ($status) { $operation->setStatus(new Status(Status::WITHDRAW_SUCCESS)); $this->logger->info("Withdraw {$operation->getWithdrawId()} successful"); $eventName = 'withdraw.notification.success'; } else { $operation->setStatus(new Status(Status::WITHDRAW_CANCELED)); $this->logger->info("Withdraw {$operation->getWithdrawId()} canceled"); $eventName = 'withdraw.notification.canceled'; } $this->operationManager->save($operation); $event = new Withdraw($hipayId, $date, $operation); $this->dispatcher->dispatch($eventName, $event); }