Magento2: Payment methods source model is broken again

Created on 29 Mar 2019  Â·  10Comments  Â·  Source: magento/magento2

Preconditions

  1. Magento 2.3.1

Steps to reproduce

  1. Go to _Marketing → Cart Price Rules_.
  2. Edit/Open a rule.
  3. Under _Conditions_, add the _Cart Attribute_ condition _Payment Method_.
  4. Wait for the possible options to load.

Expected result

  1. I see a list of either all or at least the activated payment methods.

Actual result

  1. I see a list with only the payment methods active per config defaults (i.e. checkmo, free and paypal_billing_agreement, plus some payment group names).

payment_method_cart_attribute_options

Additional Information

The bug was introduced in 28c86be by testing the active flag of payment methods in \Magento\Payment\Helper\Data::getPaymentMethodList (where \Magento\Payment\Model\Config\Source\Allmethods::toOptionArray forwards to).

https://github.com/magento/magento2/blob/28c86bed310311247604caa6c5c3b6c165fbd4f3/app/code/Magento/Payment/Helper/Data.php#L264-L271

Because the source of the data is the default payment method configuration of a plain vanilla installation, no config setting changes (=activating additional methods) are taken into account.

This issue does not only affect the cart price rules. Every extension developer building upon this source model is affected:

Source model in Magento 2.3.1

payment_methods_231

Source model in Magento 2.3.0

payment_methods_230

Payment Fixed in 2.3.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.2.x Reproduced on 2.3.x good first issue

Most helpful comment

Hi @ihor-sviziev. Thank you for clarification. The issue was tested and we can confirm that this issue not present in 2.3-develop. I closing as not actual anymore.

All 10 comments

Hi @mam08ixo. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@mam08ixo do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [x] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [x] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [x] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [x] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [x] 6. Add label Issue: Confirmed once verification is complete.

  • [x] 7. Make sure that automatic system confirms that report has been added to the backlog.

:white_check_mark: Confirmed by @engcom-backlog-nazar
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-98998, MAGETWO-98999 were created

Issue Available: @engcom-backlog-nazar, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

Hi @Nazar65. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [x] 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [x] 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

Hi,

Looks like this issue was fixed in 2.3-develop branch using following commits:

Related comments:
https://github.com/magento/magento2/issues/22231#issuecomment-503750491
https://github.com/magento/magento2/issues/22231#issuecomment-504000986

@engcom-backlog-nazar could you re-check if this issue is reproducing?

Also we're not accepting PRs to 2.2 release line, so we don't need to wait till this issue will be fixed there.

Thank you!

Hi @ihor-sviziev. Thank you for clarification. The issue was tested and we can confirm that this issue not present in 2.3-develop. I closing as not actual anymore.

Hi,
the same issue is present in 2.2.9. You can temporary fix it be setting the payment method config.xml active flag to 1.

F.E. for banktransfer

<banktransfer>
  <active>1</active>
   ...

Hi,
the same issue is present in 2.2.9. You can temporary fix it be setting the payment method config.xml active flag to 1.

F.E. for banktransfer

<banktransfer>
  <active>1</active>
   ...
  1. Path to folder is (composer installation):
    vendor/magento/module-offline-payments/etc/config.xml
  2. Make changes 0 to 1 to activate payment method ex.
    <banktransfer> <active>1</active> ...

Then launch command to apply changes:

bin/magento setup:di:compile
bin/magento setup:upgrade

Done.

Why is changing in xml a valid fix but in core_config_data the active flag is set? This is still reproducible on vanilla 2.3.2 with any payment method that does not have active = 1 in xml. If the config is enabled in the database then source does not consider it.

Seems the real reason this does not work correctly is the payment method instance is coming from a factory create object, which considers xml, but does not check the database to see if the method is enabled. Something needs to be added during the factory object creation which gets config from the database core_config_data payment//active, or other config values as well if those affect anything.

Was this page helpful?
0 / 5 - 0 ratings