0

I am developing a custom plugin - payment gateway - which returns me data through POST request. The payment gateway is expecting this response:

HTTP/1.1 200 OK
Content-Type: application/x-www-form-urlencoded; charset=utf-8

code=0&message=OK

So, in early stages of development, I decided to try if I am able to communicate at all:

add_action('init','say_ok_to_everything');

function say_ok_to_everything(){
   //I want to say OK only when getting request from the payment gateway
   if( isset( $_REQUEST['listener'] ) &&  $_REQUEST['listener']  == 'my-listener' ) {
      echo 'code=0&message=OK';
       //not sure if I should end script here
      //die();
    }
}

If I look to my access log, I see this:

"POST /?listener=my-listener HTTP/1.1" 404 16843 "-" "Zend_Http_Client"

If I directly access my site through URL https://mysite.cz/?listener=my-listener I see this in the log:

131.207.242.5 - - [29/Jul/2019:09:50:43 +0000] "GET /?listener=my-listener HTTP/1.1" 200 8698 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"

So, in other words, on POST, the site returns HTTP error 404, on GET it returns HTTP 200 OK. How do I convince the site to return 200 on both?

BTW, from the logs on payment gateway, I can see, that the code=0&message=OK was returned in both ways

Thanks a lot

  • Solved, but not sure why. When I un-commented the die() command in function say_ok_to_everything everything started working. Still clueless on why. So if someone cares to explain, I am going to be so grateful... – Pavel Janicek Jul 29 at 10:46

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.