public bool Validate(AdyenNotification.NotificationRequestItem body)
        {
            object hmacSignature = null;

            if (!body.AdditionalData?.TryGetValue("hmacSignature", out hmacSignature) == true)
            {
                return(false);
            }

            var signature    = (string)hmacSignature;
            var payload      = ConcatenatePayload(body);
            var payloadBytes = Encoding.UTF8.GetBytes(payload);
            var hash         = HmacHash(_currentKeyBytes, payloadBytes);

            if (hash == signature)
            {
                // new key working, clear cache
                _oldKeyCache = null;
                return(true);
            }

            if (_oldKeyCache == null)
            {
                return(false);
            }

            return(HmacHash(ConvertFromHex(_oldKeyCache), payloadBytes) == signature);
        }
 private static string ConcatenatePayload(AdyenNotification.NotificationRequestItem body)
 {
     return
         ($"{body.PspReference}:{body.OriginalReference}:{body.MerchantAccountCode}:{body.MerchantReference}:{body.Amount.Value}:{body.Amount.Currency}:{body.EventCode}:{body.Success.ToString().ToLower()}");
 }