class

Stripe::Subscription

Inherits OpenApi::Json < OpenApi::Validatable < JSON::Serializable::Unmapped < JSON::Serializable < Reference < Object

Subscriptions allow you to charge a customer on a recurring basis. Related guide: Creating subscriptions

Constants

ERROR_MESSAGE_FOR_COLLECTION_METHOD = "invalid value for \"collection_method\", must be one of [charge_automatically, send_invoice]."
ERROR_MESSAGE_FOR_OBJECT = "invalid value for \"object\", must be one of [subscription]."
ERROR_MESSAGE_FOR_STATUS = "invalid value for \"status\", must be one of [active, canceled, incomplete, incomplete_expired, past_due, paused, trialing, unpaid]."
MAX_LENGTH_FOR_DESCRIPTION = 500
MAX_LENGTH_FOR_ID = 5000
VALID_VALUES_FOR_COLLECTION_METHOD = String.static_array("charge_automatically", "send_invoice")
VALID_VALUES_FOR_OBJECT = String.static_array("subscription")
VALID_VALUES_FOR_STATUS = String.static_array("active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid")

Constructors

new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source
new(*, application : Stripe::SubscriptionApplication | Nil = nil, application_fee_percent : Float64 | Nil = nil, automatic_tax : Stripe::SubscriptionAutomaticTax | Nil = nil, billing_cycle_anchor : Int64 | Nil = nil, billing_cycle_anchor_config : Stripe::SubscriptionBillingCycleAnchorConfig | Nil = nil, billing_thresholds : Stripe::SubscriptionBillingThresholds1 | Nil = nil, cancel_at : Int64 | Nil = nil, cancel_at_period_end : Bool | Nil = nil, canceled_at : Int64 | Nil = nil, cancellation_details : Stripe::SubscriptionCancellationDetails | Nil = nil, collection_method : String | Nil = nil, created : Int64 | Nil = nil, currency : String | Nil = nil, current_period_end : Int64 | Nil = nil, current_period_start : Int64 | Nil = nil, customer : Stripe::SubscriptionCustomer | Nil = nil, days_until_due : Int64 | Nil = nil, default_payment_method : Stripe::SubscriptionDefaultPaymentMethod | Nil = nil, default_source : Stripe::SubscriptionDefaultSource | Nil = nil, description : String | Nil = nil, discount : Stripe::SubscriptionDiscount | Nil = nil, discounts : Array(Stripe::InvoiceitemDiscountsInner) | Nil = nil, ended_at : Int64 | Nil = nil, id : String | Nil = nil, invoice_settings : Stripe::SubscriptionsResourceSubscriptionInvoiceSettings | Nil = nil, items : Stripe::SubscriptionItemList | Nil = nil, latest_invoice : Stripe::SubscriptionLatestInvoice | Nil = nil, livemode : Bool | Nil = nil, metadata : Hash(String, String) | Nil = nil, next_pending_invoice_item_invoice : Int64 | Nil = nil, object : String | Nil = nil, on_behalf_of : Stripe::SubscriptionOnBehalfOf | Nil = nil, pause_collection : Stripe::SubscriptionPauseCollection | Nil = nil, payment_settings : Stripe::SubscriptionPaymentSettings | Nil = nil, pending_invoice_item_interval : Stripe::SubscriptionPendingInvoiceItemInterval1 | Nil = nil, pending_setup_intent : Stripe::SubscriptionPendingSetupIntent | Nil = nil, pending_update : Stripe::SubscriptionPendingUpdate | Nil = nil, schedule : Stripe::SubscriptionSchedule1 | Nil = nil, start_date : Int64 | Nil = nil, status : String | Nil = nil, test_clock : Stripe::SubscriptionTestClock | Nil = nil, transfer_data : Stripe::SubscriptionTransferData1 | Nil = nil, trial_end : Int64 | Nil = nil, trial_settings : Stripe::PaymentLinksResourceSubscriptionDataTrialSettings | Nil = nil, trial_start : Int64 | Nil = nil, default_tax_rates : Array(Stripe::TaxRate) | Nil = nil)

