nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.31k stars 5.33k forks source link

Suggestions to make Payment plugins more extensible #6080

Closed DamienLaw closed 1 year ago

DamienLaw commented 2 years ago

For this example, I'm going to use the Cheque / Money Order payment plugin but could as well applicable to other plugins.

The payment instructions could be found during Checkout (before the Order is placed). However, at this point, customers won't be writing the details down thinking that they could access the info sometime later after the order is placed. image

At the Order Details page (after the Order is placed), there's no way the customers could access the payment instructions anymore. I know I could add a FAQ page or info page with the payment instructions but that would not be intuitive anymore and customers won't even think to look for pages like that in the first place. image

It would be better if the plugin could include a ViewComponent on the Order Details page. This way the plugin has more control over what to display. It could even include javascript files or css stylesheets in the View of the ViewComponent. image Note: Although in the screenshot above, PartialView is mentioned, but a ViewComponent is more suitable and inline with how nopCommerce works.

Let's take another example, the PayPal Standard payment plugin. image

The code to display the "Retry Payment" button is controlled by Nop.Web instead of by the plugin. https://github.com/nopSolutions/nopCommerce/blob/e19fe8c85c7ca2b7f44b989ce1792fe1a517fc7f/src/Presentation/Nop.Web/Views/Order/Details.cshtml#L203-L214

Here, Nop.Web is only displaying one button which probably good enough for PayPal. It is presumtuous to assume that this also applies to every other payment gateways out there. Other banks could require some actions to be taken first before being redirected to their payment authorisation page thus might require several additional buttons to be displayed. Or to have a hyperlink when clicked would display the "Terms & Conditions" of using the bank's service.

The correct way would be as mentioned, give more control to the payment plugin to include a ViewComponent to display whatever that the plugin deem necessary instead of having Nop.Web catering for every single possible scenario.

Currently, in IPaymentMethod interface which is implemented by Payment plugins, there's a method called GetPublicViewComponentName() which is used to display the ViewComponent of the payment instructions/info as shown in the first screenshot. https://github.com/nopSolutions/nopCommerce/blob/12dd4825dfb56bbc64e192cd35d25e3205427646/src/Libraries/Nop.Services/Payments/IPaymentMethod.cs#L133-L137

We could extend this and introduce two more methods: GetOrderDetailsViewComponentName() which is the ViewComponent on the Order Details page explained above, and GetCheckoutCompletedViewComponentName() which is the ViewComponent to be displayed after checkout is completed.

GetCheckoutCompletedViewComponentName() is useful for manual/offline Payment plugins to attach a reminder to customer after the checkout process is completed. image

skoshelev commented 2 years ago

See also https://github.com/nopSolutions/nopCommerce/issues/6085

RomanovM commented 1 year ago

After some consideration we've decided not to implement this functionality.