Exception: Mercadopago::Webhook::InvalidWebhookSignatureError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/mercadopago/webhook/validator.rb

Overview

Error raised by Validator.validate when a webhook signature cannot be confirmed as originating from MercadoPago. Carries enough context for structured logging without exposing internal details in the HTTP response body.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, request_id: nil, timestamp: nil) ⇒ InvalidWebhookSignatureError

Returns a new instance of InvalidWebhookSignatureError.

Parameters:

  • reason (Symbol)

    one of the SignatureFailureReason constants

  • request_id (String, nil) (defaults to: nil)

    x-request-id value associated with the request

  • timestamp (String, nil) (defaults to: nil)

    ts extracted from the header



57
58
59
60
61
62
# File 'lib/mercadopago/webhook/validator.rb', line 57

def initialize(reason, request_id: nil, timestamp: nil)
  super("Invalid webhook signature: #{reason}")
  @reason = reason
  @request_id = request_id
  @timestamp = timestamp
end

Instance Attribute Details

#reasonSymbol (readonly)

Returns one of the SignatureFailureReason constants.

Returns:



48
49
50
# File 'lib/mercadopago/webhook/validator.rb', line 48

def reason
  @reason
end

#request_idString? (readonly)

Returns x-request-id header value, when available.

Returns:

  • (String, nil)

    x-request-id header value, when available



50
51
52
# File 'lib/mercadopago/webhook/validator.rb', line 50

def request_id
  @request_id
end

#timestampString? (readonly)

Returns ts value extracted from the signature header.

Returns:

  • (String, nil)

    ts value extracted from the signature header



52
53
54
# File 'lib/mercadopago/webhook/validator.rb', line 52

def timestamp
  @timestamp
end