Aishwarya Shiva
Aishwarya Shiva

Reputation: 3406

Nopcommerce unable to find my Payment Method plugin's component

I am developing a customized Payment Method plugin for my client. I am a beginner in Nopcommerce plugin development and here's my plugin directory structure: enter image description here

Code

Here's my CODBookingPaymentProcessor.cs

public class CODBookingPaymentProcessor : BasePlugin, IPaymentMethod
{
    #region Ctor
    public CODBookingPaymentProcessor()
    {

    }
    #endregion

    #region Methods
    public bool SupportCapture => false;

    public bool SupportPartiallyRefund => false;

    public bool SupportRefund => false;

    public bool SupportVoid => false;

    public RecurringPaymentType RecurringPaymentType => RecurringPaymentType.NotSupported;

    public PaymentMethodType PaymentMethodType => PaymentMethodType.Standard;

    public bool SkipPaymentInfo => false;

    public string PaymentMethodDescription => "Pay booking and extras before order placing.";

    public CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurringPaymentRequest cancelPaymentRequest)
    {
        return new CancelRecurringPaymentResult();
    }

    public bool CanRePostProcessPayment(Order order)
    {
        if (order == null)
            throw new ArgumentNullException(nameof(order));

        //it's not a redirection payment method. So we always return false
        return false;
    }

    public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
    {
        return new CapturePaymentResult { Errors = new[] { "Capture method not supported" } };
    }

    public decimal GetAdditionalHandlingFee(IList<ShoppingCartItem> cart)
    {
        return 0;
    }

    public ProcessPaymentRequest GetPaymentInfo(IFormCollection form)
    {
        return new ProcessPaymentRequest();
    }

    public string GetPublicViewComponentName()
    {
        return "CODBooking";
    }

    public bool HidePaymentMethod(IList<ShoppingCartItem> cart)
    {
        return false;
    }

    public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
    {

    }

    public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
    {
        return new ProcessPaymentResult();
    }

    public ProcessPaymentResult ProcessRecurringPayment(ProcessPaymentRequest processPaymentRequest)
    {
        return new ProcessPaymentResult();
    }

    public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
    {
        return new RefundPaymentResult();
    }

    public IList<string> ValidatePaymentForm(IFormCollection form)
    {
        return null;
    }

    public VoidPaymentResult Void(VoidPaymentRequest voidPaymentRequest)
    {
        return new VoidPaymentResult();
    }
    #endregion
}

PaymentCODBookingController.cs code:

[AuthorizeAdmin]
[Area(AreaNames.Admin)]
public class PaymentCODBookingController : BasePaymentController
{
    private readonly IPermissionService _permissionService;

    public PaymentCODBookingController(IPermissionService permissionService)
    {
        _permissionService = permissionService;
    }
}

CODBookingViewComponent.cs code:

[ViewComponent(Name = "CODBooking")]
public class CODBookingViewComponent : NopViewComponent
{
    public IViewComponentResult Invoke()
    {
        return View("~/Plugins/Payments.CODBookingPaymentProcessor/Views/CODBooking.cshtml");
    }
}

CODBooking.cshtml code:

@{
     Layout = "";
 }
 <p>TESTING...</p>

Issue

The problem is that system is unable to find CODBooking.cshtml view. I tried every possible path format but none worked.

enter image description here

I checked other plugins and they are also defining the component path just like mine.

Upvotes: 1

Views: 197

Answers (1)

Jon
Jon

Reputation: 3255

There is a typo in the .cshtml filename "Boooking.cshtml" :) Look closely.

Upvotes: 2

Related Questions