it4mage / CashOnDelivery

Cash on delivery module for Magento 2
25 stars 19 forks source link

Loading indefinitely M2.3.3 #23

Open NTRXIT opened 4 years ago

NTRXIT commented 4 years ago

As soon as I check the cash on delivery payment option it starts loading and never stops. I cannot proceed with the order unless I reload the page which of course doesn't work again. image

Preconditions

Steps to reproduce

Expected result

Actual result

  1. [Screenshot, logs]
arion-p commented 2 years ago

I am having the same issue. When "Cash on delivery " is selected the browser does an AJAX call to recompute the totals which fails and logs the following error in exception.log:

Report ID: webapi-615189885e89f; Message: Infinite loop detected, review the trace for the looping path {"exception":"[object] (Exception(code: 0): Report ID: webapi-615189885e89f; Message: Infinite loop detected, review the trace for the looping path at /var/www/public_html/vendor/magento/framework/Webapi/ErrorProcessor.php:208, LogicException(code: 0): Infinite loop detected, review the trace for the looping path at /var/www/public_html/vendor/magento/module-checkout/Model/Session.php:241)"} []

Printing a trace at the exception handler shows that COD extension code to calculate totals is called recursively I will try to post a trace later.

arion-p commented 2 years ago

Here is the backtrace as promissed. The issue appears to be in _canApplyTotal of MSP\CashOnDelivery\Model\Total\Quote\AbstractTotal. It calls $this->paymentMethodManagement->getList() by quote id which in turn tries to load the quote by id (ultimately calling getQuote()) and all of that happens within getQuote() (hence the infinite loop). _canApplyTotal should use some other way to determine if it is selected and should apply the fee.

