From aba8bdb24a5149309502389314282e1574647a5e Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 18 Jan 2021 11:57:18 +0100 Subject: [PATCH 1/2] Do not register the invoice as it is not yet paid --- app/code/community/Mollie/Mpm/Model/Client/Orders.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/code/community/Mollie/Mpm/Model/Client/Orders.php b/app/code/community/Mollie/Mpm/Model/Client/Orders.php index 5dd31af..95863e3 100644 --- a/app/code/community/Mollie/Mpm/Model/Client/Orders.php +++ b/app/code/community/Mollie/Mpm/Model/Client/Orders.php @@ -266,9 +266,13 @@ public function processTransaction(Mage_Sales_Model_Order $order, $type = 'webho $invoice = $order->prepareInvoice(); $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE); $invoice->setTransactionId($transactionId); - $invoice->register(); - $invoice->setState($this->mollieHelper->getInvoiceMomentPaidStatus($order)); + $invoiceStatus = $this->mollieHelper->getInvoiceMomentPaidStatus($order); + if ($invoiceStatus == \Mage_Sales_Model_Order_Invoice::STATE_PAID) { + $invoice->register(); + } + + $invoice->setState($invoiceStatus); Mage::getModel('core/resource_transaction') ->addObject($invoice) From eb9b85aeb7b9c26570d7bd189e74d10cfcec4ff2 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 18 Jan 2021 13:49:12 +0100 Subject: [PATCH 2/2] Bugfix: Replace special characters in product names --- .../community/Mollie/Mpm/Model/OrderLines.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/code/community/Mollie/Mpm/Model/OrderLines.php b/app/code/community/Mollie/Mpm/Model/OrderLines.php index 8466df0..7df0e24 100644 --- a/app/code/community/Mollie/Mpm/Model/OrderLines.php +++ b/app/code/community/Mollie/Mpm/Model/OrderLines.php @@ -104,7 +104,7 @@ public function getOrderLines(Mage_Sales_Model_Order $order) $orderLine = array( 'item_id' => $item->getId(), 'type' => $item->getProduct()->getTypeId() != 'downloadable' ? 'physical' : 'digital', - 'name' => preg_replace("/[^A-Za-z0-9 -]/", "", $item->getName()), + 'name' => $this->getProductName($item->getName()), 'quantity' => round($item->getQtyOrdered()), 'unitPrice' => $this->mollieHelper->getAmountArray($currency, $unitPrice), 'totalAmount' => $this->mollieHelper->getAmountArray($currency, $totalAmount), @@ -503,4 +503,17 @@ public function getOpenForRefundQty($orderId) return $qty; } + + /** + * @param string $name + * @return string + */ + private function getProductName($name) + { + $search = explode('','', 'ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,ø,Ø,Å,Á,À,Â,Ä,È,É,Ê,Ë,Í,Î,Ï,Ì,Ò,Ó,Ô,Ö,Ú,Ù,Û,Ü,Ÿ,Ç,Æ,Œ'); + $replace = explode('','', 'c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,o,O,A,A,A,A,A,E,E,E,E,I,I,I,I,O,O,O,O,U,U,U,U,Y,C,AE,OE'); + $name = str_replace($search, $replace, $name); + + return preg_replace('/[^A-Za-z0-9 -]/', '', $name); + } }