I have problem with notifications URL in my custom payment gateway. I have Urlnotification class under Block folder where I put

namespace MyPayment\MyGateway\Block;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;

 * Class Urlnotification
 * @package MyPayment\MyGateway\Block

 class Urlnotification extends Field {

      * @param AbstractElement $element
      * @return string
     protected function _getElementHtml(AbstractElement $element) {

          return $this->getBaseUrl() . 'mypayment/mygateway/response';

Under 'Controller' folder I have subfolder 'Response' with 'Index.php' class where I have all logic to handle reciving POST request with data to manipulating transaction / payment.

When I testing it local via Postman everything works fine - I make POST request on URL (http://my.localhost/index.php/mypayment/mygateway/response) with necessary form-data but when I try to test it on remote server I have always 404, no matter what URL I requested for example: http://mysite/index.php/mypayment/mygateway/response or http://mysite/mypayment/mygateway/response

What I'm doing wrong?

EDIT I found out I can recive POST request, only problem is 'session_id' in POST form-data, without it all works fine, but I have to handle param like 'session_id', this is what external API sent, I can't change it

  • Did you clean cache after activate the module? Seems like route is not working at all. – Pradipta Sarkar Jan 6 at 9:09
  • @PradiptaSarkar Yup, I cleaned cache via admin panel, via console, flush them but there is no difference – miguelsantos69 Jan 7 at 8:36
  • @PradiptaSarkar additional info - 404 is only when I make POST with form-data, when I make POST without any data it redirect me on the main site, with GET is this same, redirect to main page – miguelsantos69 Jan 7 at 10:02
  • Ok, I have noticed another thing - now I can recive POST request but when I pass 'session_id' parameter in form-data it result 404, and it's only with this one parameter which has underscore, I can't modify it to 'sessionId' or similar because it come from external API, how can I go around it? – miguelsantos69 Jan 7 at 11:08
  • First of all, the API response should come as Json not form data. session_id might be a preserve variable and attached with a specific task. So when you sending data to the url as form data it's not working as expected. You may try with json response. – Pradipta Sarkar Jan 8 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.