Class: Pay::Abacatepay::ProcessedWebhook

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/pay/abacatepay/processed_webhook.rb

Class Method Summary collapse

Class Method Details

.process!(event_type:, event_id:) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'app/models/pay/abacatepay/processed_webhook.rb', line 8

def self.process!(event_type:, event_id:)
  transaction(requires_new: true) do
    create!(event_type: event_type, event_id: event_id, processed_at: Time.current)
    yield if block_given?
  end
  nil
rescue ActiveRecord::RecordNotUnique
  :already_processed
end