обработка HMAC в http уведомлении QIWI

Не могу сгенерировать HMAC, аналогичный приходящему в запросе. Делал все по их инструкции. Затем взял код из их SDK. Не генерируется такой же хеш

Функция генерации:

function normalize_amount($amount) {
    return number_format(round(floatval($amount), 2, PHP_ROUND_HALF_DOWN), 2, '.', '');
}

function get_hash(array $notificationBody, $merchantSecret) {
    $notificationBody = array_replace_recursive(
        [
            'bill' => [
                'billId' => null,
                'amount' => [
                    'value'    => null,
                    'currency' => null,
                ],
                'siteId' => null,
                'status' => ['value' => null],
            ],
        ],
        $notificationBody
    );

    $processedNotificationData = [
        'billId'          => (string) $notificationBody['bill']['billId'],
        'amount.value'    => normalize_amount($notificationBody['bill']['amount']['value']),
        'amount.currency' => (string) $notificationBody['bill']['amount']['currency'],
        'siteId'          => (string) $notificationBody['bill']['siteId'],
        'status'          => (string) $notificationBody['bill']['status']['value'],
    ];
    ksort($processedNotificationData);
    $processedNotificationDataKeys = join('|', $processedNotificationData);
    $hash = hash_hmac('sha256', $processedNotificationDataKeys, $merchantSecret);

    return $hash;

}

Само применение:

$data = json_decode(file_get_contents('php://input'), true);
$headers = getallheaders();
$headers = array_change_key_case($headers, CASE_LOWER);
$hmac_hash = $headers['x-api-signature-sha256'];
$my_hmac_hash = get_hash($data, $secret);

$request = json_decode(file_get_contents('php://input'), true)['bill'];

if(strcmp($hmac_hash, $my_hmac_hash) !== 0) {
    echo '{"error": -1}';
    exit();
}

Выдается {"error": -1}. Уже пробовал менять пары ключей, не помогает


Ответы (0 шт):