Question

I am working with an API for a payment gateway that does a callback request. When the callback request is made, the gateway expects me to respond with "OK". Nothing more or less. And that doesn't mean html rendered response. Just a callback file with those 2 letters. Note that doesn't mean it wants HTTP Status Code 200/OK... it wants actual data (not headers) for the word "OK".

So this won't work:

<html><body>OK</body></html>

This will work:

<?php echo "OK"; ?>

however, after I send back OK, I need to do some stuff on the server side and then redirect the browser page to another page. But when I try to do:

<?php
echo "OK";
header('Location: http://www.store.com/success.php');
exit;
?>

The gateway ignores the echo "OK" and instead reads the html off of the success.php page that I redirect to.

So how can I send back just the OK but continue doing things on my side?

Thanks

Was it helpful?

Solution

You can't send content then redirect. The redirect header setting must be done alone.

OTHER TIPS

You could try using flush(); to force php to write out the OK.

Would it be acceptable to move the redirect into client side either with javascript or meta refresh tag?

Before you send the OK you could call PHP via commandline to make PHP acting like multi threated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top