public function tearDown()
 {
     parent::tearDown();
     $this->vendorManager->checkProphecyMethodsPredictions();
     $this->operationManager->checkProphecyMethodsPredictions();
     $this->hipay->checkProphecyMethodsPredictions();
     $this->mirakl->checkProphecyMethodsPredictions();
     $this->documentManager->checkProphecyMethodsPredictions();
 }
 /**
  * Save a vendor in case there was an error.
  *
  * @param string $email
  * @param int $miraklId
  */
 public function recordVendor($email, $miraklId)
 {
     $miraklData = current($this->mirakl->getVendors(null, false, array($miraklId)));
     $hipayInfo = $this->hipay->getWalletInfo($miraklData['contact_informations']['email']);
     $vendor = $this->createVendor($email, $hipayInfo->getUserAccountld(), $hipayInfo->getUserSpaceld(), $hipayInfo->getIdentified(), $miraklId, $miraklData);
     $this->vendorManager->save($vendor);
 }
 /**
  * Return the right vendor for an operation
  *
  * @param OperationInterface $operation
  *
  * @return VendorInterface|null
  */
 protected function getVendor(OperationInterface $operation)
 {
     if ($operation->getMiraklId()) {
         return $this->vendorManager->findByMiraklId($operation->getMiraklId());
     }
     return $this->operator;
 }
 /**
  * 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;
 }
 /**
  * @param int             $hipayId
  * @param DateTime        $date
  * @param bool            $status
  */
 protected function identification($hipayId, $date, $status)
 {
     if ($status) {
         $eventName = 'identification.notification.success';
     } else {
         $eventName = 'identification.notification.failed';
     }
     $vendor = $this->vendorManager->findByHiPayId($hipayId);
     if ($vendor !== null) {
         $vendor->setHiPayIdentified($status);
         $this->vendorManager->save($vendor);
     }
     $event = new Identification($hipayId, $date);
     $this->dispatcher->dispatch($eventName, $event);
 }