Skip to content

Commit

Permalink
Merge pull request #193 from mollie/5.6.2
Browse files Browse the repository at this point in the history
5.6.2
  • Loading branch information
Marvin-Magmodules authored Dec 28, 2020
2 parents e42f505 + c687f67 commit 13dec20
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
30 changes: 17 additions & 13 deletions app/code/community/Mollie/Mpm/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class Mollie_Mpm_Helper_Data extends Mage_Core_Helper_Abstract
*/
public $debug = null;
/**
* @var
* @var array
*/
public $apiKey = null;
public $apiKey = [];
/**
* @var
*/
Expand All @@ -78,9 +78,9 @@ class Mollie_Mpm_Helper_Data extends Mage_Core_Helper_Abstract
*/
public $mollieMethods = null;
/**
* @var \Mollie\Api\MollieApiClient
* @var \Mollie\Api\MollieApiClient[]
*/
public $mollieApi = null;
public $mollieApi = [];

/**
* @deprecated
Expand Down Expand Up @@ -146,8 +146,8 @@ public function getStoreConfig($path, $storeId = null)
*/
public function getApiKey($storeId = null)
{
if ($this->apiKey !== null) {
return $this->apiKey;
if (array_key_exists($storeId, $this->apiKey)) {
return $this->apiKey[$storeId];
}

$modus = $this->getModus($storeId);
Expand All @@ -161,7 +161,7 @@ public function getApiKey($storeId = null)
$this->addTolog('error', 'Mollie set to test modus, but API key does not start with "test_"');
}

$this->apiKey = $apiKey;
$this->apiKey[$storeId] = $apiKey;
} else {
$apiKey = trim($this->getStoreConfig(self::XPATH_LIVE_APIKEY, $storeId));
if (empty($apiKey)) {
Expand All @@ -172,10 +172,10 @@ public function getApiKey($storeId = null)
$this->addTolog('error', 'Mollie set to live modus, but API key does not start with "live_"');
}

$this->apiKey = $apiKey;
$this->apiKey[$storeId] = $apiKey;
}

return $this->apiKey;
return $this->apiKey[$storeId];
}

/**
Expand Down Expand Up @@ -794,17 +794,21 @@ public function getAvailableMethods($storeId, $quote = null, $resource = 'orders
*/
public function getMollieAPI($apiKey)
{
if ($this->mollieApi !== null) {
return $this->mollieApi;
if (array_key_exists($apiKey, $this->mollieApi)) {
return $this->mollieApi[$apiKey];
}

if (!class_exists('Mollie\Api\MollieApiClient')) {
(new Mollie_Mpm_Helper_Autoloader)->createAndRegister();
}

if (class_exists('Mollie\Api\MollieApiClient')) {
$mollieApiClient = new \Mollie\Api\MollieApiClient();
$mollieApiClient->setApiKey($apiKey);
$mollieApiClient->addVersionString('Magento/' . $this->getMagentoVersion());
$mollieApiClient->addVersionString('MollieMagento/' . $this->getExtensionVersion());
$this->mollieApi = $mollieApiClient;
return $this->mollieApi;
$this->mollieApi[$apiKey] = $mollieApiClient;
return $this->mollieApi[$apiKey];
} else {
$msg = $this->__('Could not load Mollie Api.');
Mage::throwException($msg);
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Mollie/Mpm/Model/Client/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function processTransaction(Mage_Sales_Model_Order $order, $type = 'webho
/** @var Mage_Sales_Model_Order_Invoice $invoice */
$invoice = isset($invoice) ? $invoice : $payment->getCreatedInvoice();
$sendInvoice = $this->mollieHelper->sendInvoice($storeId) &&
$this->mollieHelper->getInvoiceMoment($order) == \Mollie_Mpm_Model_Adminhtml_System_Config_Source_InvoiceMoment::ON_AUTHORIZE_PAID_BEFORE_SHIPMENT;
$this->mollieHelper->getInvoiceMoment($order) == \Mollie_Mpm_Model_Adminhtml_System_Config_Source_InvoiceMoment::ON_AUTHORIZE_PAID_AFTER_SHIPMENT;

if (!$order->getEmailSent()) {
try {
Expand Down
4 changes: 4 additions & 0 deletions app/code/community/Mollie/Mpm/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ public function injectMollieComponentsJs(Varien_Event_Observer $observer)
return;
}

if (stripos(Mage::app()->getRequest()->getControllerModule(), 'checkout') === false) {
return;
}

/** @var \Varient_Object $transport */
$transport = $observer->getData('transport');
$html = $transport->getHtml();
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Mollie/Mpm/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<config>
<modules>
<Mollie_Mpm>
<version>5.6.1</version>
<version>5.6.2</version>
</Mollie_Mpm>
</modules>
<global>
Expand Down

0 comments on commit 13dec20

Please sign in to comment.