Initializes the object @param [Hash] attributes Model attributes in the form of hash

Source

Instance methods

==(other : self)

Generates #hash and #== methods from all fields #== @return [Bool] #hash calculates hash code according to all attributes. #hash @return [UInt64] Hash code

application
Source
application=(new_value : Stripe::SubscriptionApplication | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] application Object to be assigned

Source
application_fee_percent

A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account.

Source
application_fee_percent=(new_value : Float64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] application_fee_percent Object to be assigned

Source
automatic_tax
Source
automatic_tax=(new_value : Stripe::SubscriptionAutomaticTax | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] automatic_tax Object to be assigned

Source
billing_cycle_anchor

The reference point that aligns future billing cycle dates. It sets the day of week for week intervals, the day of month for month and year intervals, and the month of year for year intervals. The timestamp is in UTC format.

Source
billing_cycle_anchor=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] billing_cycle_anchor Object to be assigned

Source
billing_cycle_anchor_config
Source
billing_cycle_anchor_config=(new_value : Stripe::SubscriptionBillingCycleAnchorConfig | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] billing_cycle_anchor_config Object to be assigned

Source
billing_thresholds
Source
billing_thresholds=(new_value : Stripe::SubscriptionBillingThresholds1 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] billing_thresholds Object to be assigned

Source
cancel_at

A date in the future at which the subscription will automatically get canceled

Source
cancel_at=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] cancel_at Object to be assigned

Source
cancel_at_period_end

Whether this subscription will (if status=active) or did (if status=canceled) cancel at the end of the current billing period.

Source
cancel_at_period_end=(new_value : Bool | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] cancel_at_period_end Object to be assigned

Source
canceled_at

If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.

Source
canceled_at=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] canceled_at Object to be assigned

Source
cancellation_details
Source
cancellation_details=(new_value : Stripe::SubscriptionCancellationDetails | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] cancellation_details Object to be assigned

Source
collection_method

Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as active.

Source
collection_method=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] collection_method Object to be assigned

Source
created

Time at which the object was created. Measured in seconds since the Unix epoch.

Source
created=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] created Object to be assigned

Source
currency

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

Source
currency=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] currency Object to be assigned

Source
current_period_end

End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.

Source
current_period_end=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] current_period_end Object to be assigned

Source
current_period_start

Start of the current period that the subscription has been invoiced for.

Source
current_period_start=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] current_period_start Object to be assigned

Source
customer
Source
customer=(new_value : Stripe::SubscriptionCustomer | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] customer Object to be assigned

Source
days_until_due

Number of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where collection_method=charge_automatically.

Source
days_until_due=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] days_until_due Object to be assigned

Source
default_payment_method
Source
default_payment_method=(new_value : Stripe::SubscriptionDefaultPaymentMethod | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] default_payment_method Object to be assigned

Source
default_source
Source
default_source=(new_value : Stripe::SubscriptionDefaultSource | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] default_source Object to be assigned

Source
default_tax_rates

The tax rates that will apply to any subscription item that does not have tax_rates set. Invoices created will have their default_tax_rates populated from the subscription.

Source
default_tax_rates=(new_value : Array(Stripe::TaxRate) | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] default_tax_rates Object to be assigned

Source
default_tax_rates_present=(default_tax_rates_present : Bool)
Source
default_tax_rates_present?
Source
description

The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.

Source
description=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] description Object to be assigned

Source
discount
Source
discount=(new_value : Stripe::SubscriptionDiscount | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] discount Object to be assigned

Source
discounts

The discounts applied to the subscription. Subscription item discounts are applied before subscription discounts. Use expand[]=discounts to expand each discount.

Source
discounts=(new_value : Array(Stripe::InvoiceitemDiscountsInner) | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] discounts Object to be assigned

Source
ended_at

If the subscription has ended, the date the subscription ended.

Source
ended_at=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] ended_at Object to be assigned

Source
hash(hasher)

Generates #hash and #== methods from all fields #== @return [Bool] #hash calculates hash code according to all attributes. #hash @return [UInt64] Hash code

