/** * Create the vendor operation * dispatch <b>after.operation.create</b>. * * @param int $amount * @param DateTime $cycleDate * @param string $paymentVoucher * @param bool|int $miraklId false if it an operator operation * * @return OperationInterface|null */ public function createOperation($amount, DateTime $cycleDate, $paymentVoucher, $miraklId = null) { if ($amount <= 0) { $this->logger->notice("Operation wasn't created du to null amount"); return null; } //Call implementation function $operation = $this->operationManager->create($amount, $cycleDate, $paymentVoucher, $miraklId); //Set hipay id $hipayId = null; if ($miraklId) { $vendor = $this->vendorManager->findByMiraklId($miraklId); if ($vendor) { $hipayId = $vendor->getHiPayId(); } } else { $hipayId = $this->operator->getHiPayId(); } $operation->setHiPayId($hipayId); //Sets mandatory values $operation->setMiraklId($miraklId); $operation->setStatus(new Status(Status::CREATED)); $operation->setUpdatedAt(new DateTime()); $operation->setAmount($amount); $operation->setCycleDate($cycleDate); $operation->setPaymentVoucher($paymentVoucher); return $operation; }