Class: BaseSendWebhookJob

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

Direct Known Subclasses

SendPaymentWebhookJob, SendRefundWebhookJob

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#callback_urlObject

Returns the value of attribute callback_url.



4
5
6
# File 'app/jobs/base_send_webhook_job.rb', line 4

def callback_url
  @callback_url
end

#govpay_payment_idObject

Returns the value of attribute govpay_payment_id.



4
5
6
# File 'app/jobs/base_send_webhook_job.rb', line 4

def govpay_payment_id
  @govpay_payment_id
end

#signing_secretObject

Returns the value of attribute signing_secret.



4
5
6
# File 'app/jobs/base_send_webhook_job.rb', line 4

def signing_secret
  @signing_secret
end

Instance Method Details

#post_callbackObject



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

def post_callback
  body = webhook_body

  RestClient::Request.execute(
    method: :post,
    url: callback_url,
    headers: { "Pay-Signature": webhook_signature(body, signing_secret) },
    payload: body.to_json
  )
rescue StandardError => e
  Rails.logger.error "[DefraRubyMocks] [BaseSendWebhookJob] error sending  " \
                     "#{webhook_type} webhook to #{callback_url}: #{e}"
end