Following some examples online, I am to return a 200 response for a correctly signed payload, and a 401 response for an incorrectly signed, or malformed payload.
The following minimal example has been tested.
The signature is being generated correctly, and the checkHash()
function identifies the correctly signed/formed payloads.
The feedback I am getting from the endpoint is Response contained a body. The advice given here is to strip everything from the body of the response -but as far as I can see all I am return is the literal response as an echo i.e. 200 or 401.
$key = 'abcSomeKey';
$rawPayload = file_get_contents("php://input");
checkHash();
function getSignature() {
return base64_encode(hash_hmac('sha256', $rawPayload, $key, true));
}
function checkHash() {
$signature = getSignature();
if($signature === $_SERVER['HTTP_X_XERO_SIGNATURE']) {
echo 200;
}
else {
echo 401;
}
}