[2021-10-04 08:49:53] main.ERROR: #1 Magento\Checkout\Model\Session\Interceptor[Magento\Checkout\Model\Session]#0000000070df9297000000005cfc2623#->getQuote() called at [generated/code/Magento/Checkout/Model/Session/Interceptor.php:50]
#2 Magento\Checkout\Model\Session\Interceptor#0000000070df9297000000005cfc2623#->getQuote() called at [vendor/klarna/module-kp/Model/Session.php:150]
#3 Klarna\Kp\Model\Session#0000000070df928a000000005cfc2623#->canSendRequest() called at [vendor/klarna/module-kp/Plugin/Payment/Helper/DataPlugin.php:124]
#4 Klarna\Kp\Plugin\Payment\Helper\DataPlugin#0000000070df92ba000000005cfc2623#->afterGetPaymentMethods(&Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#, array('free' => array('active' => 1, 'model' => 'Magento\Payment\...', 'order_status' => 'pending', 'title' => 'No Payment Infor...', 'payment_action' => 'authorize_captur...', 'allowspecific' => 0, 'sort_order' => 1, 'group' => 'offline'), 'substitution' => array('active' => 0, 'model' => 'Magento\Payment\...', 'allowspecific' => 0), 'checkmo' => array('active' => 1, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Check / Money or...', 'allowspecific' => 0, 'group' => 'offline'), 'purchaseorder' => array('active' => 0, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Purchase Order', 'allowspecific' => 0, 'group' => 'offline'), 'banktransfer' => array('active' => 0, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Bank Transfer Pa...', 'allowspecific' => 0, 'group' => 'offline'), 'cashondelivery' => array('active' => 0, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Cash On Delivery', 'allowspecific' => 0, 'group' => 'offline'), 'vault' => array('debug' => 1, 'model' => 'Magento\Vault\Mo...'), 'paypal_express' => array('model' => 'Magento\Paypal\M...', 'title' => 'PayPal Express C...', 'payment_action' => 'Authorization', 'solution_type' => 'Mark', 'line_items_enabl...' => 1, 'visible_on_cart' => 1, 'visible_on_produ...' => 1, 'allow_ba_signup' => 'never', 'group' => 'paypal', 'authorization_ho...' => 3, 'order_valid_peri...' => 29, 'child_authorizat...' => 1, 'verify_peer' => 1, 'skip_order_revie...' => 1, 'supported_locale...' => 'ar_EG,cs_CZ,da_D...', 'smart_buttons_su...' => 'en_AD,fr_AD,es_A...', 'client_id' => 'ATDZ9_ECFh-fudes...', 'sandbox_client_i...' => 'AUZfbDQ_4m8ibp82...'), 'paypal_express_b...' => array('model' => 'Magento\Paypal\M...', 'title' => 'PayPal Credit (P...', 'group' => 'paypal'), 'payflow_express' => array('title' => 'PayPal Express C...', 'payment_action' => 'Authorization', 'line_items_enabl...' => 1, 'visible_on_cart' => 1, 'visible_on_produ...' => 1, 'group' => 'paypal', 'verify_peer' => 1, 'model' => 'Magento\Paypal\M...'), 'payflow_express_...' => array('model' => 'Magento\Paypal\M...', 'title' => 'PayPal Credit (P...', 'group' => 'paypal'), 'payflowpro' => array('model' => 'Magento\Paypal\M...', 'title' => 'Credit Card (Pay...', 'payment_action' => 'Authorization', 'cctypes' => 'AE,VI', 'useccv' => 1, 'tender' => 'C', 'verbosity' => 'HIGH', 'user' => NULL, 'pwd' => NULL, 'group' => 'paypal', 'verify_peer' => 1, 'date_delim' => NULL, 'ccfields' => 'csc,expdate,acct', 'place_order_url' => 'paypal/transpare...', 'cgi_url_test_mod...' => 'https://pilot-pa...', 'cgi_url' => 'https://payflowl...', 'transaction_url_...' => 'https://pilot-pa...', 'transaction_url' => 'https://payflowp...', 'fmf' => 0, 'avs_street' => 0, 'avs_zip' => 0, 'avs_internationa...' => 0, 'avs_security_cod...' => 1, 'cc_year_length' => 2, 'can_authorize_va...' => 1, 'can_capture_vaul...' => 1, 'avs_ems_adapter' => 'Magento\Paypal\M...', 'cvv_ems_adapter' => 'Magento\Paypal\M...'), 'payflowpro_cc_va...' => array('model' => 'PayflowProCredit...', 'title' => 'Stored Cards (Pa...', 'instant_purchase' => array('tokenFormat' => '\Magento\Paypal\...'), 'group' => 'paypal'), 'paypal_billing_a...' => array('active' => 1, 'allow_billing_ag...' => 1, 'model' => 'Magento\Paypal\M...', 'title' => 'PayPal Billing A...', 'group' => 'paypal', 'verify_peer' => 1), 'payflow_link' => array('model' => 'Magento\Paypal\M...', 'payment_action' => 'Authorization', 'verbosity' => 'HIGH', 'user' => NULL, 'pwd' => NULL, 'group' => 'paypal', 'title' => 'Credit Card (Pay...', 'partner' => 'PayPal', 'csc_required' => 1, 'csc_editable' => 1, 'url_method' => 'GET', 'email_confirmati...' => 0, 'verify_peer' => 1, 'transaction_url_...' => 'https://pilot-pa...', 'transaction_url' => 'https://payflowp...', 'cgi_url_test_mod...' => 'https://pilot-pa...', 'cgi_url' => 'https://payflowl...'), 'payflow_advanced' => array('model' => 'Magento\Paypal\M...', 'payment_action' => 'Authorization', 'verbosity' => 'HIGH', 'user' => NULL, 'pwd' => NULL, 'group' => 'paypal', 'title' => 'Credit Card (Pay...', 'partner' => 'PayPal', 'vendor' => 'PayPal', 'csc_required' => 1, 'csc_editable' => 1, 'url_method' => 'GET', 'email_confirmati...' => 0, 'verify_peer' => 1, 'transaction_url_...' => 'https://pilot-pa...', 'transaction_url' => 'https://payflowp...', 'cgi_url_test_mod...' => 'https://pilot-pa...', 'cgi_url' => 'https://payflowl...'), 'hosted_pro' => array('model' => 'Magento\Paypal\M...', 'title' => 'Payment by cards...', 'payment_action' => 'Authorization', 'group' => 'paypal', 'display_ec' => 0, 'verify_peer' => 1), 'paypal_paylater' => array('experience_activ...' => 0, 'enabled' => 0, 'productpage_disp...' => 0, 'productpage_posi...' => 'header', 'productpage_styl...' => 'text', 'productpage_logo...' => 'primary', 'productpage_logo...' => 'left', 'productpage_text...' => 'black', 'productpage_text...' => 12, 'productpage_rati...' => '1x1', 'productpage_colo...' => 'blue', 'categorypage_dis...' => 0, 'categorypage_pos...' => 'header', 'categorypage_sty...' => 'flex', 'categorypage_col...' => 'blue', 'categorypage_rat...' => '20x1', 'categorypage_log...' => 'primary', 'categorypage_log...' => 'left', 'categorypage_tex...' => 'black', 'categorypage_tex...' => 12, 'homepage_display' => 0, 'homepage_positio...' => 'header', 'homepage_stylela...' => 'flex', 'homepage_ratio' => '1x1', 'homepage_color' => 'blue', 'homepage_logotyp...' => 'primary', 'homepage_logopos...' => 'left', 'homepage_textcol...' => 'black', 'homepage_textsiz...' => 12, 'checkout_payment...' => 0, 'checkout_payment...' => 'header', 'checkout_payment...' => 'text', 'checkout_payment...' => 'primary', 'checkout_payment...' => 'left', 'checkout_payment...' => 'black', 'checkout_payment...' => 12, 'checkout_payment...' => '1x1', 'checkout_payment...' => 'blue', 'cartpage_display' => 0, 'cartpage_positio...' => 'header', 'cartpage_stylela...' => 'text', 'cartpage_logotyp...' => 'primary', 'cartpage_logopos...' => 'left', 'cartpage_textcol...' => 'black', 'cartpage_textsiz...' => 12, 'cartpage_ratio' => '1x1', 'cartpage_color' => 'blue'), 'amazon_payment' => array('amazon_login_in_...' => 1, 'active' => 0, 'is_gateway' => 1, 'title' => 'Amazon Pay', 'sort_order' => 1, 'model' => 'AmazonFacade', 'order_status' => 'processing', 'payment_action' => 'authorize', 'can_authorize' => 1, 'can_capture' => 1, 'can_capture_part...' => 1, 'can_void' => 1, 'can_cancel' => 1, 'can_refund_parti...' => 1, 'can_refund' => 1, 'can_use_checkout' => 1, 'packstation_term...' => 'Packstation,Pack...', 'lwa_enabled' => 0, 'authorization_mo...' => 'synchronous', 'update_mechanism' => 'polling', 'pwa_pp_button_is...' => 1, 'minicart_button_...' => 1, 'button_type' => 'full', 'button_color' => 'Gold', 'button_size' => 'medium', 'logging' => 1, 'platform_id' => 'AUGT0HMCLQVX1', 'hard_decline_cod...' => 4273, 'soft_decline_cod...' => 7638, 'sca_regions' => 'de,uk'), 'amazonlogin' => array('active' => 0, 'model' => 'Amazon\Payment\M...', 'order_status' => 'pending', 'title' => 'Amazon Pay', 'allowspecific' => 0), 'klarna_kp' => array('model' => 'Klarna\Kp\Model\...', 'payment_action' => 'authorize', 'title' => 'Klarna Payments', 'group' => 'klarna', 'active' => 0, 'data_sharing' => 1, 'data_sharing_onl...' => 1, 'allowspecific' => 0, 'order_status' => 'processing', 'can_order' => 0, 'can_authorize' => 1, 'can_capture' => 1, 'can_fetch_transa...' => 1, 'can_capture_part...' => 1, 'can_capture_once' => 0, 'can_refund' => 1, 'can_refund_parti...' => 1, 'can_void' => 1, 'can_cancel' => 1, 'can_use_internal' => 0, 'can_use_checkout' => 1, 'can_edit' => 0, 'is_gateway' => 0, 'is_offline' => 0, 'can_initialize' => 0, 'can_review_payme...' => 0, 'can_use_for_mult...' => 0), 'msp_cashondelive...' => array('model' => 'MSP\CashOnDelive...', 'title' => 'Cash on delivery', 'order_status' => 'pending', 'active' => 0, 'allowspecific' => 0, 'sort_order' => 100, 'group' => 'offline', 'used_totals' => 'subtotal,tax,shi...', 'tax' => 0), 'alphabank_gatewa...' => array('model' => 'AlphaBankPayment...', 'active' => 0, 'is_gateway' => 1, 'active_cc' => 1, 'title' => 'Credit Card (usi...', 'description' => 'Pay using credit...', 'payment_action' => 'initialize', 'logo' => NULL, 'can_initialize' => 1, 'can_use_checkout' => 1, 'can_authorize' => 0, 'can_capture' => 0, 'can_capture_part...' => 0, 'can_authorize_va...' => 0, 'can_capture_vaul...' => 1, 'can_use_internal' => 0, 'can_refund_parti...' => 0, 'can_refund' => 0, 'can_void' => 0, 'can_cancel' => 0, 'can_edit' => 0, 'can_review_payme...' => 1, 'can_deny_payment' => 1, 'sort_order' => 1), 'alphabank_gatewa...' => array('model' => 'AlphaBankPayment...', 'active' => 0, 'is_gateway' => 1, 'title' => 'MasterPass (usin...', 'description' => 'Pay using Master...', 'payment_action' => 'initialize', 'logo' => NULL, 'can_initialize' => 1, 'can_use_checkout' => 1, 'can_authorize' => 0, 'can_capture' => 0, 'can_capture_part...' => 0, 'can_authorize_va...' => 0, 'can_capture_vaul...' => 1, 'can_use_internal' => 0, 'can_refund_parti...' => 0, 'can_refund' => 0, 'can_void' => 0, 'can_cancel' => 0, 'can_edit' => 0, 'can_review_payme...' => 1, 'can_deny_payment' => 1, 'sort_order' => 2))) called at [vendor/magento/framework/Interception/Interceptor.php:146]
#5 Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#6 Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#->___callPlugins('getPaymentMethod...', array(), array(array('klarnaKpPaymentD...'))) called at [generated/code/Magento/Payment/Helper/Data/Interceptor.php:68]
#7 Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#->getPaymentMethods() called at [vendor/magento/module-payment/Model/PaymentMethodList.php:43]
#8 Magento\Payment\Model\PaymentMethodList#0000000070df9fdc000000005cfc2623#->getList(1) called at [vendor/magento/module-payment/Model/PaymentMethodList.php:88]
#9 Magento\Payment\Model\PaymentMethodList#0000000070df9fdc000000005cfc2623#->getActiveList(1) called at [vendor/magento/module-payment/Model/MethodList.php:73]
#10 Magento\Payment\Model\MethodList\Interceptor[Magento\Payment\Model\MethodList]#0000000070df96a9000000005cfc2623#->getAvailableMethods(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [generated/code/Magento/Payment/Model/MethodList/Interceptor.php:23]
#11 Magento\Payment\Model\MethodList\Interceptor#0000000070df96a9000000005cfc2623#->getAvailableMethods(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/module-quote/Model/PaymentMethodManagement.php:111]
#12 Magento\Quote\Model\PaymentMethodManagement\Interceptor[Magento\Quote\Model\PaymentMethodManagement]#0000000070df9673000000005cfc2623#->getList(12551) called at [generated/code/Magento/Quote/Model/PaymentMethodManagement/Interceptor.php:41]
#13 Magento\Quote\Model\PaymentMethodManagement\Interceptor#0000000070df9673000000005cfc2623#->getList(12551) called at [vendor/it4mage/cashondelivery/Model/Total/Quote/AbstractTotal.php:50]
#14 MSP\CashOnDelivery\Model\Total\Quote\Cashondelivery[MSP\CashOnDelivery\Model\Total\Quote\AbstractTotal]#0000000070df908f000000005cfc2623#->_canApplyTotal(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/it4mage/cashondelivery/Model/Total/Quote/Cashondelivery.php:73]
#15 MSP\CashOnDelivery\Model\Total\Quote\Cashondelivery#0000000070df908f000000005cfc2623#->collect(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#, &Magento\Quote\Model\ShippingAssignment#0000000070df9ff6000000005cfc2623#, &Magento\Quote\Model\Quote\Address\Total#0000000070df9fe7000000005cfc2623#) called at [vendor/magento/module-quote/Model/Quote/TotalsCollector.php:274]
#16 Magento\Quote\Model\Quote\TotalsCollector\Interceptor[Magento\Quote\Model\Quote\TotalsCollector]#0000000070df90b4000000005cfc2623#->collectAddressTotals(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#, &Magento\Quote\Model\Quote\Address\Interceptor#0000000070df9340000000005cfc2623#) called at [generated/code/Magento/Quote/Model/Quote/TotalsCollector/Interceptor.php:41]
#17 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->collectAddressTotals(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#, &Magento\Quote\Model\Quote\Address\Interceptor#0000000070df9340000000005cfc2623#) called at [vendor/magento/module-quote/Model/Quote/TotalsCollector.php:148]
#18 Magento\Quote\Model\Quote\TotalsCollector\Interceptor[Magento\Quote\Model\Quote\TotalsCollector]#0000000070df90b4000000005cfc2623#->collect(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#19 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->___callParent('collect', array(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#20 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->Magento\Framework\Interception\{closure}(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#21 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->___callPlugins('collect', array(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#), array(array('in-store-pickup-...'), array('mSPCashOnDeliver...'))) called at [generated/code/Magento/Quote/Model/Quote/TotalsCollector/Interceptor.php:32]
#22 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->collect(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/module-quote/Model/Quote.php:2015]
#23 Magento\Quote\Model\Quote\Interceptor[Magento\Quote\Model\Quote]#0000000070df909c000000005cfc2623#->collectTotals() called at [generated/code/Magento/Quote/Model/Quote/Interceptor.php:743]
#24 Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#->collectTotals() called at [vendor/magento/module-checkout/Model/Session.php:279]
#25 Magento\Checkout\Model\Session\Interceptor[Magento\Checkout\Model\Session]#0000000070df9297000000005cfc2623#->getQuote() called at [generated/code/Magento/Checkout/Model/Session/Interceptor.php:50]
#26 Magento\Checkout\Model\Session\Interceptor#0000000070df9297000000005cfc2623#->getQuote() called at [vendor/klarna/module-kp/Model/Session.php:150]
#27 Klarna\Kp\Model\Session#0000000070df928a000000005cfc2623#->canSendRequest() called at [vendor/klarna/module-kp/Plugin/Payment/Helper/DataPlugin.php:124]
#28 Klarna\Kp\Plugin\Payment\Helper\DataPlugin#0000000070df92ba000000005cfc2623#->afterGetPaymentMethods(&Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#, array('free' => array('active' => 1, 'model' => 'Magento\Payment\...', 'order_status' => 'pending', 'title' => 'No Payment Infor...', 'payment_action' => 'authorize_captur...', 'allowspecific' => 0, 'sort_order' => 1, 'group' => 'offline'), 'substitution' => array('active' => 0, 'model' => 'Magento\Payment\...', 'allowspecific' => 0), 'checkmo' => array('active' => 1, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Check / Money or...', 'allowspecific' => 0, 'group' => 'offline'), 'purchaseorder' => array('active' => 0, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Purchase Order', 'allowspecific' => 0, 'group' => 'offline'), 'banktransfer' => array('active' => 0, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Bank Transfer Pa...', 'allowspecific' => 0, 'group' => 'offline'), 'cashondelivery' => array('active' => 0, 'model' => 'Magento\OfflineP...', 'order_status' => 'pending', 'title' => 'Cash On Delivery', 'allowspecific' => 0, 'group' => 'offline'), 'vault' => array('debug' => 1, 'model' => 'Magento\Vault\Mo...'), 'paypal_express' => array('model' => 'Magento\Paypal\M...', 'title' => 'PayPal Express C...', 'payment_action' => 'Authorization', 'solution_type' => 'Mark', 'line_items_enabl...' => 1, 'visible_on_cart' => 1, 'visible_on_produ...' => 1, 'allow_ba_signup' => 'never', 'group' => 'paypal', 'authorization_ho...' => 3, 'order_valid_peri...' => 29, 'child_authorizat...' => 1, 'verify_peer' => 1, 'skip_order_revie...' => 1, 'supported_locale...' => 'ar_EG,cs_CZ,da_D...', 'smart_buttons_su...' => 'en_AD,fr_AD,es_A...', 'client_id' => 'ATDZ9_ECFh-fudes...', 'sandbox_client_i...' => 'AUZfbDQ_4m8ibp82...'), 'paypal_express_b...' => array('model' => 'Magento\Paypal\M...', 'title' => 'PayPal Credit (P...', 'group' => 'paypal'), 'payflow_express' => array('title' => 'PayPal Express C...', 'payment_action' => 'Authorization', 'line_items_enabl...' => 1, 'visible_on_cart' => 1, 'visible_on_produ...' => 1, 'group' => 'paypal', 'verify_peer' => 1, 'model' => 'Magento\Paypal\M...'), 'payflow_express_...' => array('model' => 'Magento\Paypal\M...', 'title' => 'PayPal Credit (P...', 'group' => 'paypal'), 'payflowpro' => array('model' => 'Magento\Paypal\M...', 'title' => 'Credit Card (Pay...', 'payment_action' => 'Authorization', 'cctypes' => 'AE,VI', 'useccv' => 1, 'tender' => 'C', 'verbosity' => 'HIGH', 'user' => NULL, 'pwd' => NULL, 'group' => 'paypal', 'verify_peer' => 1, 'date_delim' => NULL, 'ccfields' => 'csc,expdate,acct', 'place_order_url' => 'paypal/transpare...', 'cgi_url_test_mod...' => 'https://pilot-pa...', 'cgi_url' => 'https://payflowl...', 'transaction_url_...' => 'https://pilot-pa...', 'transaction_url' => 'https://payflowp...', 'fmf' => 0, 'avs_street' => 0, 'avs_zip' => 0, 'avs_internationa...' => 0, 'avs_security_cod...' => 1, 'cc_year_length' => 2, 'can_authorize_va...' => 1, 'can_capture_vaul...' => 1, 'avs_ems_adapter' => 'Magento\Paypal\M...', 'cvv_ems_adapter' => 'Magento\Paypal\M...'), 'payflowpro_cc_va...' => array('model' => 'PayflowProCredit...', 'title' => 'Stored Cards (Pa...', 'instant_purchase' => array('tokenFormat' => '\Magento\Paypal\...'), 'group' => 'paypal'), 'paypal_billing_a...' => array('active' => 1, 'allow_billing_ag...' => 1, 'model' => 'Magento\Paypal\M...', 'title' => 'PayPal Billing A...', 'group' => 'paypal', 'verify_peer' => 1), 'payflow_link' => array('model' => 'Magento\Paypal\M...', 'payment_action' => 'Authorization', 'verbosity' => 'HIGH', 'user' => NULL, 'pwd' => NULL, 'group' => 'paypal', 'title' => 'Credit Card (Pay...', 'partner' => 'PayPal', 'csc_required' => 1, 'csc_editable' => 1, 'url_method' => 'GET', 'email_confirmati...' => 0, 'verify_peer' => 1, 'transaction_url_...' => 'https://pilot-pa...', 'transaction_url' => 'https://payflowp...', 'cgi_url_test_mod...' => 'https://pilot-pa...', 'cgi_url' => 'https://payflowl...'), 'payflow_advanced' => array('model' => 'Magento\Paypal\M...', 'payment_action' => 'Authorization', 'verbosity' => 'HIGH', 'user' => NULL, 'pwd' => NULL, 'group' => 'paypal', 'title' => 'Credit Card (Pay...', 'partner' => 'PayPal', 'vendor' => 'PayPal', 'csc_required' => 1, 'csc_editable' => 1, 'url_method' => 'GET', 'email_confirmati...' => 0, 'verify_peer' => 1, 'transaction_url_...' => 'https://pilot-pa...', 'transaction_url' => 'https://payflowp...', 'cgi_url_test_mod...' => 'https://pilot-pa...', 'cgi_url' => 'https://payflowl...'), 'hosted_pro' => array('model' => 'Magento\Paypal\M...', 'title' => 'Payment by cards...', 'payment_action' => 'Authorization', 'group' => 'paypal', 'display_ec' => 0, 'verify_peer' => 1), 'paypal_paylater' => array('experience_activ...' => 0, 'enabled' => 0, 'productpage_disp...' => 0, 'productpage_posi...' => 'header', 'productpage_styl...' => 'text', 'productpage_logo...' => 'primary', 'productpage_logo...' => 'left', 'productpage_text...' => 'black', 'productpage_text...' => 12, 'productpage_rati...' => '1x1', 'productpage_colo...' => 'blue', 'categorypage_dis...' => 0, 'categorypage_pos...' => 'header', 'categorypage_sty...' => 'flex', 'categorypage_col...' => 'blue', 'categorypage_rat...' => '20x1', 'categorypage_log...' => 'primary', 'categorypage_log...' => 'left', 'categorypage_tex...' => 'black', 'categorypage_tex...' => 12, 'homepage_display' => 0, 'homepage_positio...' => 'header', 'homepage_stylela...' => 'flex', 'homepage_ratio' => '1x1', 'homepage_color' => 'blue', 'homepage_logotyp...' => 'primary', 'homepage_logopos...' => 'left', 'homepage_textcol...' => 'black', 'homepage_textsiz...' => 12, 'checkout_payment...' => 0, 'checkout_payment...' => 'header', 'checkout_payment...' => 'text', 'checkout_payment...' => 'primary', 'checkout_payment...' => 'left', 'checkout_payment...' => 'black', 'checkout_payment...' => 12, 'checkout_payment...' => '1x1', 'checkout_payment...' => 'blue', 'cartpage_display' => 0, 'cartpage_positio...' => 'header', 'cartpage_stylela...' => 'text', 'cartpage_logotyp...' => 'primary', 'cartpage_logopos...' => 'left', 'cartpage_textcol...' => 'black', 'cartpage_textsiz...' => 12, 'cartpage_ratio' => '1x1', 'cartpage_color' => 'blue'), 'amazon_payment' => array('amazon_login_in_...' => 1, 'active' => 0, 'is_gateway' => 1, 'title' => 'Amazon Pay', 'sort_order' => 1, 'model' => 'AmazonFacade', 'order_status' => 'processing', 'payment_action' => 'authorize', 'can_authorize' => 1, 'can_capture' => 1, 'can_capture_part...' => 1, 'can_void' => 1, 'can_cancel' => 1, 'can_refund_parti...' => 1, 'can_refund' => 1, 'can_use_checkout' => 1, 'packstation_term...' => 'Packstation,Pack...', 'lwa_enabled' => 0, 'authorization_mo...' => 'synchronous', 'update_mechanism' => 'polling', 'pwa_pp_button_is...' => 1, 'minicart_button_...' => 1, 'button_type' => 'full', 'button_color' => 'Gold', 'button_size' => 'medium', 'logging' => 1, 'platform_id' => 'AUGT0HMCLQVX1', 'hard_decline_cod...' => 4273, 'soft_decline_cod...' => 7638, 'sca_regions' => 'de,uk'), 'amazonlogin' => array('active' => 0, 'model' => 'Amazon\Payment\M...', 'order_status' => 'pending', 'title' => 'Amazon Pay', 'allowspecific' => 0), 'klarna_kp' => array('model' => 'Klarna\Kp\Model\...', 'payment_action' => 'authorize', 'title' => 'Klarna Payments', 'group' => 'klarna', 'active' => 0, 'data_sharing' => 1, 'data_sharing_onl...' => 1, 'allowspecific' => 0, 'order_status' => 'processing', 'can_order' => 0, 'can_authorize' => 1, 'can_capture' => 1, 'can_fetch_transa...' => 1, 'can_capture_part...' => 1, 'can_capture_once' => 0, 'can_refund' => 1, 'can_refund_parti...' => 1, 'can_void' => 1, 'can_cancel' => 1, 'can_use_internal' => 0, 'can_use_checkout' => 1, 'can_edit' => 0, 'is_gateway' => 0, 'is_offline' => 0, 'can_initialize' => 0, 'can_review_payme...' => 0, 'can_use_for_mult...' => 0), 'msp_cashondelive...' => array('model' => 'MSP\CashOnDelive...', 'title' => 'Cash on delivery', 'order_status' => 'pending', 'active' => 0, 'allowspecific' => 0, 'sort_order' => 100, 'group' => 'offline', 'used_totals' => 'subtotal,tax,shi...', 'tax' => 0), 'alphabank_gatewa...' => array('model' => 'AlphaBankPayment...', 'active' => 0, 'is_gateway' => 1, 'active_cc' => 1, 'title' => 'Credit Card (usi...', 'description' => 'Pay using credit...', 'payment_action' => 'initialize', 'logo' => NULL, 'can_initialize' => 1, 'can_use_checkout' => 1, 'can_authorize' => 0, 'can_capture' => 0, 'can_capture_part...' => 0, 'can_authorize_va...' => 0, 'can_capture_vaul...' => 1, 'can_use_internal' => 0, 'can_refund_parti...' => 0, 'can_refund' => 0, 'can_void' => 0, 'can_cancel' => 0, 'can_edit' => 0, 'can_review_payme...' => 1, 'can_deny_payment' => 1, 'sort_order' => 1), 'alphabank_gatewa...' => array('model' => 'AlphaBankPayment...', 'active' => 0, 'is_gateway' => 1, 'title' => 'MasterPass (usin...', 'description' => 'Pay using Master...', 'payment_action' => 'initialize', 'logo' => NULL, 'can_initialize' => 1, 'can_use_checkout' => 1, 'can_authorize' => 0, 'can_capture' => 0, 'can_capture_part...' => 0, 'can_authorize_va...' => 0, 'can_capture_vaul...' => 1, 'can_use_internal' => 0, 'can_refund_parti...' => 0, 'can_refund' => 0, 'can_void' => 0, 'can_cancel' => 0, 'can_edit' => 0, 'can_review_payme...' => 1, 'can_deny_payment' => 1, 'sort_order' => 2))) called at [vendor/magento/framework/Interception/Interceptor.php:146]
#29 Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#30 Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#->___callPlugins('getPaymentMethod...', array(), array(array('klarnaKpPaymentD...'))) called at [generated/code/Magento/Payment/Helper/Data/Interceptor.php:68]
#31 Magento\Payment\Helper\Data\Interceptor#0000000070df96e4000000005cfc2623#->getPaymentMethods() called at [vendor/magento/module-payment/Model/PaymentMethodList.php:43]
#32 Magento\Payment\Model\PaymentMethodList#0000000070df9fdc000000005cfc2623#->getList(1) called at [vendor/magento/module-payment/Model/PaymentMethodList.php:88]
#33 Magento\Payment\Model\PaymentMethodList#0000000070df9fdc000000005cfc2623#->getActiveList(1) called at [vendor/magento/module-payment/Model/MethodList.php:73]
#34 Magento\Payment\Model\MethodList\Interceptor[Magento\Payment\Model\MethodList]#0000000070df96a9000000005cfc2623#->getAvailableMethods(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [generated/code/Magento/Payment/Model/MethodList/Interceptor.php:23]
#35 Magento\Payment\Model\MethodList\Interceptor#0000000070df96a9000000005cfc2623#->getAvailableMethods(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/module-quote/Model/PaymentMethodManagement.php:111]
#36 Magento\Quote\Model\PaymentMethodManagement\Interceptor[Magento\Quote\Model\PaymentMethodManagement]#0000000070df9673000000005cfc2623#->getList(12551) called at [generated/code/Magento/Quote/Model/PaymentMethodManagement/Interceptor.php:41]
#37 Magento\Quote\Model\PaymentMethodManagement\Interceptor#0000000070df9673000000005cfc2623#->getList(12551) called at [vendor/it4mage/cashondelivery/Model/Total/Quote/AbstractTotal.php:50]
#38 MSP\CashOnDelivery\Model\Total\Quote\Cashondelivery[MSP\CashOnDelivery\Model\Total\Quote\AbstractTotal]#0000000070df908f000000005cfc2623#->_canApplyTotal(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/it4mage/cashondelivery/Model/Total/Quote/Cashondelivery.php:73]
#39 MSP\CashOnDelivery\Model\Total\Quote\Cashondelivery#0000000070df908f000000005cfc2623#->collect(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#, &Magento\Quote\Model\ShippingAssignment#0000000070df92a9000000005cfc2623#, &Magento\Quote\Model\Quote\Address\Total#0000000070df92f6000000005cfc2623#) called at [vendor/magento/module-quote/Model/Quote/TotalsCollector.php:274]
#40 Magento\Quote\Model\Quote\TotalsCollector\Interceptor[Magento\Quote\Model\Quote\TotalsCollector]#0000000070df90b4000000005cfc2623#->collectAddressTotals(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#, &Magento\Quote\Model\Quote\Address\Interceptor#0000000070df9340000000005cfc2623#) called at [generated/code/Magento/Quote/Model/Quote/TotalsCollector/Interceptor.php:41]
#41 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->collectAddressTotals(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#, &Magento\Quote\Model\Quote\Address\Interceptor#0000000070df9340000000005cfc2623#) called at [vendor/magento/module-quote/Model/Quote/TotalsCollector.php:148]
#42 Magento\Quote\Model\Quote\TotalsCollector\Interceptor[Magento\Quote\Model\Quote\TotalsCollector]#0000000070df90b4000000005cfc2623#->collect(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#43 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->___callParent('collect', array(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#44 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->Magento\Framework\Interception\{closure}(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#45 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->___callPlugins('collect', array(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#), array(array('in-store-pickup-...'), array('mSPCashOnDeliver...'))) called at [generated/code/Magento/Quote/Model/Quote/TotalsCollector/Interceptor.php:32]
#46 Magento\Quote\Model\Quote\TotalsCollector\Interceptor#0000000070df90b4000000005cfc2623#->collect(&Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#) called at [vendor/magento/module-quote/Model/Quote.php:2015]
#47 Magento\Quote\Model\Quote\Interceptor[Magento\Quote\Model\Quote]#0000000070df909c000000005cfc2623#->collectTotals() called at [generated/code/Magento/Quote/Model/Quote/Interceptor.php:743]
#48 Magento\Quote\Model\Quote\Interceptor#0000000070df909c000000005cfc2623#->collectTotals() called at [vendor/magento/module-quote/Model/Quote/Payment.php:187]
#49 Magento\Quote\Model\Quote\Payment\Interceptor[Magento\Quote\Model\Quote\Payment]#0000000070df964f000000005cfc2623#->importData(&Magento\Framework\DataObject#0000000070df9365000000005cfc2623#) called at [generated/code/Magento/Quote/Model/Quote/Payment/Interceptor.php:41]
#50 Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df964f000000005cfc2623#->importData(array('method' => 'msp_cashondelive...', 'po_number' => NULL, 'additional_data' => NULL, 'checks' => array('checkout', 'country', 'currency', 'total'))) called at [vendor/magento/module-quote/Model/PaymentMethodManagement.php:79]
#51 Magento\Quote\Model\PaymentMethodManagement\Interceptor[Magento\Quote\Model\PaymentMethodManagement]#0000000070df9673000000005cfc2623#->set(12551, &Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df9658000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#52 Magento\Quote\Model\PaymentMethodManagement\Interceptor#0000000070df9673000000005cfc2623#->___callParent('set', array(12551, &Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df9658000000005cfc2623#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#53 Magento\Quote\Model\PaymentMethodManagement\Interceptor#0000000070df9673000000005cfc2623#->Magento\Framework\Interception\{closure}(12551, &Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df9658000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#54 Magento\Quote\Model\PaymentMethodManagement\Interceptor#0000000070df9673000000005cfc2623#->___callPlugins('set', array(12551, &Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df9658000000005cfc2623#), array(array('confirm_order_re...'))) called at [generated/code/Magento/Quote/Model/PaymentMethodManagement/Interceptor.php:23]
#55 Magento\Quote\Model\PaymentMethodManagement\Interceptor#0000000070df9673000000005cfc2623#->set(12551, &Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df9658000000005cfc2623#) called at [vendor/magento/module-quote/Model/GuestCart/GuestPaymentMethodManagement.php:49]
#56 Magento\Quote\Model\GuestCart\GuestPaymentMethodManagement#0000000070df964a000000005cfc2623#->set('1T6rIWlMbNuUcRSA...', &Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df9658000000005cfc2623#)
#57 call_user_func_array(array(&Magento\Quote\Model\GuestCart\GuestPaymentMethodManagement#0000000070df964a000000005cfc2623#, 'set'), array('1T6rIWlMbNuUcRSA...', &Magento\Quote\Model\Quote\Payment\Interceptor#0000000070df9658000000005cfc2623#)) called at [vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php:95]
#58 Magento\Webapi\Controller\Rest\SynchronousRequestProcessor#0000000070df97f1000000005cfc2623#->process(&Magento\Framework\Webapi\Rest\Request\Proxy#0000000070df94ec000000005cfc2623#) called at [vendor/magento/module-webapi/Controller/Rest.php:188]
#59 Magento\Webapi\Controller\Rest\Interceptor[Magento\Webapi\Controller\Rest]#0000000070df974a000000005cfc2623#->dispatch(&Magento\Framework\App\Request\Http#0000000070df9500000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#60 Magento\Webapi\Controller\Rest\Interceptor#0000000070df974a000000005cfc2623#->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#0000000070df9500000000005cfc2623#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#61 Magento\Webapi\Controller\Rest\Interceptor#0000000070df974a000000005cfc2623#->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000070df9500000000005cfc2623#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#62 Magento\Webapi\Controller\Rest\Interceptor#0000000070df974a000000005cfc2623#->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#0000000070df9500000000005cfc2623#), array(array('append_no_store_...'), array('webapiContorller...', 'configHash'))) called at [generated/code/Magento/Webapi/Controller/Rest/Interceptor.php:23]
#63 Magento\Webapi\Controller\Rest\Interceptor#0000000070df974a000000005cfc2623#->dispatch(&Magento\Framework\App\Request\Http#0000000070df9500000000005cfc2623#) called at [vendor/magento/framework/App/Http.php:116]
#64 Magento\Framework\App\Http\Interceptor[Magento\Framework\App\Http]#0000000070df9535000000005cfc2623#->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:23]
#65 Magento\Framework\App\Http\Interceptor#0000000070df9535000000005cfc2623#->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]
#66 Magento\Framework\App\Bootstrap#0000000070df959b000000005cfc2623#->run(&Magento\Framework\App\Http\Interceptor#0000000070df9535000000005cfc2623#) called at [pub/index.php:29]
 [] []
arion-p commented 2 years ago

Having another look at it, it seems the following code in AbstractTotal (line 50):

        $paymentMethodsList = $this->paymentMethodManagement->getList($quote->getId());
        if ((count($paymentMethodsList) == 1) && (current($paymentMethodsList)->getCode() == 'msp_cashondelivery')) {
            return true;
        }

only serves to apply the fee in case Cash-on-delivery is the only available method regardless if it is selected or not. Personally I think this is unnecessary (the payment method should be selected for the fee to apply anyway). Removing these 4 lines fixes the issue.