Class: Billy::Plan
- Inherits:
- 
      ApplicationRecord
      
        - Object
- ActiveRecord::Base
- ApplicationRecord
- Billy::Plan
 
- Defined in:
- app/models/billy/plan.rb
Instance Method Summary collapse
- 
  
    
      #find_interval_plan  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Find a plan with the same name in the opposite interval This is useful when letting users upgrade to the yearly plan. 
- #lemon_squeezy? ⇒ Boolean
- 
  
    
      #lemon_squeezy_url(owner:)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Generate a Lemon Squeezy URL with the passthrough details. 
- #monthly_version ⇒ Object
- #paddle? ⇒ Boolean
- #yearly_version ⇒ Object
Instance Method Details
#find_interval_plan ⇒ Object
Find a plan with the same name in the opposite interval This is useful when letting users upgrade to the yearly plan
| 42 43 44 45 46 47 48 | # File 'app/models/billy/plan.rb', line 42 def find_interval_plan if interval == :month yearly.where(name: name).first else monthly.where(name: name).first end end | 
#lemon_squeezy? ⇒ Boolean
| 22 23 24 | # File 'app/models/billy/plan.rb', line 22 def lemon_squeezy? processor == "lemon_squeezy" end | 
#lemon_squeezy_url(owner:) ⇒ Object
Generate a Lemon Squeezy URL with the passthrough details
| 27 28 29 30 31 32 33 34 35 36 37 38 | # File 'app/models/billy/plan.rb', line 27 def lemon_squeezy_url(owner:) return unless lemon_squeezy? url = "https://#{Billy.lemon_squeezy_site}.lemonsqueezy.com/checkout/buy/#{processor_extra}" url += "?embed=1" url += "&media=0" url += "&desc=0" url += "&checkout[email]=#{owner.email}" url += "&checkout[custom][passthrough]=#{owner.billy_account.passthrough}" url end | 
#monthly_version ⇒ Object
| 55 56 57 58 | # File 'app/models/billy/plan.rb', line 55 def monthly_version return self if interval == "month" monthly.where(name: name).first end | 
#paddle? ⇒ Boolean
| 18 19 20 | # File 'app/models/billy/plan.rb', line 18 def paddle? processor == "paddle" end | 
#yearly_version ⇒ Object
| 50 51 52 53 | # File 'app/models/billy/plan.rb', line 50 def yearly_version return self if interval == "year" yearly.where(name: name).first end |