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, Pause, 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, pause: 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.



1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1890

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,
  pause: 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
  @pause = pause
  @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`.



1856
1857
1858
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1856

def billing_cycle_anchor
  @billing_cycle_anchor
end

#billing_modeObject

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



1858
1859
1860
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1858

def billing_mode
  @billing_mode
end

#billing_schedulesObject

Sets the billing schedules for the subscription.



1860
1861
1862
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1860

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.



1862
1863
1864
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1862

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`.



1864
1865
1866
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1864

def cancel_at_period_end
  @cancel_at_period_end
end

#cancel_nowObject

This simulates the subscription being canceled or expired immediately.



1866
1867
1868
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1866

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.



1868
1869
1870
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1868

def default_tax_rates
  @default_tax_rates
end

#itemsObject

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



1870
1871
1872
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1870

def items
  @items
end

#pauseObject

Previews the invoice that would be generated when pausing the subscription. Passing an empty hash won’t preview pausing and instead returns the next invoice.

To receive a preview invoice, set ‘invoicing_behavior` to `invoice`. A preview isn’t available if the ‘bill_for` options produce no billable amounts.

‘pending_invoice_item` never has a preview available because pausing wouldn’t generate an invoice, and paused subscriptions don’t generate invoices either.



1876
1877
1878
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1876

def pause
  @pause
end

#prebillingObject

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



1878
1879
1880
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1878

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`.



1880
1881
1882
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1880

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’.



1882
1883
1884
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1882

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.



1884
1885
1886
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1884

def resume_at
  @resume_at
end

#start_dateObject

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



1886
1887
1888
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1886

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.



1888
1889
1890
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1888

def trial_end
  @trial_end
end

Class Method Details

.field_encodingsObject



1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
# File 'lib/stripe/params/invoice_create_preview_params.rb', line 1924

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