PAYONE-GmbH / shopware-5

PAYONE Payment Plugin for shopware 5
MIT License
10 stars 24 forks source link

Possibility to disable Creditcard Grouping #296

Closed danielDigitalArt closed 5 years ago

danielDigitalArt commented 5 years ago

We are trying to include the Plugin into a customer shop where we have a custom plugin running. This Plugin also uses the Shopware Hook "GetPaymentMeans" to recive the currently available Payments, pretty much like Payone does. In the later Process this list is then Filtered so only some of these Payment Methods are shown to the User.

The Problem is that the Payone Plugin seems to group Payment Methods further down the Process, so the recieved Payment Methods are not up to date anymore when the Custom Plugin tries to sort out other Payment Methods, this leads to a Problem where the Credit-Card Payment Method can not be selected by the Customer anymore, we think that it should work if the payment Methods were not grouped. We already tried to disable the Function from within the Subscriber that is called upon "GetPaymentMeans" but it still was not working, the Payment Methods were still be grouped.

Would it be possible to create a plugin-Config that allows the backend user to disable the Payment-Grouping?

fjbender commented 5 years ago

Without diving in the details: Wouldn't this leave the user with individual payment methods for the brands, e.g. Visa and Mastercard being different methods, although their are perceived by users as being subtypes of the same method "card"?

danielDigitalArt commented 5 years ago

Hi,

yes i think that is what would happen then. The only other option that i could come up with would be to have a new Event to be fired from the Payone Plugin when the grouping of Payment Methods have taken place so other Plugins can Subscribe to this event and get the grouped Payment array to work on.

The thing is, that the shopware-hook does not seem to recognize a priority value as an additional parameter, so we can not place our plugin behind the payone grouping method. So our Plugin receives the payment-methods purely out of shopware, checks if there are currently payment methods that should not be visible for the current user and drops them from the array and returns them later on. I think payone uses a similar approach but because both plugins have their own instance of payment-methods then, the functionality gets broken.

fjbender commented 5 years ago

Firing an event sounds like a viable approach. I suppose it would be somewhere around \Shopware\Plugins\MoptPaymentPayone\Subscribers\Payment::onGetPaymentMeans:

https://github.com/PAYONE-GmbH/shopware-5/blob/b9409aae8d323851538c08a4c844f0b2db8a9385/Frontend/MoptPaymentPayone/Subscribers/Payment.php#L230-L258

We then should hand over the $paymentMeansWithGroupedCreditcard somewhere.

However, as this (for me right now) seems pretty niche, I won't be able to attend to this some time soon. PRs are very welcome though.

danielDigitalArt commented 5 years ago

Ok, i created a PR for this: https://github.com/PAYONE-GmbH/shopware-5/pull/298