Class: Stripe::InvoiceCreatePreviewParams::SubscriptionDetails

Inherits:
RequestParams
  • Object
show all
Defined in:
lib/stripe/params/invoice_create_preview_params.rb

Defined Under Namespace

Classes: BillingMode, BillingSchedule, Item, Prebilling

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(billing_cycle_anchor: nil, billing_mode: nil, billing_schedules: nil, cancel_at: nil, cancel_at_period_end: nil, cancel_now: nil, default_tax_rates: nil, items: nil, prebilling: nil, proration_behavior: nil, proration_date: nil, resume_at: nil, start_date: nil, trial_end: nil) ⇒ SubscriptionDetails

Returns a new instance of SubscriptionDetails.



2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2361

def initialize(
  billing_cycle_anchor: nil,
  billing_mode: nil,
  billing_schedules: nil,
  cancel_at: nil,
  cancel_at_period_end: nil,
  cancel_now: nil,
  default_tax_rates: nil,
  items: nil,
  prebilling: nil,
  proration_behavior: nil,
  proration_date: nil,
  resume_at: nil,
  start_date: nil,
  trial_end: nil
)
  @billing_cycle_anchor = billing_cycle_anchor
  @billing_mode = billing_mode
  @billing_schedules = billing_schedules
  @cancel_at = cancel_at
  @cancel_at_period_end = cancel_at_period_end
  @cancel_now = cancel_now
  @default_tax_rates = default_tax_rates
  @items = items
  @prebilling = prebilling
  @proration_behavior = proration_behavior
  @proration_date = proration_date
  @resume_at = resume_at
  @start_date = start_date
  @trial_end = trial_end
end

Instance Attribute Details

#billing_cycle_anchorObject

For new subscriptions, a future timestamp to anchor the subscription’s [billing cycle](docs.stripe.com/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with ‘month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`.



2333
2334
2335
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2333

def billing_cycle_anchor
  @billing_cycle_anchor
end

#billing_modeObject

Controls how prorations and invoices for subscriptions are calculated and orchestrated.



2335
2336
2337
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2335

def billing_mode
  @billing_mode
end

#billing_schedulesObject

Sets the billing schedules for the subscription.



2337
2338
2339
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2337

def billing_schedules
  @billing_schedules
end

#cancel_atObject

A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using ‘proration_behavior`. If set during a future period, this will always cause a proration for that period.



2339
2340
2341
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2339

def cancel_at
  @cancel_at
end

#cancel_at_period_endObject

Indicate whether this subscription should cancel at the end of the current period (‘current_period_end`). Defaults to `false`.



2341
2342
2343
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2341

def cancel_at_period_end
  @cancel_at_period_end
end

#cancel_nowObject

This simulates the subscription being canceled or expired immediately.



2343
2344
2345
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2343

def cancel_now
  @cancel_now
end

#default_tax_ratesObject

If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have ‘tax_rates` set.



2345
2346
2347
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2345

def default_tax_rates
  @default_tax_rates
end

#itemsObject

A list of up to 20 subscription items, each with an attached price.



2347
2348
2349
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2347

def items
  @items
end

#prebillingObject

The pre-billing to apply to the subscription as a preview.



2349
2350
2351
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2349

def prebilling
  @prebilling
end

#proration_behaviorObject

Determines how to handle [prorations](docs.stripe.com/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting ‘billing_cycle_anchor=now`, or starting a trial), or if an item’s ‘quantity` changes. The default value is `create_prorations`.



2351
2352
2353
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2351

def proration_behavior
  @proration_behavior
end

#proration_dateObject

If previewing an update to a subscription, and doing proration, ‘subscription_details.proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period and within the current phase of the schedule backing this subscription, if the schedule exists. If set, `subscription`, and one of `subscription_details.items`, or `subscription_details.trial_end` are required. Also, `subscription_details.proration_behavior` cannot be set to ’none’.



2353
2354
2355
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2353

def proration_date
  @proration_date
end

#resume_atObject

For paused subscriptions, setting ‘subscription_details.resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed.



2355
2356
2357
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2355

def resume_at
  @resume_at
end

#start_dateObject

Date a subscription is intended to start (can be future or past).



2357
2358
2359
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2357

def start_date
  @start_date
end

#trial_endObject

If provided, the invoice returned will preview updating or creating a subscription with that trial end. If set, one of ‘subscription_details.items` or `subscription` is required.



2359
2360
2361
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2359

def trial_end
  @trial_end
end

Class Method Details

.field_encodingsObject



2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 2393

def self.field_encodings
  @field_encodings = {
    items: {
      kind: :array,
      element: {
        kind: :object,
        fields: { price_data: { kind: :object, fields: { unit_amount_decimal: :decimal_string } } },
      },
    },
  }
end