Class: Wbase::StripeWebhook
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Wbase::StripeWebhook
- Defined in:
- app/models/wbase/stripe_webhook.rb
Instance Method Summary collapse
Instance Method Details
#customer_stripe_id ⇒ Object
37 38 39 |
# File 'app/models/wbase/stripe_webhook.rb', line 37 def customer_stripe_id get("customer") end |
#get(key) ⇒ Object
45 46 47 |
# File 'app/models/wbase/stripe_webhook.rb', line 45 def get(key) data.fetch("object", {}).fetch(key) end |
#paid_thru ⇒ Object
41 42 43 |
# File 'app/models/wbase/stripe_webhook.rb', line 41 def paid_thru data.fetch("object", {}).fetch("current_period_end") end |
#process! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/wbase/stripe_webhook.rb', line 23 def process! self.update(state: 1) begin if external_type == 'customer.subscription.updated' subscription = Subscription.find_by(stripe_id: customer_stripe_id) subscription.update(paid_thru: Time.at(paid_thru)) end self.update(state: 2) rescue => e self.update(state: 3, error_text: e) end end |