From bff087b463bc3036ab4bf4dc555626a496ea6dff Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Tue, 5 Mar 2019 14:17:48 +0100 Subject: [PATCH 01/15] [change](MAGE2-115) Improved Response::execute behaviour if post is empty. --- CHANGELOG.md | 6 ++++++ Controller/Index/Response.php | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2d9a607a6..9d56fedb07e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ This project does not follow a versioning standard. Versions are crafted after the dates; for example, the version 17.7.25 was released on July, 25th in 2017 +## 19.xx.xx + +### Changed +- improved response handling if Post data are empty: Customer gets redirected to cart with an error message. Wording of +log entry was changed for a better understanding. + ## 19.1.30 ### Fixed diff --git a/Controller/Index/Response.php b/Controller/Index/Response.php index b38c1f21e1e..2ff5e8f06ee 100755 --- a/Controller/Index/Response.php +++ b/Controller/Index/Response.php @@ -139,13 +139,17 @@ public function execute() // the payment just wants a url as result, so we set the content to the redirectUrl. $result->setContents($redirectUrl); - // if there is no post request, just do nothing and return the redirectUrl instantly, so an - // error message can be shown to the customer (which will be created in the redirect controller) + // if there is no post request, just redirect to the redirectUrl instantly, so an + // error message can be shown to the customer. if (!$this->getRequest()->isPost()) { - $this->_logger->warning('Heidelpay - Response: Request is not POST.'); + $this->_logger->warning( + 'Heidelpay - Response: There has been an error fetching the RedirectURL by the payment.' + . ' Please make sure the ResponseURL (' . $this->_url->getCurrentUrl() + . ') is accessible from the internet.' + ); - // no further processing. - return $result; + // no further processing and redirect. + return $this->_redirect($redirectUrl); } // initialize the Response object with data from the request. From 269c00ba3a80a89cbe33b9c13ecb98b1524a02c5 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Tue, 5 Mar 2019 17:02:36 +0100 Subject: [PATCH 02/15] [change](MAGE2-115) Solve PR issue --- Controller/Index/Response.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Controller/Index/Response.php b/Controller/Index/Response.php index 2ff5e8f06ee..0926f333c5b 100755 --- a/Controller/Index/Response.php +++ b/Controller/Index/Response.php @@ -139,17 +139,20 @@ public function execute() // the payment just wants a url as result, so we set the content to the redirectUrl. $result->setContents($redirectUrl); - // if there is no post request, just redirect to the redirectUrl instantly, so an - // error message can be shown to the customer. + // if there is no post request, just redirect to the cart instantly and show an error message to the customer. if (!$this->getRequest()->isPost()) { $this->_logger->warning( - 'Heidelpay - Response: There has been an error fetching the RedirectURL by the payment.' - . ' Please make sure the ResponseURL (' . $this->_url->getCurrentUrl() + 'Heidelpay - Response: There has been an error fetching the redirect url by the payment API.' + . ' Please make sure the response url (' . $this->_url->getCurrentUrl() . ') is accessible from the internet.' ); + $this->messageManager->addErrorMessage( + __('An unexpected error occurred. Please contact us to get further information.') + ); + // no further processing and redirect. - return $this->_redirect($redirectUrl); + return $this->_redirect('checkout/cart/', ['_secure' => true]); } // initialize the Response object with data from the request. From b4bf47d50366e1e2ce7435b39525d94afd3b75cc Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Mon, 25 Mar 2019 15:30:44 +0100 Subject: [PATCH 03/15] [bugfix] (MAGE2-154) Remove static version from composer command in installation manual. --- CHANGELOG.md | 3 ++- README.md | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d56fedb07e..9a752c6964a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,9 @@ This project does not follow a versioning standard. Versions are crafted after t ## 19.xx.xx ### Changed -- improved response handling if Post data are empty: Customer gets redirected to cart with an error message. Wording of +- Improved response handling if Post data is empty: Customer gets redirected to cart with an error message. Wording of log entry was changed for a better understanding. +- Removed static version from composer command in installation manual. ## 19.1.30 diff --git a/README.md b/README.md index ccc7b9fe394..1a991e27751 100755 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ All versions greater than 18.3.1 are based on the heidelpay php-payment-api. (ht ### Install the heidelpay Magento 2 composer package -```composer require "heidelpay/magento2:17.10.12"``` +```composer require "heidelpay/magento2"``` ### Enable the extension in Magento 2 @@ -76,4 +76,4 @@ support@heidelpay.com +49 (0)6221/6471-100 #### Twitter -@devHeidelpay \ No newline at end of file +@devHeidelpay From 0c1a7390e5475b45744840ff755702df613ac1b8 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Fri, 5 Apr 2019 16:15:38 +0200 Subject: [PATCH 04/15] [change](MAGE2-162) Fix an issue where a second refund references on the previous one and therefore cant be executed. --- PaymentMethods/HeidelpayAbstractPaymentMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaymentMethods/HeidelpayAbstractPaymentMethod.php b/PaymentMethods/HeidelpayAbstractPaymentMethod.php index 68476c3dc37..54337210b43 100755 --- a/PaymentMethods/HeidelpayAbstractPaymentMethod.php +++ b/PaymentMethods/HeidelpayAbstractPaymentMethod.php @@ -395,7 +395,7 @@ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) $collection = $this->transactionCollectionFactory->create(); /** @var \Heidelpay\Gateway\Model\Transaction $transactionInfo */ - $transactionInfo = $collection->loadByTransactionId($payment->getLastTransId()); + $transactionInfo = $collection->loadByTransactionId($payment->getParentTransactionId()); // if there is no heidelpay transaction, something went wrong. if ($transactionInfo === null || $transactionInfo->isEmpty()) { From 3d0c29037135564d61b014974bc1bcf54bcb2f8d Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Fri, 5 Apr 2019 18:51:20 +0200 Subject: [PATCH 05/15] [change](MAGE2-157) Fix an issue where the tax amount provided by magento is not correct. That can cause the finalize to fail. --- CHANGELOG.md | 3 ++- Wrapper/ItemWrapper.php | 7 ++++++- Wrapper/QuoteWrapper.php | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a752c6964a..a76b4ba5545 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ This project does not follow a versioning standard. Versions are crafted after the dates; for example, the version 17.7.25 was released on July, 25th in 2017 ## 19.xx.xx - +### Fixed +- Fixed an issue where the tax amount provided by magento is not correct. That can cause the finalize to fail. ### Changed - Improved response handling if Post data is empty: Customer gets redirected to cart with an error message. Wording of log entry was changed for a better understanding. diff --git a/Wrapper/ItemWrapper.php b/Wrapper/ItemWrapper.php index 8d098a0ca78..5a283e0588b 100755 --- a/Wrapper/ItemWrapper.php +++ b/Wrapper/ItemWrapper.php @@ -66,7 +66,12 @@ public function getDiscountAmount() */ public function getTaxAmount() { - return (int)floor(bcmul($this->item->getTaxAmount(), 100, 10)); + // calculate the tax amount manually since the amount given by magento ist not reliable sometimes. + return (int)floor(bcdiv( + bcmul($this->getRowTotalInclTax(), $this->getTaxPercent(), 10), + $this->getTaxPercent() + 100, + 10 + )); } /** diff --git a/Wrapper/QuoteWrapper.php b/Wrapper/QuoteWrapper.php index 33d11ca8b97..bc52231ce4c 100755 --- a/Wrapper/QuoteWrapper.php +++ b/Wrapper/QuoteWrapper.php @@ -95,8 +95,8 @@ public function getSubtotalWithDiscountAndShipping() */ public function getActualTaxAmount() { - - return $this->getActualSubtotalTax() + $this->getActualShippingTax(); + $totalAmount = (int)floor(bcmul($this->quote->getGrandTotal(), 100, 10)); + return $totalAmount - $this->getSubtotalWithDiscountAndShipping(); //brutto amount - netto amount } /** From b8edf6fbca7b0e6b6eb9cc31db2617858f2ed802 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Fri, 5 Apr 2019 16:15:38 +0200 Subject: [PATCH 06/15] [change](MAGE2-162) Fix an issue where a second refund references on the previous one and therefore cant be executed. --- CHANGELOG.md | 3 ++- PaymentMethods/HeidelpayAbstractPaymentMethod.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a752c6964a..ebb9aee688f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ This project does not follow a versioning standard. Versions are crafted after the dates; for example, the version 17.7.25 was released on July, 25th in 2017 ## 19.xx.xx - +### Fixed +- Fix an issue that prevented an invoice to be (partly) refunded twice. ### Changed - Improved response handling if Post data is empty: Customer gets redirected to cart with an error message. Wording of log entry was changed for a better understanding. diff --git a/PaymentMethods/HeidelpayAbstractPaymentMethod.php b/PaymentMethods/HeidelpayAbstractPaymentMethod.php index 68476c3dc37..54337210b43 100755 --- a/PaymentMethods/HeidelpayAbstractPaymentMethod.php +++ b/PaymentMethods/HeidelpayAbstractPaymentMethod.php @@ -395,7 +395,7 @@ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) $collection = $this->transactionCollectionFactory->create(); /** @var \Heidelpay\Gateway\Model\Transaction $transactionInfo */ - $transactionInfo = $collection->loadByTransactionId($payment->getLastTransId()); + $transactionInfo = $collection->loadByTransactionId($payment->getParentTransactionId()); // if there is no heidelpay transaction, something went wrong. if ($transactionInfo === null || $transactionInfo->isEmpty()) { From 88c531e8dbeac4ea5aff5772912fe8f57db4331f Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Thu, 18 Apr 2019 15:16:24 +0200 Subject: [PATCH 07/15] [change](MAGE2-165) An issue that can cause order prices differ from transaction price. e.g. different currencies. --- Controller/Index/Response.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Controller/Index/Response.php b/Controller/Index/Response.php index 0926f333c5b..1d500d53291 100755 --- a/Controller/Index/Response.php +++ b/Controller/Index/Response.php @@ -252,7 +252,6 @@ public function execute() // get the quote by transactionid from the heidelpay response /** @var Quote $quote */ $quote = $this->quoteRepository->get($this->heidelpayResponse->getIdentification()->getTransactionId()); - $quote->collectTotals(); // in case of guest checkout, set some customer related data. if ($this->getRequest()->getPost('CRITERION_GUEST') === 'true') { From 9a584d670d3e51d426efa244b8f19b85cd3c9f08 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Thu, 18 Apr 2019 15:40:39 +0200 Subject: [PATCH 08/15] [change](MAGE2-165) Update readme --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 162070ee55f..bcd06b1ed4e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project does not follow a versioning standard. Versions are crafted after t ### Fixed - An issue where the tax amount provided by magento is not correct. That can cause the finalize to fail. - An issue that prevented an invoice to be (partly) refunded twice. +- An issue where different curencies can cause that order is created in base currency. ### Changed - Improved response handling if Post data is empty: Customer gets redirected to cart with an error message. Wording of From 6f5c4f598d0d5ff2358450a81baf314068c80777 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Tue, 23 Apr 2019 10:04:51 +0200 Subject: [PATCH 09/15] [fix](MAGE2-165) Prevent setting status that doesnt exists. --- Model/Order/Payment/State/AuthorizeCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Model/Order/Payment/State/AuthorizeCommand.php b/Model/Order/Payment/State/AuthorizeCommand.php index f587ff0ee80..e60fc1e774e 100755 --- a/Model/Order/Payment/State/AuthorizeCommand.php +++ b/Model/Order/Payment/State/AuthorizeCommand.php @@ -32,8 +32,10 @@ class AuthorizeCommand extends \Magento\Sales\Model\Order\Payment\State\Authoriz */ public function execute(OrderPaymentInterface $payment, $amount, OrderInterface $order) { - $order->setStatus(Order::STATE_NEW) - ->setState(Order::STATE_NEW) + $state = Order::STATE_NEW; + $status = $order->getConfig()->getStateDefaultStatus($state); + $order->setStatus($status) + ->setState($state) ->setIsCustomerNotified(false); return __('heidelpay - Saving order'); From 3f016678ecff922e9da0176054d5d03b59405cb6 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Wed, 24 Apr 2019 11:08:44 +0200 Subject: [PATCH 10/15] Revert "[change](MAGE2-157) Fix an issue where the tax amount provided by magento is not correct. That can cause the finalize to fail." This reverts commit 3d0c290 --- CHANGELOG.md | 1 - Wrapper/ItemWrapper.php | 7 +------ Wrapper/QuoteWrapper.php | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 162070ee55f..7d1f3f60344 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ This project does not follow a versioning standard. Versions are crafted after t ## 19.xx.xx ### Fixed -- An issue where the tax amount provided by magento is not correct. That can cause the finalize to fail. - An issue that prevented an invoice to be (partly) refunded twice. ### Changed diff --git a/Wrapper/ItemWrapper.php b/Wrapper/ItemWrapper.php index 5a283e0588b..8d098a0ca78 100755 --- a/Wrapper/ItemWrapper.php +++ b/Wrapper/ItemWrapper.php @@ -66,12 +66,7 @@ public function getDiscountAmount() */ public function getTaxAmount() { - // calculate the tax amount manually since the amount given by magento ist not reliable sometimes. - return (int)floor(bcdiv( - bcmul($this->getRowTotalInclTax(), $this->getTaxPercent(), 10), - $this->getTaxPercent() + 100, - 10 - )); + return (int)floor(bcmul($this->item->getTaxAmount(), 100, 10)); } /** diff --git a/Wrapper/QuoteWrapper.php b/Wrapper/QuoteWrapper.php index bc52231ce4c..33d11ca8b97 100755 --- a/Wrapper/QuoteWrapper.php +++ b/Wrapper/QuoteWrapper.php @@ -95,8 +95,8 @@ public function getSubtotalWithDiscountAndShipping() */ public function getActualTaxAmount() { - $totalAmount = (int)floor(bcmul($this->quote->getGrandTotal(), 100, 10)); - return $totalAmount - $this->getSubtotalWithDiscountAndShipping(); //brutto amount - netto amount + + return $this->getActualSubtotalTax() + $this->getActualShippingTax(); } /** From ebe719a2065dc9d61b12a80d5631971ada910973 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Mon, 29 Apr 2019 11:10:00 +0200 Subject: [PATCH 11/15] [fix](MAGE2-165) Set store currency of the quote to be the same as the placed order. --- Controller/Index/Response.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Controller/Index/Response.php b/Controller/Index/Response.php index 1d500d53291..18ba2a8c18c 100755 --- a/Controller/Index/Response.php +++ b/Controller/Index/Response.php @@ -253,6 +253,8 @@ public function execute() /** @var Quote $quote */ $quote = $this->quoteRepository->get($this->heidelpayResponse->getIdentification()->getTransactionId()); + $quote->getStore()->setCurrentCurrencyCode($quote->getQuoteCurrencyCode()); + $quote->collectTotals(); // in case of guest checkout, set some customer related data. if ($this->getRequest()->getPost('CRITERION_GUEST') === 'true') { $quote->setCustomerId(null) From 0c1ea746cb0e978d9081bb9c8acba1e0b7fa5f3f Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Fri, 3 May 2019 16:57:12 +0200 Subject: [PATCH 12/15] [fix](MAGE2-170) Set corresponding state for order after shipping/finalize. --- Controller/Adminhtml/Order/Shipment/Save.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Controller/Adminhtml/Order/Shipment/Save.php b/Controller/Adminhtml/Order/Shipment/Save.php index 2a0c05cb975..cb13e14152f 100755 --- a/Controller/Adminhtml/Order/Shipment/Save.php +++ b/Controller/Adminhtml/Order/Shipment/Save.php @@ -144,9 +144,11 @@ public function beforeExecute() } // set order status to "pending payment" - $order->setStatus(Order::STATE_PENDING_PAYMENT) - ->addStatusHistoryComment('heidelpay - Finalizing Order', Order::STATE_PENDING_PAYMENT) - ->save(); + $state = Order::STATE_PENDING_PAYMENT; + $order->setState($state) + ->addStatusHistoryComment('heidelpay - Finalizing Order', true); + + $this->orderResository->save($order); $this->messageManager->addSuccessMessage(__('Shipping Notification has been sent to Heidelpay.')); } From c439a8f4ec8b5aafe282277d5c2b614bec87bdfe Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 3 May 2019 17:22:08 +0200 Subject: [PATCH 13/15] Update Controller/Adminhtml/Order/Shipment/Save.php Co-Authored-By: Ryouzanpaku <33735090+Ryouzanpaku@users.noreply.github.com> --- Controller/Adminhtml/Order/Shipment/Save.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Adminhtml/Order/Shipment/Save.php b/Controller/Adminhtml/Order/Shipment/Save.php index cb13e14152f..076327cc646 100755 --- a/Controller/Adminhtml/Order/Shipment/Save.php +++ b/Controller/Adminhtml/Order/Shipment/Save.php @@ -143,7 +143,7 @@ public function beforeExecute() $this->_redirect('*/*/new', ['order_id' => $this->getRequest()->getParam('order_id')]); } - // set order status to "pending payment" + // set order state to "pending payment" $state = Order::STATE_PENDING_PAYMENT; $order->setState($state) ->addStatusHistoryComment('heidelpay - Finalizing Order', true); From 8e8a77f72be26351b57731cbd4218ef801fde447 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Wed, 8 May 2019 09:55:51 +0200 Subject: [PATCH 14/15] (MAGE2-165) prepare release 19.5.08 --- CHANGELOG.md | 6 ++++-- etc/module.xml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab20cc6d274..68ce877751c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,12 @@ This project does not follow a versioning standard. Versions are crafted after the dates; for example, the version 17.7.25 was released on July, 25th in 2017 -## 19.xx.xx +## 19.5.08 +### Change +- improved status handling to ensure compatibility with magento 2.2.8 ### Fixed - An issue that prevented an invoice to be (partly) refunded twice. -- An issue where different curencies can cause that order is created in base currency. +- An issue where different currencies can cause that order is created in base currency. ### Changed - Improved response handling if Post data is empty: Customer gets redirected to cart with an error message. Wording of diff --git a/etc/module.xml b/etc/module.xml index 7ec2993f1c2..80b3d0f69e6 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - + From 417f5a9b9c161e92cb35f6360a3925579287f0bf Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Wed, 8 May 2019 14:06:56 +0200 Subject: [PATCH 15/15] Update etc/module.xml Co-Authored-By: Ryouzanpaku <33735090+Ryouzanpaku@users.noreply.github.com> --- etc/module.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/module.xml b/etc/module.xml index 80b3d0f69e6..af07672a047 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - + @@ -7,4 +7,4 @@ - \ No newline at end of file +