Sha256: c95ecc66602fa4bcca94e87f23ce34870110c951e8c090ad4044edc19c1f186a
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
module Stripe module Plans include ConfigurationBuilder configuration_for :plan do attr_accessor :name, :amount, :interval, :interval_count, :trial_period_days, :currency, :metadata, :statement_descriptor validates_presence_of :id, :amount, :currency, :name validates_inclusion_of :interval, :in => %w(day week month year), :message => "'%{value}' is not one of 'day', 'week', 'month' or 'year'" validates :statement_descriptor, :length => { :maximum => 22 } def initialize(*args) super(*args) @currency = 'usd' @interval_count = 1 @trial_period_days = 0 end private def create_options if api_version_after_switch_to_products_in_plans default_create_options else create_options_without_products end end def api_version_after_switch_to_products_in_plans Date.parse(current_api_version) >= Date.parse('2018-02-05') end def current_api_version Stripe.api_version || begin resp, _ = @stripe_class.request(:get, @stripe_class.resource_url) resp.http_headers['stripe-version'] end end def default_create_options { :currency => @currency, product: { :name => @name, :statement_descriptor => @statement_descriptor, }, :amount => @amount, :interval => @interval, :interval_count => @interval_count, :trial_period_days => @trial_period_days, :metadata => @metadata, } end def create_options_without_products { :currency => @currency, :name => @name, :amount => @amount, :interval => @interval, :interval_count => @interval_count, :trial_period_days => @trial_period_days, :metadata => @metadata, :statement_descriptor => @statement_descriptor } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stripe-rails-1.2.2 | lib/stripe/plans.rb |
stripe-rails-1.2.1 | lib/stripe/plans.rb |