Nopcommerce 无法找到我的付款方式插件的组件
Nopcommerce unable to find my Payment Method plugin's component
我正在为我的客户开发一个定制的支付方式插件。我是 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
视图。我尝试了所有可能的路径格式,但 none 有效。
我检查了其他插件,它们也像我一样定义了组件路径。
.cshtml 文件名中有错别字 "Boooking.cshtml" :) 仔细看。
我正在为我的客户开发一个定制的支付方式插件。我是 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
视图。我尝试了所有可能的路径格式,但 none 有效。
我检查了其他插件,它们也像我一样定义了组件路径。
.cshtml 文件名中有错别字 "Boooking.cshtml" :) 仔细看。