@Override public NotifyRequestResultResponse notifyRequestResult(NotifyRequestResultRequest notifyRequestResultRequest) { SessionInfo sessionInfo = sourceSessionRepository.findSessionInfoByRequestId(notifyRequestResultRequest.getRequestIdentifier()); NotifyRequestResultResponse notifyRequestResultResponse = new NotifyRequestResultResponse(); if (notifyRequestResultRequest.isRequestSuccess()) { if (sessionInfo.getSessionStateMachine().hasStateStartTransactionRequested()) { sessionInfo.getSessionStateMachine().eventStartOk(); sourceSessionRepository.insertOrUpdateSessionInfo(sessionInfo); } else if (sessionInfo.getSessionStateMachine().hasStateStopTransactionRequested()) { sessionInfo.getSessionStateMachine().eventStopOk(); sourceSessionRepository.insertOrUpdateSessionInfo(sessionInfo); } else { ResponseError responseError = new ResponseError(); responseError.setErrorCode("400"); responseError.setErrorMsg("Unexpected event in current state"); notifyRequestResultResponse.setResponseError(responseError); } } return notifyRequestResultResponse; }