Class: Stripe::PlanCreateParams

Inherits:
RequestParams show all
Defined in:
lib/stripe/params/plan_create_params.rb

Defined Under Namespace

Classes: Product, Tier, TransformUsage

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RequestParams

attr_accessor, coerce_params, coerce_value, new, #to_h

Constructor Details

#initialize(active: nil, amount: nil, amount_decimal: nil, billing_scheme: nil, currency: nil, expand: nil, id: nil, interval: nil, interval_count: nil, metadata: nil, meter: nil, nickname: nil, product: nil, tiers: nil, tiers_mode: nil, transform_usage: nil, trial_period_days: nil, usage_type: nil) ⇒ PlanCreateParams

Returns a new instance of PlanCreateParams.



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/stripe/params/plan_create_params.rb', line 140

def initialize(
  active: nil,
  amount: nil,
  amount_decimal: nil,
  billing_scheme: nil,
  currency: nil,
  expand: nil,
  id: nil,
  interval: nil,
  interval_count: nil,
  metadata: nil,
  meter: nil,
  nickname: nil,
  product: nil,
  tiers: nil,
  tiers_mode: nil,
  transform_usage: nil,
  trial_period_days: nil,
  usage_type: nil
)
  @active = active
  @amount = amount
  @amount_decimal = amount_decimal
  @billing_scheme = billing_scheme
  @currency = currency
  @expand = expand
  @id = id
  @interval = interval
  @interval_count = interval_count
  @metadata = 
  @meter = meter
  @nickname = nickname
  @product = product
  @tiers = tiers
  @tiers_mode = tiers_mode
  @transform_usage = transform_usage
  @trial_period_days = trial_period_days
  @usage_type = usage_type
end

Instance Attribute Details

#activeObject

Whether the plan is currently available for new subscriptions. Defaults to true.



104
105
106
# File 'lib/stripe/params/plan_create_params.rb', line 104

def active
  @active
end

#amountObject

A positive integer in cents (or local equivalent) (or 0 for a free plan) representing how much to charge on a recurring basis.



106
107
108
# File 'lib/stripe/params/plan_create_params.rb', line 106

def amount
  @amount
end

#amount_decimalObject

Same as amount, but accepts a decimal value with at most 12 decimal places. Only one of amount and amount_decimal can be set.



108
109
110
# File 'lib/stripe/params/plan_create_params.rb', line 108

def amount_decimal
  @amount_decimal
end

#billing_schemeObject

Describes how to compute the price per period. Either per_unit or tiered. per_unit indicates that the fixed amount (specified in amount) will be charged per unit in quantity (for plans with usage_type=licensed), or per unit of total usage (for plans with usage_type=metered). tiered indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers and tiers_mode attributes.



110
111
112
# File 'lib/stripe/params/plan_create_params.rb', line 110

def billing_scheme
  @billing_scheme
end

#currencyObject

Three-letter ISO currency code, in lowercase. Must be a supported currency.



112
113
114
# File 'lib/stripe/params/plan_create_params.rb', line 112

def currency
  @currency
end

#expandObject

Specifies which fields in the response should be expanded.



114
115
116
# File 'lib/stripe/params/plan_create_params.rb', line 114

def expand
  @expand
end

#idObject

An identifier randomly generated by Stripe. Used to identify this plan when subscribing a customer. You can optionally override this ID, but the ID must be unique across all plans in your Stripe account. You can, however, use the same plan ID in both live and test modes.



116
117
118
# File 'lib/stripe/params/plan_create_params.rb', line 116

def id
  @id
end

#intervalObject

Specifies billing frequency. Either day, week, month or year.



118
119
120
# File 'lib/stripe/params/plan_create_params.rb', line 118

def interval
  @interval
end

#interval_countObject

The number of intervals between subscription billings. For example, interval=month and interval_count=3 bills every 3 months. Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).



120
121
122
# File 'lib/stripe/params/plan_create_params.rb', line 120

def interval_count
  @interval_count
end

#metadataObject

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.



122
123
124
# File 'lib/stripe/params/plan_create_params.rb', line 122

def 
  @metadata
end

#meterObject

The meter tracking the usage of a metered price



124
125
126
# File 'lib/stripe/params/plan_create_params.rb', line 124

def meter
  @meter
end

#nicknameObject

A brief description of the plan, hidden from customers.



126
127
128
# File 'lib/stripe/params/plan_create_params.rb', line 126

def nickname
  @nickname
end

#productObject

Attribute for param field product



128
129
130
# File 'lib/stripe/params/plan_create_params.rb', line 128

def product
  @product
end

#tiersObject

Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered. See also the documentation for billing_scheme.



130
131
132
# File 'lib/stripe/params/plan_create_params.rb', line 130

def tiers
  @tiers
end

#tiers_modeObject

Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price, in graduated tiering pricing can successively change as the quantity grows.



132
133
134
# File 'lib/stripe/params/plan_create_params.rb', line 132

def tiers_mode
  @tiers_mode
end

#transform_usageObject

Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with tiers.



134
135
136
# File 'lib/stripe/params/plan_create_params.rb', line 134

def transform_usage
  @transform_usage
end

#trial_period_daysObject

Default number of trial days when subscribing a customer to this plan using trial_from_plan=true.



136
137
138
# File 'lib/stripe/params/plan_create_params.rb', line 136

def trial_period_days
  @trial_period_days
end

#usage_typeObject

Configures how the quantity per period should be determined. Can be either metered or licensed. licensed automatically bills the quantity set when adding it to a subscription. metered aggregates the total usage based on usage records. Defaults to licensed.



138
139
140
# File 'lib/stripe/params/plan_create_params.rb', line 138

def usage_type
  @usage_type
end

Class Method Details

.field_encodingsObject



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/stripe/params/plan_create_params.rb', line 180

def self.field_encodings
  @field_encodings = {
    amount_decimal: :decimal_string,
    tiers: {
      kind: :array,
      element: {
        kind: :object,
        fields: { flat_amount_decimal: :decimal_string, unit_amount_decimal: :decimal_string },
      },
    },
  }
end