We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 00751462 authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

read module version from composer.json (#569)

* read module version from composer.json

* Fix with the PHP Code Beautifier and Fixer (phpcbf)
parent 7bcd4646
...@@ -136,6 +136,11 @@ class Data extends AbstractHelper ...@@ -136,6 +136,11 @@ class Data extends AbstractHelper
*/ */
private $serializer; private $serializer;
/**
* @var \Magento\Framework\Component\ComponentRegistrarInterface
*/
private $componentRegistrar;
/** /**
* Data constructor. * Data constructor.
* @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Helper\Context $context
...@@ -181,7 +186,8 @@ class Data extends AbstractHelper ...@@ -181,7 +186,8 @@ class Data extends AbstractHelper
\Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Backend\Helper\Data $helperBackend, \Magento\Backend\Helper\Data $helperBackend,
\Magento\Framework\Serialize\SerializerInterface $serializer \Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
...@@ -204,6 +210,7 @@ class Data extends AbstractHelper ...@@ -204,6 +210,7 @@ class Data extends AbstractHelper
$this->config = $config; $this->config = $config;
$this->helperBackend = $helperBackend; $this->helperBackend = $helperBackend;
$this->serializer = $serializer; $this->serializer = $serializer;
$this->componentRegistrar = $componentRegistrar;
} }
/** /**
...@@ -384,19 +391,19 @@ class Data extends AbstractHelper ...@@ -384,19 +391,19 @@ class Data extends AbstractHelper
return (['name' => trim($streetName), 'house_number' => $streetNr]); return (['name' => trim($streetName), 'house_number' => $streetNr]);
} }
/** /**
* Street format * Street format
* @param string $streetLine * @param string $streetLine
* @return array * @return array
*/ */
public function getStreetFromString($streetLine) public function getStreetFromString($streetLine)
{ {
$street = self::formatStreet([$streetLine]); $street = self::formatStreet([$streetLine]);
$streetName = $street['0']; $streetName = $street['0'];
unset($street['0']); unset($street['0']);
$streetNr = implode(' ', $street); $streetNr = implode(' ', $street);
return (['name' => trim($streetName), 'house_number' => $streetNr]); return (['name' => trim($streetName), 'house_number' => $streetNr]);
} }
/** /**
* Fix this one string street + number * Fix this one string street + number
...@@ -733,11 +740,15 @@ class Data extends AbstractHelper ...@@ -733,11 +740,15 @@ class Data extends AbstractHelper
public function getAPIKey($storeId = null) public function getAPIKey($storeId = null)
{ {
if ($this->isDemoMode($storeId)) { if ($this->isDemoMode($storeId)) {
$apiKey = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('api_key_test', $apiKey = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData(
$storeId))); 'api_key_test',
$storeId
)));
} else { } else {
$apiKey = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData('api_key_live', $apiKey = $this->_encryptor->decrypt(trim($this->getAdyenAbstractConfigData(
$storeId))); 'api_key_live',
$storeId
)));
} }
return $apiKey; return $apiKey;
} }
...@@ -864,13 +875,22 @@ class Data extends AbstractHelper ...@@ -864,13 +875,22 @@ class Data extends AbstractHelper
} }
/** /**
* Get adyen magento module's version * Get adyen magento module's version from composer.json
* *
* @return string * @return string
*/ */
public function getModuleVersion() public function getModuleVersion()
{ {
return (string)$this->_moduleList->getOne("Adyen_Payment")['setup_version']; $moduleDir = $this->componentRegistrar->getPath(\Magento\Framework\Component\ComponentRegistrar::MODULE, 'Adyen_Payment');
$composerJson = file_get_contents($moduleDir . '/composer.json');
$composerJson = json_decode($composerJson, true);
if (empty($composerJson['version'])) {
return "Version is not available in composer.json";
}
return $composerJson['version'];
} }
public function getBoletoTypes() public function getBoletoTypes()
...@@ -1023,18 +1043,18 @@ class Data extends AbstractHelper ...@@ -1023,18 +1043,18 @@ class Data extends AbstractHelper
return false; return false;
} }
/** /**
* @param $paymentMethod * @param $paymentMethod
* @return bool * @return bool
*/ */
public function isPaymentMethodAfterpayTouchMethod($paymentMethod) public function isPaymentMethodAfterpayTouchMethod($paymentMethod)
{ {
if (strpos($paymentMethod, 'afterpaytouch') !== false) { if (strpos($paymentMethod, 'afterpaytouch') !== false) {
return true; return true;
} }
return false; return false;
} }
/** /**
* @param $paymentMethod * @param $paymentMethod
...@@ -1537,7 +1557,8 @@ class Data extends AbstractHelper ...@@ -1537,7 +1557,8 @@ class Data extends AbstractHelper
/** /**
* @return string * @return string
*/ */
public function getOrigin() { public function getOrigin()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('Magento\Framework\App\State'); $state = $objectManager->get('Magento\Framework\App\State');
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB); $baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
...@@ -1666,13 +1687,17 @@ class Data extends AbstractHelper ...@@ -1666,13 +1687,17 @@ class Data extends AbstractHelper
if ($billingAgreement->getCustomerId() === null) { if ($billingAgreement->getCustomerId() === null) {
$billingAgreement->setCustomerId($this->getCustomerId($order)); $billingAgreement->setCustomerId($this->getCustomerId($order));
} }
$message = __('Created billing agreement #%1.', $message = __(
$additionalData['recurring.recurringDetailReference']); 'Created billing agreement #%1.',
$additionalData['recurring.recurringDetailReference']
);
} else { } else {
$billingAgreement->setIsObjectChanged(true); $billingAgreement->setIsObjectChanged(true);
$message = __('Updated billing agreement #%1.', $message = __(
$additionalData['recurring.recurringDetailReference']); 'Updated billing agreement #%1.',
$additionalData['recurring.recurringDetailReference']
);
} }
// Populate billing agreement data // Populate billing agreement data
...@@ -1683,8 +1708,10 @@ class Data extends AbstractHelper ...@@ -1683,8 +1708,10 @@ class Data extends AbstractHelper
if ($billingAgreement->isValid() && empty($billingAgreementErrors)) { if ($billingAgreement->isValid() && empty($billingAgreementErrors)) {
if (!$this->agreementResourceModel->getOrderRelation($billingAgreement->getAgreementId(), if (!$this->agreementResourceModel->getOrderRelation(
$order->getId())) { $billingAgreement->getAgreementId(),
$order->getId()
)) {
// save into sales_billing_agreement_order // save into sales_billing_agreement_order
$billingAgreement->addOrderRelation($order); $billingAgreement->addOrderRelation($order);
...@@ -1692,8 +1719,10 @@ class Data extends AbstractHelper ...@@ -1692,8 +1719,10 @@ class Data extends AbstractHelper
// add to order to save agreement // add to order to save agreement
$order->addRelatedObject($billingAgreement); $order->addRelatedObject($billingAgreement);
} else { } else {
$message = __('Failed to create billing agreement for this order. Reason(s): ') . join(', ', $message = __('Failed to create billing agreement for this order. Reason(s): ') . join(
$billingAgreementErrors); ', ',
$billingAgreementErrors
);
throw new \Exception($message); throw new \Exception($message);
} }
...@@ -1792,38 +1821,38 @@ class Data extends AbstractHelper ...@@ -1792,38 +1821,38 @@ class Data extends AbstractHelper
return $this->getAdyenCcConfigDataFlag('threeds2_enabled', $storeId); return $this->getAdyenCcConfigDataFlag('threeds2_enabled', $storeId);
} }
/** /**
* @param $client * @param $client
* @return \Adyen\Service\Checkout * @return \Adyen\Service\Checkout
*/ */
public function createAdyenCheckoutService($client) public function createAdyenCheckoutService($client)
{ {
return new \Adyen\Service\Checkout($client); return new \Adyen\Service\Checkout($client);
} }
/** /**
* @param $client * @param $client
* @return \Adyen\Service\Recurring * @return \Adyen\Service\Recurring
* @throws \Adyen\AdyenException * @throws \Adyen\AdyenException
*/ */
public function createAdyenRecurringService($client) public function createAdyenRecurringService($client)
{ {
return new \Adyen\Service\Recurring($client); return new \Adyen\Service\Recurring($client);
} }
/** /**
* @param string $date * @param string $date
* @param string $format * @param string $format
* @return mixed * @return mixed
*/ */
public function formatDate($date = null, $format = 'Y-m-d H:i:s') public function formatDate($date = null, $format = 'Y-m-d H:i:s')
{ {
if (strlen($date) < 0) { if (strlen($date) < 0) {
$date = date('d-m-Y H:i:s'); $date = date('d-m-Y H:i:s');
} }
$timeStamp = new \DateTime($date); $timeStamp = new \DateTime($date);
return $timeStamp->format($format); return $timeStamp->format($format);
} }
/** /**
* @param string|null $type * @param string|null $type
...@@ -1834,7 +1863,7 @@ class Data extends AbstractHelper ...@@ -1834,7 +1863,7 @@ class Data extends AbstractHelper
{ {
$response = ['threeDS2' => false]; $response = ['threeDS2' => false];
if(!empty($type)) { if (!empty($type)) {
$response['type'] = $type; $response['type'] = $type;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment