Sha256: bce224237aaabeff4262d9539d4e91e81f7f518c3326f0132f3a136de7aae771

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 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

      def create_options
        {
          :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

5 entries across 5 versions & 1 rubygems

Version Path
stripe-rails-1.2.0 lib/stripe/plans.rb
stripe-rails-1.1.2 lib/stripe/plans.rb
stripe-rails-1.1.1 lib/stripe/plans.rb
stripe-rails-1.1.0 lib/stripe/plans.rb
stripe-rails-1.0.2 lib/stripe/plans.rb