Exemplo n.º 1
0
Arquivo: Card.php Projeto: arbi/MyCode
 /**
  * @param $rawData
  * @return int
  */
 public function processCreditCardData($rawData)
 {
     $partnerId = Partners::PARTNER_WEBSITE;
     /**
      * @var \CreditCard\Service\Encrypt $encryptService
      */
     $encryptService = $this->getServiceLocator()->get('service_encrypt');
     // Detect partner business model
     if (isset($rawData['partner_id']) && $rawData['partner_id']) {
         /**
          * @var \DDD\Dao\Partners\Partners $partnerDao
          */
         $partnerDao = $this->getServiceLocator()->get('dao_partners_partners');
         $partnerData = $partnerDao->getPartnerModel($rawData['partner_id']);
         if ($partnerData && $partnerData->getBusinessModel() == Partners::BUSINESS_MODEL_GINOSI_COLLECT_PARTNER) {
             $partnerId = $rawData['partner_id'];
         }
     }
     // Save CC Details
     $creditCard = new CompleteData();
     $pan = isset($rawData['number']) ? $rawData['number'] : '';
     $creditCard->setPan($encryptService->encrypt($pan, ''));
     $holder = isset($rawData['holder']) ? $rawData['holder'] : '';
     $creditCard->setHolder($encryptService->encrypt($holder, ''));
     $cvc = isset($rawData['cvc']) ? $rawData['cvc'] : '';
     $creditCard->setSecurityCode($encryptService->encrypt($cvc, ''));
     if (isset($rawData['year']) && strlen($rawData['year']) == 4) {
         $rawData['year'] = substr($rawData['year'], 2, 2);
     }
     $year = isset($rawData['year']) ? $rawData['year'] : '';
     $creditCard->setExpirationYear($encryptService->encrypt($year, ''));
     $month = isset($rawData['month']) ? $rawData['month'] : '';
     $creditCard->setExpirationMonth($encryptService->encrypt($month, ''));
     // Card Type
     $creditCardValidator = new CreditCardValidator();
     $cardType = $creditCardValidator->getCardTypeByNumber(substr($pan, 0, 6));
     $creditCard->setBrand(0);
     if ($cardType) {
         $creditCardType = Objects::getCreditCardId($cardType);
         $creditCard->setBrand($creditCardType);
     }
     $creditCard->setSource($rawData['source']);
     $creditCard->setStatus(self::CC_STATUS_UNKNOWN);
     $creditCard->setPartnerId($partnerId);
     $creditCard->setCustomerId($rawData['customer_id']);
     $creditCard->setDateProvided(date('Y-m-d h:i:s'));
     // Save cc details locally
     //        $this->gr2info('Successfully created CC data from ' . ucfirst($params['source_provider']), ['module' => 'Finance']);
     //        $ccId = $creditCard->getId();
     /**
      * @var Queue $creditCardCreationQueueService
      */
     $creditCardCreationQueueService = $this->getServiceLocator()->get('service_card_creation_queue');
     $cardId = $creditCardCreationQueueService->insert($creditCard);
     return $cardId;
     //        $this->gr2info('Successfully send to Processing Queue from ' . ucfirst($params['source_provider']), ['module' => 'Finance']);
     //
     //        $this->gr2info('Customer or CC create/update end from ' . ucfirst($params['source_provider']), ['module' => 'Finance']);
     //
     //        $logger->save(Logger::MODULE_BOOKING, $reservationId, Logger::ACTION_NEW_CC_DETAILS, $cardId);
     //        $this->gr2logException($e, 'Cannot update CC data from Frontier');
     //        $this->gr2debug($e->getMessage(), [
     //            'reservation_id'              => $reservationId,
     //            'customer_id'                 => $reservationData['customer_id'],
     //            'credit_card_source_provider' => 'frontier'
     //        ]);
 }