Class: BaseSendWebhookJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/base_send_webhook_job.rb

Direct Known Subclasses

SendPaymentWebhookJob, SendRefundWebhookJob

Instance Method Summary collapse

Instance Method Details

#perform(govpay_id:, status:, callback_url:, signing_secret:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/jobs/base_send_webhook_job.rb', line 4

def perform(govpay_id:, status:, callback_url:, signing_secret:)
  body = webhook_body(govpay_id:, status:)
  Rails.logger.warn "MOCKS: sending #{webhook_type} webhook for #{govpay_id}, status \"#{status}\" to #{callback_url}"
  RestClient::Request.execute(
    method: :get,
    url: callback_url,
    body: body,
    headers: { "Pay-Signature": webhook_signature(body, signing_secret) }
  )
rescue StandardError => e
  Rails.logger.error "MOCKS: error sending #{webhook_type} webhook to #{callback_url}: #{e}\n#{e.backtrace}"
end