caseManagement = $caseManagement; $this->serviceFactory = $serviceFactory; $this->gateway = $gateway; $this->cancelGuaranteeAbility = $cancelGuaranteeAbility; $this->logger = $logger; } /** * @inheritdoc */ public function cancelForOrder($orderId) { if (!$this->cancelGuaranteeAbility->isAvailable($orderId)) { return false; } $caseEntity = $this->caseManagement->getByOrderId($orderId); try { $disposition = $this->gateway->cancelGuarantee($caseEntity->getCaseId()); } catch (GatewayException $e) { $this->logger->error($e->getMessage()); return false; } $updatingService = $this->serviceFactory->create('guarantees/cancel'); $data = [ 'guaranteeDisposition' => $disposition ]; $updatingService->update($caseEntity, $data); return true; } }