I am trying to integrate a payment gateway with my headless magento 2 website.

So after the payment is processed/failed, the payment website makes a POST request to my API with x-www-form-encoded data, and it throws me the following error:

{"message":"Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded","trace":null}

I've tried using:

   $request_body = file_get_contents('php://input');

    $data = json_decode($request_body,true);

But this doesn't work either.

Normal form works, sending these params as JSON works too, but they are sending the params in x-www-form-encoded format, and we can't change that.

Please help!

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.