Top Level Namespace

Defined Under Namespace

Modules: BaseEndpoints Classes: BadRequestError, Base, Bitnob, BitnobBadKeyError, BitnobServerError, Cards, Checkout, Customer, IncompleteParameterError, LNURL, Lightning, NotFoundError, Onchain, PermissionError, StableCoin, Swap, TooManyRequests, UnAuthorizedError, Wallets

Instance Method Summary collapse

Instance Method Details

#webhook_authentication(request) ⇒ Object

  • Authenticates Webhook Requests



7
8
9
10
11
12
13
14
# File 'lib/bitnob/objects/utils.rb', line 7

def webhook_authentication(request)
  webhook_secret = ENV['BITNOB_WEBHOOK_SECRET']
  signature = request.headers['x-bitnob-signature']
  digest = OpenSSL::Digest.new('Digest', 'sha512')

  hash = OpenSSL::HMAC.hexdigest(digest, webhook_secret, request.body)
  signature == hash
end