Пример #1
0
 /**
  * @param Customer $customer
  */
 public function changeDb($customer)
 {
     $refConn = new \ReflectionObject($this->connection);
     $refParams = $refConn->getProperty('_params');
     $refParams->setAccessible('public');
     //we have to change it for a moment
     $params = $refParams->getValue($this->connection);
     $params['dbname'] = $customer->getDbName();
     $refParams->setAccessible('private');
     $refParams->setValue($this->connection, $params);
 }
Пример #2
0
 /**
  * @param Customer $customer
  * @return mixed
  */
 private function prepareCustomerData(Customer $customer)
 {
     /** @var Customer $customer */
     $data = ['external_id' => $customer->getUsername(), 'gender' => $customer->getSalutation() == 1 ? 'M' : 'F', 'company' => $customer->getCompany(), 'address' => $customer->getStreet() . '-' . $customer->getStreetNr(), 'first_name' => $customer->getFirstName(), 'last_name' => $customer->getLastName(), 'zip_code' => $customer->getPostCode(), 'city' => $customer->getCity(), 'phone_number' => $customer->getPhone(), 'email' => $customer->getEmail(), 'status' => $customer->getIsActive() ? 'active' : 'blocked', 'country' => $customer->getCountry()->getId()];
     if ($customer->getAccountHolder() && $customer->getAccountNumber()) {
         $data['payment_data']['bank_account'] = ['account_holder' => $customer->getAccountHolder(), 'account_number' => $customer->getAccountNumber(), 'bank_name' => $customer->getBankName(), 'bank_code' => $customer->getBankCode()];
     } elseif ($customer->getCreditCardOwner() && $customer->getCreditCardNumber()) {
         $data['payment_data']['credit_card'] = ['card_number' => $customer->getCreditCardNumber(), 'card_type' => $customer->getCreditCardType(), 'card_holder' => $customer->getCreditCardOwner(), 'card_cvc_holder' => $customer->getSecurityCode(), 'card_expiration_date' => $customer->getExpirationMonth() . '/' . $customer->getExpirationYear()];
     } elseif ($customer->getBankSwift() && $customer->getBankIban()) {
         $data['payment_data']['sepa_direct_debit'] = ['bic' => $customer->getBankSwift(), 'iban' => $customer->getBankIban()];
     }
     return $data;
 }
Пример #3
0
 /**
  * @param array $data
  * @return array
  */
 public function createNewCustomer($data)
 {
     $customer = new CustomerEntity();
     $maxUserName = (int) $this->getNewUserName() + 1;
     $customer->setClientId($maxUserName);
     $customer->setUsername($maxUserName);
     $customer->setSalutation($data['salutation']);
     $customer->setEmail($data['email']);
     $customer->setFirstName($data['firstName']);
     $customer->setLastName($data['lastName']);
     $customer->setDomain($data['domain']);
     $encoder = $this->encoderFactory->getEncoder($customer);
     $password = $this->generateRandomString();
     $customer->setPassword($encoder->encodePassword($password, $customer->getSalt()));
     $customer->setIsActive(true);
     $customer->setDbServer($this->getDbServer());
     $customer->setDbUser($this->getDbUser());
     $customer->setDbName($this->getDbName($customer->getUsername()));
     $customer->setDbPassword($this->getDbPassword());
     if (!isset($data['plan'])) {
         $data['plan'] = 269;
     }
     $customer->setTariff($data['plan']);
     $this->addNewRole($customer);
     $this->addNewExtra($data, $customer);
     return array($customer, $password);
 }
Пример #4
0
 /**
  * @param Customer $customer
  * @return array
  */
 private function prepareCustomerDataForOrder(Customer $customer)
 {
     return ['external_id' => $customer->getUsername(), 'active' => true, 'order_items' => [['plan' => (int) $customer->getTariff(), 'active' => true]]];
 }
Пример #5
0
 /**
  * @param string   $message
  * @param Customer $customer
  * @param null     $contractErrorsMessage
  * @param string   $additional
  * @param bool     $firstMessage
  * @param bool     $lastMessage
  */
 public function logMessage($message, Customer $customer = null, $contractErrorsMessage = null, $additional = '', $firstMessage = false, $lastMessage = false)
 {
     $log = $this->initBillerfoxLog();
     !$firstMessage ?: $log->addNotice('Start log for connexion', ['===================================START=================================']);
     /** @var Customer $customer */
     if ($customer) {
         $log->addError($message, array('username' => $customer->getUsername(), 'contractId' => $customer->getBillerfoxContractId(), 'tariffId' => $customer->getTariff(), 'errors' => explode("\n", $contractErrorsMessage), 'additionalInfo' => $additional));
     } else {
         if ($additional) {
             $log->addInfo($message, array('info' => $additional));
         } else {
             $log->addInfo($message);
         }
     }
     !$lastMessage ?: $log->addNotice('Finish log connexion   ', ['***********************************FINISH********************************']);
 }