/** * Transfer money between the technical * wallet and the operator|seller wallet. * * @param OperationInterface $operation * * @return int * * @throws Exception */ public function transfer(OperationInterface $operation) { try { $vendor = $this->getVendor($operation); if (!$vendor || $this->hipay->isAvailable($vendor->getEmail())) { throw new WalletNotFoundException($vendor); } $operation->setHiPayId($vendor->getHiPayId()); $transfer = new Transfer(round($operation->getAmount(), self::SCALE), $vendor, $this->operationManager->generatePublicLabel($operation), $this->operationManager->generatePrivateLabel($operation)); //Transfer $transferId = $this->hipay->transfer($transfer); $operation->setStatus(new Status(Status::TRANSFER_SUCCESS)); $operation->setTransferId($transferId); $operation->setUpdatedAt(new DateTime()); $this->operationManager->save($operation); return $transferId; } catch (Exception $e) { $operation->setStatus(new Status(Status::TRANSFER_FAILED)); $operation->setUpdatedAt(new DateTime()); $this->operationManager->save($operation); throw $e; } }