id

Unique identifier for the object.

Source
id=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] id Object to be assigned

Source
invoice_settings
Source

Custom attribute writer method checking allowed values (enum). @param [Object] invoice_settings Object to be assigned

Source
items
Source
items=(new_value : Stripe::SubscriptionItemList | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] items Object to be assigned

Source
latest_invoice
Source
latest_invoice=(new_value : Stripe::SubscriptionLatestInvoice | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] latest_invoice Object to be assigned

Source
list_invalid_properties

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

Source
livemode

Has the value true if the object exists in live mode or the value false if the object exists in test mode.

Source
livemode=(new_value : Bool | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] livemode Object to be assigned

Source
metadata
Source
metadata=(new_value : Hash(String, String) | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] metadata Object to be assigned

Source
next_pending_invoice_item_invoice

Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at pending_invoice_item_interval.

Source
next_pending_invoice_item_invoice=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] next_pending_invoice_item_invoice Object to be assigned

Source
object

String representing the object's type. Objects of the same type share the same value.

Source
object=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] object Object to be assigned

Source
on_behalf_of
Source
on_behalf_of=(new_value : Stripe::SubscriptionOnBehalfOf | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] on_behalf_of Object to be assigned

Source
pause_collection
Source
pause_collection=(new_value : Stripe::SubscriptionPauseCollection | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] pause_collection Object to be assigned

Source
payment_settings
Source
payment_settings=(new_value : Stripe::SubscriptionPaymentSettings | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] payment_settings Object to be assigned

Source
pending_invoice_item_interval
Source
pending_invoice_item_interval=(new_value : Stripe::SubscriptionPendingInvoiceItemInterval1 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] pending_invoice_item_interval Object to be assigned

Source
pending_setup_intent
Source
pending_setup_intent=(new_value : Stripe::SubscriptionPendingSetupIntent | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] pending_setup_intent Object to be assigned

Source
pending_update
Source
pending_update=(new_value : Stripe::SubscriptionPendingUpdate | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] pending_update Object to be assigned

Source
schedule
Source
schedule=(new_value : Stripe::SubscriptionSchedule1 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] schedule Object to be assigned

Source
start_date

Date when the subscription was first created. The date might differ from the created date due to backdating.

Source
start_date=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] start_date Object to be assigned

Source
status

Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, unpaid, or paused. For collection_method=charge_automatically a subscription moves into incomplete if the initial payment attempt fails. A subscription in this status can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an active status. If the first invoice is not paid within 23 hours, the subscription transitions to incomplete_expired. This is a terminal status, the open invoice will be voided and no further invoices will be generated. A subscription that is currently in a trial period is trialing and moves to active when the trial period is over. A subscription can only enter a paused status when a trial ends without a payment method. A paused subscription doesn't generate invoices and can be resumed after your customer adds their payment method. The paused status is different from pausing collection, which still generates invoices and leaves the subscription's status unchanged. If subscription collection_method=charge_automatically, it becomes past_due when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become canceled or unpaid (depending on your subscriptions settings). If subscription collection_method=send_invoice it becomes past_due when its invoice is not paid by the due date, and canceled or unpaid if it is still not paid by an additional deadline after that. Note that when a subscription has a status of unpaid, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.

Source
status=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] status Object to be assigned

Source
test_clock
Source
test_clock=(new_value : Stripe::SubscriptionTestClock | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] test_clock Object to be assigned

Source
transfer_data
Source
transfer_data=(new_value : Stripe::SubscriptionTransferData1 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] transfer_data Object to be assigned

Source
trial_end

If the subscription has a trial, the end of that trial.

Source
trial_end=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] trial_end Object to be assigned

Source
trial_settings
Source

Custom attribute writer method checking allowed values (enum). @param [Object] trial_settings Object to be assigned

Source
trial_start

If the subscription has a trial, the beginning of that trial.

Source
trial_start=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] trial_start Object to be assigned

Source
valid?

Check to see if the all the properties in the model are valid @return true if the model is valid

Source