Class: Xendit::Webhook

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

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Webhook

Returns a new instance of Webhook.



5
6
7
8
9
10
11
# File 'lib/xendit/webhook.rb', line 5

def initialize(request)
  if Xendit.callback_verification_token.nil? || Xendit.callback_verification_token == ""
    raise "Please configure your Callback Verification Token" 
  end

  @request = request
end

Instance Method Details

#dataObject



17
18
19
# File 'lib/xendit/webhook.rb', line 17

def data
  verified? ? JSONSerializer.decode(@request.body.read) : {"error" => "The source not verified"}
end

#verified?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/xendit/webhook.rb', line 13

def verified?
  secure_compare(Xendit.callback_verification_token, @request.headers["X-CALLBACK-TOKEN"])
end