Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @throws \InvalidArgumentException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $locale = $input->getOption(self::LOCALE_OPTION);
     if (!$this->validator->isValid($locale)) {
         throw new \InvalidArgumentException($locale . ' argument has invalid value, please run info:language:list for list of available locales');
     }
     $area = $input->getOption(self::AREA_OPTION);
     $theme = $input->getOption(self::THEME_OPTION);
     $type = $input->getArgument(self::TYPE_ARGUMENT);
     $this->state->setAreaCode($area);
     $this->objectManager->configure($this->configLoader->load($area));
     $sourceFileGenerator = $this->sourceFileGeneratorPool->create($type);
     foreach ($input->getArgument(self::FILE_ARGUMENT) as $file) {
         $file .= '.' . $type;
         $output->writeln("<info>Gathering {$file} sources.</info>");
         $asset = $this->assetRepo->createAsset($file, ['area' => $area, 'theme' => $theme, 'locale' => $locale]);
         $rootDir = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
         $sourceFile = $this->assetSource->findSource($asset);
         $relativePath = $rootDir->getRelativePath($sourceFile);
         $content = $rootDir->readFile($relativePath);
         $chain = $this->chainFactory->create(['asset' => $asset, 'origContent' => $content, 'origContentType' => $asset->getContentType(), 'origAssetPath' => $relativePath]);
         $processedCoreFile = $sourceFileGenerator->generateFileTree($chain);
         $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
         $source = $rootDir->getRelativePath($processedCoreFile);
         $destination = $asset->getPath();
         $rootDir->copyFile($source, $destination, $targetDir);
         $output->writeln("<info>Successfully processed dynamic stylesheet into CSS</info>");
     }
 }
Ejemplo n.º 2
0
 /**
  * Get icons for available payment methods
  *
  * @return array
  */
 protected function getIcons()
 {
     $icons = [];
     $types = $this->ccConfig->getCcAvailableTypes();
     foreach (array_keys($types) as $code) {
         if (!array_key_exists($code, $icons)) {
             $asset = $this->ccConfig->createAsset('Magento_Payment::images/cc/' . strtolower($code) . '.png');
             $placeholder = $this->assetSource->findSource($asset);
             if ($placeholder) {
                 list($width, $height) = getimagesize($asset->getSourceFile());
                 $icons[$code] = ['url' => $asset->getUrl(), 'width' => $width, 'height' => $height];
             }
         }
     }
     return $icons;
 }
