Class: Xendit::Webhook
- Inherits:
-
Object
- Object
- Xendit::Webhook
- Defined in:
- lib/xendit/webhook.rb
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(request) ⇒ Webhook
constructor
A new instance of Webhook.
- #verified? ⇒ Boolean
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
#data ⇒ Object
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
13 14 15 |
# File 'lib/xendit/webhook.rb', line 13 def verified? secure_compare(Xendit.callback_verification_token, @request.headers["X-CALLBACK-TOKEN"]) end |