diff --git a/app/code/community/Mollie/Mpm/Model/Client/Orders.php b/app/code/community/Mollie/Mpm/Model/Client/Orders.php index 9cd5145..5be429a 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) 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); + } }