【问题标题】:Nopcommerce unable to find my Payment Method plugin's componentNopcommerce 找不到我的付款方式插件的组件
【发布时间】:2019-09-09 19:38:16
【问题描述】:

我正在为我的客户开发一个定制的付款方式插件。我是 Nopcommerce 插件开发的初学者,这是我的插件目录结构:

代码

这是我的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代码:

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

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

CODBookingViewComponent.cs代码:

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

CODBooking.cshtml代码:

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

问题

问题是系统找不到CODBooking.cshtml 视图。我尝试了所有可能的路径格式,但都没有奏效。

我检查了其他插件,他们也像我一样定义了组件路径。

【问题讨论】:

  • 您的 .cshtml 文件名中有错字。你有预订而不是预订:)
  • @jon omg..my idiocy..非常感谢 :D 请将其添加为答案以将其标记为已回答,并帮助错过错字的未来开发人员。
  • 哈,没问题。有时需要另一双眼睛才能看到不那么明显
  • @jon haha​​..so true :)

标签: c# asp.net .net asp.net-mvc nopcommerce


【解决方案1】:

.cshtml 文件名“Boooking.cshtml”中有错字:) 仔细看。

【讨论】:

    猜你喜欢
    • 2015-11-14
    • 2013-05-18
    • 2019-11-20
    • 2019-09-11
    • 1970-01-01
    • 2021-10-30
    • 2014-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多