Allow customisation of payment callback response within payment handler


Well-known member
I'm creating a new payment provider integration, and it requires a certain response to be output when the webhook has been processed. Currently payment_callback.php returns output with this:


I can't extend this, so means I can only respond with the log message, which isn't what I need, and I don't really want to change what the log message is, as I need to return XML and this isn't going to be suitable as the log message. If this was a method in the payment provider, it could return this by default, but allow it to be overridden. Every other aspect can be overridden, but there is an (incorrect) assumption that the payment gateway doesn't need any custom response data. I'm sure some other payment gateways may require specific responses to callbacks, and this seems like a limitation that doesn't need to exist.
Last edited:
Upvote 0


Well-known member
Somewhat hackish but might work for now:

What about overwriting method log() to call the parent method first and afterwards change $state->logMessage to the XML you need to output, maybe even just in the context of being called straight from payment_callback.php?


Well-known member
Good idea, hadn't thought of that - looked into it and almost worked just doing that, if it wasn't for the htmlspecialchars which encoded the XML. So had to get even more hacky and send the response myself too and exit so it didn't continue to the default one:

public function log(CallbackState $state)

    $response = \XF::app()->response();
    $request = \XF::app()->request();


    $code = $response->httpCode() == 200 ? 0 : 1;
    $body = <<<END
<?xml version="1.0" encoding="UTF-8"?>



Thanks for the suggestion, I was going to just create another callback PHP file in the root, this is at least self-contained. It does the job but not ideal.
Last edited: