Class: QiwiObserver::Webhook
- Inherits:
-
Object
- Object
- QiwiObserver::Webhook
- Defined in:
- lib/qiwi_observer/webhook/webhook.rb
Instance Method Summary collapse
- #call(params) ⇒ Object
-
#initialize(key) ⇒ Webhook
constructor
A new instance of Webhook.
Constructor Details
#initialize(key) ⇒ Webhook
Returns a new instance of Webhook.
3 4 5 6 7 |
# File 'lib/qiwi_observer/webhook/webhook.rb', line 3 def initialize(key) raise ArgumentError, "Secret key must be set" unless key @key = key end |
Instance Method Details
#call(params) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/qiwi_observer/webhook/webhook.rb', line 9 def call(params) return WebhookResponse.new(success: true, body: params) if params.dig(:test) == true return WebhookResponse.new(success: true, body: params) if sign_correct?(params) WebhookResponse.new(success: false, body: params.dig(:payment, :txnId)) end |