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
31 32 33 34 |
# File 'app/models/stripe_webhooks/event.rb', line 31 def run_callbacks! StripeWebhooks::Callback.run_callbacks_for(self.stripe_event_type, self.stripe_event) return true end |
#stripe_event ⇒ Object
6 7 8 9 10 11 12 |
# 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 ||= Stripe::Event.retrieve(stripe_event_id) return @_stripe_event end |
#validate! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/stripe_webhooks/event.rb', line 14 def validate! return true if is_authentic begin event = stripe_event() update_attributes({ :is_processed => true, :is_authentic => true, :stripe_event_type => event.type, :stripe_created_at => Time.at(event.created).to_datetime }) return true rescue Stripe::InvalidRequestError update_attributes(:is_processed => true, :is_authentic => false) return false end end |