Class: PaypalAPI::WebhookVerifier Private

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal-api/webhook_verifier.rb,
lib/paypal-api/webhook_verifier/certs_cache.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Webhook Verifier

Defined Under Namespace

Classes: CertsCache, MissingHeader, NullCache

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WebhookVerifier

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of WebhookVerifier.



18
19
20
# File 'lib/paypal-api/webhook_verifier.rb', line 18

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientClient (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns current client.

Returns:



16
17
18
# File 'lib/paypal-api/webhook_verifier.rb', line 16

def client
  @client
end

Instance Method Details

#call(webhook_id:, headers:, raw_body:) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Verifies Webhook.

It requires one-time request to download and cache certificate. If local verification returns false it tries to verify webhook online.

Parameters:

  • webhook_id (String)

    Webhook ID provided by PayPal when registering webhook for your URL

  • headers (Hash)

    webhook request headers

  • raw_body (String)

    webhook request raw body string

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/paypal-api/webhook_verifier.rb', line 32

def call(webhook_id:, headers:, raw_body:)
  args = {
    webhook_id: webhook_id,
    raw_body: raw_body,
    auth_algo: paypal_auth_algo(headers),
    transmission_sig: paypal_transmission_sig(headers),
    transmission_id: paypal_transmission_id(headers),
    transmission_time: paypal_transmission_time(headers),
    cert_url: paypal_cert_url(headers)
  }

  offline(**args) || online(**args)
end