Class: Solidgate::Webhook

Inherits:
Object
  • Object
show all
Defined in:
lib/solidgate/webhook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = nil) ⇒ Webhook

Returns a new instance of Webhook.



6
7
8
# File 'lib/solidgate/webhook.rb', line 6

def initialize(client = nil)
  @client = client || Solidgate.client
end

Instance Attribute Details

#clientObject (readonly)

Webhook resource for handling webhook-related operations



4
5
6
# File 'lib/solidgate/webhook.rb', line 4

def client
  @client
end

Instance Method Details

#validate_signature(payload, signature) ⇒ Boolean

Validate webhook signature

Parameters:

  • payload (String)

    webhook payload

  • signature (String)

    webhook signature

Returns:

  • (Boolean)

    whether the signature is valid



14
15
16
17
18
# File 'lib/solidgate/webhook.rb', line 14

def validate_signature(payload, signature)
  client.generate_signature(payload,
                             public_key: Solidgate.configuration.webhook_public_key,
                             private_key: Solidgate.configuration.webhook_private_key) == signature
end