From 636e8e441e80e5ba1fc442c4ccdd0443ee08653a Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 27 Jul 2020 16:09:24 +0200 Subject: [PATCH 1/6] Bugfix: Try to run the autoloader so that the Mollie SDK is available on the CLI --- app/code/community/Mollie/Mpm/Helper/Data.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/community/Mollie/Mpm/Helper/Data.php b/app/code/community/Mollie/Mpm/Helper/Data.php index 1c8b950..077d340 100644 --- a/app/code/community/Mollie/Mpm/Helper/Data.php +++ b/app/code/community/Mollie/Mpm/Helper/Data.php @@ -798,6 +798,10 @@ public function getMollieAPI($apiKey) return $this->mollieApi; } + 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); From 4023c5266751e085c3c30208414c4551082a3947 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 9 Nov 2020 11:44:29 +0100 Subject: [PATCH 2/6] Sometimes the wrong api key could be used --- app/code/community/Mollie/Mpm/Helper/Data.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/community/Mollie/Mpm/Helper/Data.php b/app/code/community/Mollie/Mpm/Helper/Data.php index 1c8b950..2cdeb63 100644 --- a/app/code/community/Mollie/Mpm/Helper/Data.php +++ b/app/code/community/Mollie/Mpm/Helper/Data.php @@ -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 */ @@ -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); @@ -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)) { @@ -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]; } /** From 201e308399bb521bed7d80a6a40899af8faad5e2 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 16 Nov 2020 15:20:42 +0100 Subject: [PATCH 3/6] Make sure the SDK instance is unique per apikey --- app/code/community/Mollie/Mpm/Helper/Data.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/community/Mollie/Mpm/Helper/Data.php b/app/code/community/Mollie/Mpm/Helper/Data.php index 2cdeb63..26fa1e1 100644 --- a/app/code/community/Mollie/Mpm/Helper/Data.php +++ b/app/code/community/Mollie/Mpm/Helper/Data.php @@ -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 @@ -794,8 +794,8 @@ 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')) { @@ -803,8 +803,8 @@ public function getMollieAPI($apiKey) $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); From 279753067ec77e8edee2c285dfca900c58062ffb Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 7 Dec 2020 15:05:20 +0100 Subject: [PATCH 4/6] Limit the mollie.js JS to the checkout --- app/code/community/Mollie/Mpm/Model/Observer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/community/Mollie/Mpm/Model/Observer.php b/app/code/community/Mollie/Mpm/Model/Observer.php index 7e37d8d..7eb8511 100644 --- a/app/code/community/Mollie/Mpm/Model/Observer.php +++ b/app/code/community/Mollie/Mpm/Model/Observer.php @@ -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(); From 26d76eff4b71f17202eb44ca9b4d0425f3b6ecc5 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 14 Dec 2020 16:02:42 +0100 Subject: [PATCH 5/6] Bugfix: Send invoices when the API method is orders --- app/code/community/Mollie/Mpm/Model/Client/Orders.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Mollie/Mpm/Model/Client/Orders.php b/app/code/community/Mollie/Mpm/Model/Client/Orders.php index 5dd31af..9cd5145 100644 --- a/app/code/community/Mollie/Mpm/Model/Client/Orders.php +++ b/app/code/community/Mollie/Mpm/Model/Client/Orders.php @@ -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 { From c687f670e3ecc9bd27f4f8b1ed1708c631b44c24 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Mon, 28 Dec 2020 14:44:53 +0100 Subject: [PATCH 6/6] Version bump --- app/code/community/Mollie/Mpm/etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Mollie/Mpm/etc/config.xml b/app/code/community/Mollie/Mpm/etc/config.xml index 4bf55bc..1575469 100644 --- a/app/code/community/Mollie/Mpm/etc/config.xml +++ b/app/code/community/Mollie/Mpm/etc/config.xml @@ -33,7 +33,7 @@ - 5.6.1 + 5.6.2