Ejemplo n.º 3
0
 /**
  * @param $store
  * @param $country
  * @return array
  */
 protected function _fetchHppMethods($store, $country)
 {
     $skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code');
     $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData('merchant_account');
     if (!$skinCode || !$merchantAccount) {
         return [];
     }
     $adyFields = ["paymentAmount" => (int) $this->_adyenHelper->formatAmount($this->_getCurrentPaymentAmount(), $this->_getCurrentCurrencyCode($store)), "currencyCode" => $this->_getCurrentCurrencyCode($store), "merchantReference" => "Get Payment methods", "skinCode" => $skinCode, "merchantAccount" => $merchantAccount, "sessionValidity" => date(DATE_ATOM, mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y"))), "countryCode" => $this->_getCurrentCountryCode($store, $country), "shopperLocale" => $this->_getCurrentLocaleCode($store)];
     $responseData = $this->_getDirectoryLookupResponse($adyFields, $store);
     $paymentMethods = [];
     if (isset($responseData['paymentMethods'])) {
         foreach ($responseData['paymentMethods'] as $paymentMethod) {
             $paymentMethodCode = $paymentMethod['brandCode'];
             $paymentMethod = $this->_fieldMapPaymentMethod($paymentMethod);
             // check if payment method is an openinvoice method
             $paymentMethod['isPaymentMethodOpenInvoiceMethod'] = $this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethodCode);
             // add icon location in result
             if ($this->_adyenHelper->showLogos()) {
                 $params = [];
                 // use frontend area
                 $params = array_merge(['area' => 'frontend', '_secure' => $this->_request->isSecure()], $params);
                 $asset = $this->_assetRepo->createAsset('Adyen_Payment::images/logos/' . $paymentMethodCode . '.png', $params);
                 $placeholder = $this->_assetSource->findSource($asset);
                 $icon = null;
                 if ($placeholder) {
                     list($width, $height) = getimagesize($asset->getSourceFile());
                     $icon = ['url' => $asset->getUrl(), 'width' => $width, 'height' => $height];
                 }
                 $paymentMethod['icon'] = $icon;
             }
             $paymentMethods[$paymentMethodCode] = $paymentMethod;
         }
     }
     return $paymentMethods;
 }
Ejemplo n.º 4
0
 /**
  * Launch application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $this->state->setAreaCode($this->params->getArea());
     $this->objectManager->configure($this->configLoader->load($this->params->getArea()));
     $sourceFileGenerator = $this->sourceFileGeneratorPool->create($this->params->getExt());
     foreach ($this->params->getFiles() as $file) {
         $file .= '.' . $this->params->getExt();
         $this->logger->logMessage("Gathering {$file} sources.");
         $asset = $this->assetRepo->createAsset($file, ['area' => $this->params->getArea(), 'theme' => $this->params->getTheme(), 'locale' => $this->params->getLocale()]);
         $sourceFile = $this->assetSource->findSource($asset);
         $content = \file_get_contents($sourceFile);
         $chain = $this->chainFactory->create(['asset' => $asset, 'origContent' => $content, 'origContentType' => $asset->getContentType()]);
         $processedCoreFile = $sourceFileGenerator->generateFileTree($chain);
         $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
         $rootDir = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
         $source = $rootDir->getRelativePath($processedCoreFile);
         $destination = $asset->getPath();
         $rootDir->copyFile($source, $destination, $targetDir);
         $this->logger->logMessage("Done");
     }
     $this->response->setCode(Response::SUCCESS);
     return $this->response;
 }
Ejemplo n.º 5
0
 /**
  * @param $customerId
  * @param $storeId
  * @param $grandTotal
  * @param $recurringType
  * @return array
  */
 public function getOneClickPaymentMethods($customerId, $storeId, $grandTotal, $recurringType)
 {
     $billingAgreements = [];
     $baCollection = $this->_billingAgreementCollectionFactory->create();
     $baCollection->addFieldToFilter('customer_id', $customerId);
     $baCollection->addFieldToFilter('store_id', $storeId);
     $baCollection->addFieldToFilter('method_code', 'adyen_oneclick');
     $baCollection->addActiveFilter();
     foreach ($baCollection as $billingAgreement) {
         $agreementData = $billingAgreement->getAgreementData();
         // no agreementData and contractType then ignore
         if (!is_array($agreementData) || !isset($agreementData['contractTypes'])) {
             continue;
         }
         // check if contractType is supporting the selected contractType for OneClick payments
         $allowedContractTypes = $agreementData['contractTypes'];
         if (in_array($recurringType, $allowedContractTypes)) {
             // check if AgreementLabel is set and if contract has an recurringType
             if ($billingAgreement->getAgreementLabel()) {
                 // for Ideal use sepadirectdebit because it is
                 if ($agreementData['variant'] == 'ideal') {
                     $agreementData['variant'] = 'sepadirectdebit';
                 }
                 $data = ['reference_id' => $billingAgreement->getReferenceId(), 'agreement_label' => $billingAgreement->getAgreementLabel(), 'agreement_data' => $agreementData];
                 if ($this->showLogos()) {
                     $logoName = $agreementData['variant'];
                     $asset = $this->createAsset('Adyen_Payment::images/logos/' . $logoName . '.png');
                     $icon = null;
                     $placeholder = $this->_assetSource->findSource($asset);
                     if ($placeholder) {
                         list($width, $height) = getimagesize($asset->getSourceFile());
                         $icon = ['url' => $asset->getUrl(), 'width' => $width, 'height' => $height];
                     }
                     $data['logo'] = $icon;
                 }
                 /**
                  * Check if there are installments for this creditcard type defined
                  */
                 $data['number_of_installments'] = 0;
                 $ccType = $this->getMagentoCreditCartType($agreementData['variant']);
                 $installments = null;
                 $installmentsValue = $this->getAdyenCcConfigData('installments');
                 if ($installmentsValue) {
                     $installments = unserialize($installmentsValue);
                 }
                 if ($installments) {
                     $numberOfInstallments = null;
                     foreach ($installments as $ccTypeInstallment => $installment) {
                         if ($ccTypeInstallment == $ccType) {
                             foreach ($installment as $amount => $installments) {
                                 if ($grandTotal <= $amount) {
                                     $numberOfInstallments = $installments;
                                 }
                             }
                         }
                     }
                     if ($numberOfInstallments) {
                         $data['number_of_installments'] = $numberOfInstallments;
                     }
                 }
                 $billingAgreements[] = $data;
             }
         }
     }
     return $billingAgreements;
 }