pondělí 1. srpna 2022

NopCommerce Payment Plugin


Components

One or more errors occurred. (A view component named 'PaymentComGate' could not be found. A view component must be a public non-abstract class, not contain any generic parameters, and either be decorated with 'ViewComponentAttribute' or have a class name ending with the 'ViewComponent' suffix. A view component must not be decorated with 'NonViewComponentAttribute'.)

Nebo

One or more errors occurred. (A view component named 'PaymentBesteron' could not be found. A view component must be a public non-abstract class, not contain any generic parameters, and either be decorated with 'ViewComponentAttribute' or have a class name ending with the 'ViewComponent' suffix. A view component must not be decorated with 'NonViewComponentAttribute'.)


Řešení

 namespace Nop.Plugin.Payments.{NázevSlužby}.Components
{

          [ViewComponent(Name = "Payment{NázevSlužby}")]

 public class Payment{NázevSlužby}ViewComponent : NopViewComponent
    {
        public IViewComponentResult Invoke()
        {
            return View("~/Plugins/Payments.{NázevSlužby}/Views/PaymentInfo.cshtml");
        }
    }

            } 

Souvisí s metodou GetPublicViewComponentName ve třídě {NázevSlužby}PaymentProceser

/// <summary>
/// Gets a name of a view component for displaying plugin in public store ("payment info" checkout step)
/// </summary>
/// <returns>View component name</returns>
public string GetPublicViewComponentName()
{
return "Payment{NázevSlužby}";
}

 

Services

Služby jteré jsou využívány v konstruktorech je potřeba nejprce zaregistrovat tak aby je IOC mohl nalézt. Registrují se ve třídě NopStartup ve složce Infrastructure
Pokud je použijete bez registrace tak Vám pravděpodobně nepůjde plugin ani nainstalovat a instalace skončí chybou ve smyslu že se nepodařilo nalézt vyhovující konstruktor.

Views

Configure.cshtml

Zobrazuje formulář v administraci kterým se nastavují údaje pro komunikaci s platební bránou. Například ID obchodníka

PaymentInfo.cshtml

Zobrazuje informace o tom že po dokončení objednávky budete přesměrování na platební bránu, nebo může obsahuvat formulář pro zadání doplňujících informací pro dokončení platby.

Zdroj:

Žádné komentáře:

Okomentovat