diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f63cbf9db4..9bf0687b626 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ for secured payment methods and PayPal. - Disable caching for dynamic blocks. - An issue creating orders from Reservations. - Problem when switching from an unknown payment method to a heidelpay gateway method. +- Invoice Payment methods : An issue not always setting the expected state after shipment. ## 20.2.24 ### Added diff --git a/Controller/Adminhtml/Order/Shipment/Save.php b/Controller/Adminhtml/Order/Shipment/Save.php index 7eb471390cd..ab851c57bac 100755 --- a/Controller/Adminhtml/Order/Shipment/Save.php +++ b/Controller/Adminhtml/Order/Shipment/Save.php @@ -131,8 +131,8 @@ public function beforeExecute() // if the response isn't successful, redirect back to the order view. if (!$heidelpayMethod->getResponse()->isSuccess()) { - $this->messageManager->addErrorMessage( - __('Heidelpay Error at sending Finalize Request. The Shipment was not created.') + $this->messageManager->addWarningMessage( + __('Heidelpay Error at sending Finalize Request. The Shipment was created.') . ' Error Message: ' . $heidelpayMethod->getResponse()->getError()['message'] ); @@ -142,16 +142,14 @@ public function beforeExecute() ); $this->_redirect('*/*/new', ['order_id' => $this->getRequest()->getParam('order_id')]); + } else { + $order->addStatusHistoryComment('heidelpay - Finalizing Order'); + $this->messageManager->addSuccessMessage(__('Shipping Notification has been sent to Heidelpay.')); } - // set order state to "pending payment" - $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.')); } + $method->setShippedOrderState($order); + $this->orderResository->save($order); } } } diff --git a/PaymentMethods/HeidelpayAbstractPaymentMethod.php b/PaymentMethods/HeidelpayAbstractPaymentMethod.php index 70140f134e9..029fc837f9d 100755 --- a/PaymentMethods/HeidelpayAbstractPaymentMethod.php +++ b/PaymentMethods/HeidelpayAbstractPaymentMethod.php @@ -889,6 +889,14 @@ public function getUseShippingAddressAsBillingAddress() return $this->useShippingAddressAsBillingAddress; } + /** + * Define order status after shipment. + * @param $order + */ + public function setShippedOrderState(&$order) + { + } + /** * Load the payment information by store id, customer email address and payment method of the quote * diff --git a/PaymentMethods/HeidelpayInvoicePaymentMethod.php b/PaymentMethods/HeidelpayInvoicePaymentMethod.php index 227cfd850b9..f2c8957848e 100755 --- a/PaymentMethods/HeidelpayInvoicePaymentMethod.php +++ b/PaymentMethods/HeidelpayInvoicePaymentMethod.php @@ -15,6 +15,7 @@ use Exception; use Heidelpay\Gateway\Block\Info\Invoice as InvoiceBlock; +use Heidelpay\Gateway\Traits\CanShipBeforePayment; use Heidelpay\PhpPaymentApi\Exceptions\UndefinedTransactionModeException; use Heidelpay\PhpPaymentApi\PaymentMethods\InvoicePaymentMethod; use Magento\Sales\Model\Order; @@ -27,6 +28,8 @@ */ class HeidelpayInvoicePaymentMethod extends HeidelpayAbstractPaymentMethod { + use CanShipBeforePayment; + /** @var string Payment Code */ const CODE = 'hgwiv'; diff --git a/PaymentMethods/HeidelpayInvoiceSecuredPaymentMethod.php b/PaymentMethods/HeidelpayInvoiceSecuredPaymentMethod.php index 962a631c490..d9ccc2e133a 100755 --- a/PaymentMethods/HeidelpayInvoiceSecuredPaymentMethod.php +++ b/PaymentMethods/HeidelpayInvoiceSecuredPaymentMethod.php @@ -15,6 +15,7 @@ use Heidelpay\Gateway\Block\Info\InvoiceSecured as InvoiceSecuredBlock; use Heidelpay\Gateway\Model\PaymentInformation; +use Heidelpay\Gateway\Traits\CanShipBeforePayment; use Heidelpay\PhpPaymentApi\Exceptions\UndefinedTransactionModeException; use Heidelpay\PhpPaymentApi\PaymentMethods\InvoiceB2CSecuredPaymentMethod; use Magento\Quote\Api\Data\CartInterface; @@ -28,6 +29,7 @@ */ class HeidelpayInvoiceSecuredPaymentMethod extends HeidelpayAbstractPaymentMethod { + use CanShipBeforePayment; /** @var string Payment Code */ const CODE = 'hgwivs'; diff --git a/PaymentMethods/Traits/CanShipBeforePayment.php b/PaymentMethods/Traits/CanShipBeforePayment.php new file mode 100644 index 00000000000..a2da31b96e4 --- /dev/null +++ b/PaymentMethods/Traits/CanShipBeforePayment.php @@ -0,0 +1,33 @@ +getTotalPaid() < $order->getGrandTotal()) { + $state = Order::STATE_PENDING_PAYMENT; + $status = $order->getConfig()->getStateDefaultStatus($state); + $order->setState($state)->setStatus($status); + } + } +}