Class: StripeWebhooks::Event
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- StripeWebhooks::Event
- Defined in:
- app/models/stripe_webhooks/event.rb
Instance Method Summary collapse
Instance Method Details
#run_callbacks! ⇒ Object
28 29 30 31 |
# File 'app/models/stripe_webhooks/event.rb', line 28 def run_callbacks! StripeWebhooks::Callback.run_callbacks_for(stripe_event_type, stripe_event) return true end |
#stripe_event ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/models/stripe_webhooks/event.rb', line 6 def stripe_event if created_at < 30.days.ago Rails.logger.warn('The event you requested was created over 30 days ago, which means it may no longer be available via the Stripe Events API.') end @_stripe_event ||= fetch_event return @_stripe_event end |
#validate! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/stripe_webhooks/event.rb', line 15 def validate! return true if is_authentic event = stripe_event() update_attributes(is_processed: true, is_authentic: true, stripe_event_type: event.type, stripe_created_at: Time.zone.at(event.created).to_datetime) return true rescue Stripe::InvalidRequestError, Stripe::PermissionError update_attributes(is_processed: true, is_authentic: false) return false end |