Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to view orders paid with removed payment method without breaking #15

Merged

Conversation

tmewes
Copy link
Contributor

@tmewes tmewes commented Sep 3, 2024

Description

Maho currently can't handle deleted/removed payment methods in orders in the frontend as well as in the adminhtml.

Example: An external payment module for the payment method Amazon Pay had been installed. Some customers used this payment method for their orders in the past. The module was then removed again because a different payment method was to be introduced instead.

A customer who used such removed payment method currrently will get this error when viewing the order in the customer account:

There has been an error processing your request

The requested Payment Method is not available.

Trace:
#0 /var/www/html/app/code/core/Mage/Payment/Model/Info.php(101): Mage::throwException('The requested P...')
#1 /var/www/html/app/code/core/Mage/Payment/Helper/Data.php(131): Mage_Payment_Model_Info->getMethodInstance()
#2 /var/www/html/app/code/core/Mage/Sales/Block/Order/Info.php(47): Mage_Payment_Helper_Data->getInfoBlock(Object(Mage_Sales_Model_Order_Payment))
#3 /var/www/html/app/code/core/Mage/Core/Block/Abstract.php(299): Mage_Sales_Block_Order_Info->_prepareLayout()
#4 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(474): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#5 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(490): Mage_Core_Model_Layout->createBlock('sales/order_inf...', 'sales.order.inf...')
#6 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(234): Mage_Core_Model_Layout->addBlock('sales/order_inf...', 'sales.order.inf...')
#7 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(200): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#8 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#9 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(348): Mage_Core_Model_Layout->generateBlocks()
#10 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(259): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#11 /var/www/html/app/code/core/Mage/Sales/Controller/Abstract.php(51): Mage_Core_Controller_Varien_Action->loadLayout()
#12 /var/www/html/app/code/core/Mage/Sales/Controller/Abstract.php(93): Mage_Sales_Controller_Abstract->_viewAction()
#13 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(424): Mage_Sales_Controller_Abstract->viewAction()
#14 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(255): Mage_Core_Controller_Varien_Action->dispatch('view')
#15 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(181): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#16 /var/www/html/app/code/core/Mage/Core/Model/App.php(358): Mage_Core_Controller_Varien_Front->dispatch()
#17 /var/www/html/app/Mage.php(700): Mage_Core_Model_App->run(Array)
#18 /var/www/html/pub/index.php(59): Mage::run('', 'store')
#19 {main}

This PR handles removed payment methods in the frontend e.g. on customer account order view pages as well as in the adminhtml e.g. on sales order view pages so they will successfully render again.

Type of change

Fix

How can this fix be tested

  1. Checkout the main branch (without this fix).
  2. Create a customer account.
  3. Place an order.
  4. View the order in the customer account.
  5. The order view page will render successfully and displays, among other things, the payment method selected when ordering correctly.
  6. Change the payment method of the order in sales_flat_order_payment database table (column method) to a non existent payment method (to simulate a removed payment method), e.g. some_obsolete_payment_method.
  7. Reload the customer account order view page and see the above error message.
  8. Checkout the branch of this PR including the fix.
  9. Reload the customer account order view page.
  10. The page will render successfully again and displays, among other things, at least the payment method code (e.g. some_obsolete_payment_method) in the payment information block.
  11. A notice is logged so that this case can be tracked if necessary.
  12. View the oder in adminhtml.
  13. The sales oder view page will render successfully again and displays, among other things, at least the payment method code (e.g. some_obsolete_payment_method) in the payment information block.

@fballiano
Copy link
Contributor

@tmewes this is beautiful, will do a quick test as soon as I have a break from the language-pack generation work and we'll try to merge it right away.

@fballiano
Copy link
Contributor

@tmewes I've changed the "method" on an order but I've 2 problems

without developer mode

I see this

Screenshot 2024-09-05 alle 23 43 46

with developer mode

I see this

Screenshot 2024-09-05 alle 23 44 39

weird :-\

@tmewes tmewes changed the title Order View: Handle Removed Payment Methods Frontend Order View: Handle Removed Payment Methods Sep 6, 2024
@tmewes
Copy link
Contributor Author

tmewes commented Sep 6, 2024

Yes, this PR only affects the frontend (which is why I only addressed it in the test steps). I would prepare a separate PR for the adminhtml, as there are a few other problem areas with missing or removed payment methods. I think this can be better tracked and tested with a separate PR, which will follow soon. :)

@fballiano
Copy link
Contributor

ahhh right, you also wrote it in the PR name 🤦🏻 sorry

If you want to do 2 separate PRs that's ok but we have to merge them both together so as you prefer :-)

@tmewes tmewes changed the title Frontend Order View: Handle Removed Payment Methods Order View: Handle Removed Payment Methods Sep 6, 2024
@tmewes
Copy link
Contributor Author

tmewes commented Sep 6, 2024

The code for fixing the frontend is needed for fixing the adminhtml, so we can't merge those two PRs both together.
But no problem, I added fixes for the adminhtml in this PR and adjusted the title, description and test steps in this PR. :)

Could you please test again to see if everything works now?

@fballiano
Copy link
Contributor

sorry for the notes @tmewes :-(((

@tmewes
Copy link
Contributor Author

tmewes commented Sep 10, 2024

Everything is fine, I've adjusted the mentioned parts again and added explanations/answers to your questions from your review. :)

@tmewes tmewes requested a review from fballiano September 12, 2024 14:55
@fballiano fballiano changed the title Order View: Handle Removed Payment Methods Added ability to view orders paid with removed payment method without breaking Sep 12, 2024
@fballiano fballiano merged commit 1f8db2d into MahoCommerce:main Sep 12, 2024
12 checks passed
@fballiano
Copy link
Contributor

Retested today, re-read and everything looks ok to me, thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants