PAYONE-GmbH / magento-2

PAYONE Payment Extension for Magento 2
28 stars 56 forks source link

Klarna payment method still appears even if the delivery country is not valid #451

Closed gfemorris closed 2 years ago

gfemorris commented 2 years ago

Klarna Payment methods are displayed in an extra block in the checkout after the user selects Klarna as payment method. If the delivery address is not under the configured valid ones the payment selection for Klarna in the main payment selection still appears. In the extra Klarna block there is nothing to choose from which is correct but it's confusing for the user that it's even an option in the first place.

janteuber commented 2 years ago

Hello @gfemorris ,

Thank you very much for your advice.

Technically, we send all the customer's information to Klarna and then only load the widget from Klarna.

We want to interfere as little as possible with the logic of Klarna and therefore only show the widget.

We currently do not plan to develop a separate logic for the Klarna widget.

gfemorris commented 2 years ago

I was referring to a magento logic to limit the countries in which the payment method is allowed. This does not work as intended with the Payone Klarna solution because it is only checked in the Klarna widget and not in the main Klarna selection. This is confusing for the users to see a payment option which was not available in the first place.

gfemorris commented 2 years ago

@janteuber could you please respond if you still do not plan to fix this issue? As i explaned it has nothing to do with klarna as it is magento logic to limit the countries in which you offer the payment method.

janteuber commented 2 years ago

Hello @gfemorris , I have created a ticket and am currently having this reviewed internally by our agency. As soon as there are news I will share them.

FatchipRobert commented 2 years ago

Hello @gfemorris,

unfortunately I haven't been able to reproduce this behaviour until now. I could imagine that there might be a way that Klarna behaves a little strange, because it is the only payment method in the module that kind of works as a pseudo payment method - triggering one of the 3 Klarna subtype payment methods.

I tried the Global config option "Payment from Applicable Countries" with the value "Specific Countries" and then selected a country there. When entering a delivery country from a different country my payment method list shows no Payone methods at all, including no Klarna.

Then I tried to set every Klarna subtype to "Use Global Settings" = "No" and configure all of them individually to only allow a specific country. This worked as expected too though -> No Klarna method shown.

Then I configured the 3 Klarna subtypes to different allowed order totals ("Minimum Order Total" and "Maximum Order Total"). I put them to 0-100, 0-200 and 0-300. When testing that it correctly showed me all 3 subtypes below 100€, only 2 above 100€ but below 200€ and only one subtype above 200€ and below 300€. Above 300€ no Klarna payment was selectable in the payment list.

There is a mechanism that checks if at least 1 Klarna subtype is applicable and then allows Klarna to be shown, respectively it removes the Klarna payment method from the list when no Klarna subtype is applicable: https://github.com/PAYONE-GmbH/magento-2/blob/master/Model/Plugins/MethodList.php#L329 This mechanism worked correctly all the time when I was testing these configs.

Could you please elaborate which config option disqualifies the Klarna subtypes in your case and maybe post a screenshot of how it looks in the frontend in that case? That might be helpful.

gfemorris commented 2 years ago

Hi @FatchipRobert i tested again with a vanilla magento and i can reproduce this issue there as well. It seems it happens if you switch the address in the checkout. So if you have a default address of an allowed country it will still appear even if you switch the shipping and billing address to a non allowed country in the checkout. And vice versa if you have default a non allowed country and switch to an allowed one it will not appear.

FatchipRobert commented 2 years ago

I think I found a solution for this.

The problem is, that the options "Payment from Applicable Countries" with the value "Specific Countries" determine which payment methods can be shown based on the BILLING address.

But since the billing address can only be selected inside of the payment list, this is pretty inconvenient for the mechanism.

When the default address is from an allowed country and you change the shipping country to a not allowed country address, then the billing address is still set to the default address from the allowed country.

By default, Magento 2 does not update the payment method list when the billing address is changed. This can only be enforced by certain config options in a vanilla magento.

I added a mechanism that always updates the payment method list for Payone methods.

So when the billing address is changed to a not allowed country the Klarna methods should be removed or vice versa when changing the billing address to an allowed country it should be added to the payment method list.

janteuber commented 2 years ago

Hello @gfemorris ,

We have just bookmarked the PR: https://github.com/PAYONE-GmbH/magento-2/pull/467