Plugin route not working when using HttpPost attribute

1 个月 前
I have a problem with the callback Action method in the payment plugin in NopCommerce 4.0 (Bank redirect User with post method to call back URL and post some values). when I use [HttpPost] routing not found my action and when to remove that, my action is called but form values are null.
I test some attributes but routing is not found my action yet.
        public ActionResult CallBack(IFormCollection form)
1 个月 前
My route Provider class:

  public class PaymentPluginRoutProvider : IRouteProvider
    public int Priority => -1;

    public void RegisterRoutes(IRouteBuilder routeBuilder)
      routeBuilder.MapRoute("Plugin.Payments.PaymentPlugin.CallBack", "Plugins/PaymentPlugin/CallBack", new { controller = "PaymentPlugin", action = "CallBack" });

Controller and action code:

public class PaymentPluginController : BasePaymentController
        public IActionResult CancelOrder()
                  //some code .....

this form on the bank's site:

<form method="post" name="returnForm" action="">
        <input type="hidden" id="RefId" name="RefId" value="EA877FCE3FCEE510">
        <input type="hidden" id="ResCode" name="ResCode">
        <input type="hidden" id="SaleOrderId" name="SaleOrderId" value="93">

I'm very confused and I think everything should work fine but it does not and I get a page not found error.
1 个月 前
I dont know about recieving the form parameter
In the first instance you should be able to test the controller action first them modify

// My route
            endpointRouteBuilder.MapControllerRoute("Test.PaymentWebhook", "Test/Webhook/{orderId:regex(\\d*)}",
                new { controller = "PaymentTest", action = "TestWebhook" });

// My controller and function
namespace Nop.Plugin.Payments.Test.Controllers
    public class PaymentTestController : BasePaymentController
        public virtual IActionResult TestWebhook(int? orderId, string id)
                // do some stuff

// Test it
1 个月 前
Thank you very much Yidna.
I finally realized this insane problem. The return address from the bank started with HTTP, whereas this address should have started with HTTPS. In this case, the posted information was lost due to the change of address.
I hope this helps others.