Class: FiatStripe::Subscription

Inherits:
ApplicationRecord show all
Includes:
Tokenable
Defined in:
app/models/fiat_stripe/subscription.rb

Defined Under Namespace

Classes: CancelStripeSubscriptionJob, CreateStripeSubscriptionJob, UpdateStripeSubscriptionJob

Instance Method Summary collapse

Instance Method Details

#is_stripe_pricing_inaccurate?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
42
# File 'app/models/fiat_stripe/subscription.rb', line 34

def is_stripe_pricing_inaccurate?
  if self.stripe_subscription
    if self.stripe_subscription.items.first.plan.amount != (self.rate * 100)
      true
    else
      false
    end
  end
end

#stripe_planObject



22
23
24
25
26
# File 'app/models/fiat_stripe/subscription.rb', line 22

def stripe_plan
  if self.stripe_subscription
    self.stripe_subscription.items.first.plan.id
  end
end

#stripe_productObject



28
29
30
31
32
# File 'app/models/fiat_stripe/subscription.rb', line 28

def stripe_product
  if self.stripe_subscription
    self.stripe_subscription.items.first.plan.product
  end
end

#stripe_subscriptionObject



14
15
16
17
18
19
20
# File 'app/models/fiat_stripe/subscription.rb', line 14

def stripe_subscription
  if self.stripe_subscription_id?
    Rails.cache.fetch("#{cache_key}/stripe_subscription", expires_in: 30.days) do
      subscription = Stripe::Subscription.retrieve(self.stripe_subscription_id)
    end
  end
end