Class: Stripe::SubscriptionSchedule

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/subscription_schedule.rb

Overview

A subscription schedule allows you to create and manage the lifecycle of a subscription by predefining expected changes.

Related guide: Subscription schedules

Defined Under Namespace

Classes: BillingMode, BillingSchedule, CurrentPhase, DefaultSettings, LastPriceMigrationError, PauseSchedule, Phase, Prebilling

Constant Summary collapse

OBJECT_NAME =
"subscription_schedule"

Constants inherited from StripeObject

Stripe::StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#applicationObject (readonly)

ID of the Connect Application that created the schedule.



1058
1059
1060
# File 'lib/stripe/resources/subscription_schedule.rb', line 1058

def application
  @application
end

#billing_behaviorObject (readonly)

Configures when the subscription schedule generates prorations for phase transitions. Possible values are prorate_on_next_phase or prorate_up_front with the default being prorate_on_next_phase. prorate_on_next_phase will apply phase changes and generate prorations at transition time. prorate_up_front will bill for all phases within the current billing cycle up front.



1060
1061
1062
# File 'lib/stripe/resources/subscription_schedule.rb', line 1060

def billing_behavior
  @billing_behavior
end

#billing_modeObject (readonly)

The billing mode of the subscription.



1062
1063
1064
# File 'lib/stripe/resources/subscription_schedule.rb', line 1062

def billing_mode
  @billing_mode
end

#billing_schedulesObject (readonly)

Billing schedules for this subscription schedule.



1064
1065
1066
# File 'lib/stripe/resources/subscription_schedule.rb', line 1064

def billing_schedules
  @billing_schedules
end

#canceled_atObject (readonly)

Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch.



1066
1067
1068
# File 'lib/stripe/resources/subscription_schedule.rb', line 1066

def canceled_at
  @canceled_at
end

#completed_atObject (readonly)

Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch.



1068
1069
1070
# File 'lib/stripe/resources/subscription_schedule.rb', line 1068

def completed_at
  @completed_at
end

#createdObject (readonly)

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



1070
1071
1072
# File 'lib/stripe/resources/subscription_schedule.rb', line 1070

def created
  @created
end

#current_phaseObject (readonly)

Object representing the start and end dates for the current phase of the subscription schedule, if it is active.



1072
1073
1074
# File 'lib/stripe/resources/subscription_schedule.rb', line 1072

def current_phase
  @current_phase
end

#customerObject (readonly)

ID of the customer who owns the subscription schedule.



1074
1075
1076
# File 'lib/stripe/resources/subscription_schedule.rb', line 1074

def customer
  @customer
end

#customer_accountObject (readonly)

ID of the account who owns the subscription schedule.



1076
1077
1078
# File 'lib/stripe/resources/subscription_schedule.rb', line 1076

def 
  @customer_account
end

#default_settingsObject (readonly)

Attribute for field default_settings



1078
1079
1080
# File 'lib/stripe/resources/subscription_schedule.rb', line 1078

def default_settings
  @default_settings
end

#end_behaviorObject (readonly)

Behavior of the subscription schedule and underlying subscription when it ends. Possible values are release or cancel with the default being release. release will end the subscription schedule and keep the underlying subscription running. cancel will end the subscription schedule and cancel the underlying subscription.



1080
1081
1082
# File 'lib/stripe/resources/subscription_schedule.rb', line 1080

def end_behavior
  @end_behavior
end

#idObject (readonly)

Unique identifier for the object.



1082
1083
1084
# File 'lib/stripe/resources/subscription_schedule.rb', line 1082

def id
  @id
end

#last_price_migration_errorObject (readonly)

Details of the most recent price migration that failed for the subscription schedule.



1084
1085
1086
# File 'lib/stripe/resources/subscription_schedule.rb', line 1084

def last_price_migration_error
  @last_price_migration_error
end

#latest_invoiceObject (readonly)

The most recent invoice this subscription schedule has generated.



1086
1087
1088
# File 'lib/stripe/resources/subscription_schedule.rb', line 1086

def latest_invoice
  @latest_invoice
end

#livemodeObject (readonly)

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.



1088
1089
1090
# File 'lib/stripe/resources/subscription_schedule.rb', line 1088

def livemode
  @livemode
end

#metadataObject (readonly)

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.



1090
1091
1092
# File 'lib/stripe/resources/subscription_schedule.rb', line 1090

def 
  @metadata
end

#objectObject (readonly)

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



1092
1093
1094
# File 'lib/stripe/resources/subscription_schedule.rb', line 1092

def object
  @object
end

#pause_schedulesObject (readonly)

The pause schedules for this subscription schedule.



1094
1095
1096
# File 'lib/stripe/resources/subscription_schedule.rb', line 1094

def pause_schedules
  @pause_schedules
end

#phasesObject (readonly)

Configuration for the subscription schedule's phases.



1096
1097
1098
# File 'lib/stripe/resources/subscription_schedule.rb', line 1096

def phases
  @phases
end

#prebillingObject (readonly)

Time period and invoice for a Subscription billed in advance.



1098
1099
1100
# File 'lib/stripe/resources/subscription_schedule.rb', line 1098

def prebilling
  @prebilling
end

#released_atObject (readonly)

Time at which the subscription schedule was released. Measured in seconds since the Unix epoch.



1100
1101
1102
# File 'lib/stripe/resources/subscription_schedule.rb', line 1100

def released_at
  @released_at
end

#released_subscriptionObject (readonly)

ID of the subscription once managed by the subscription schedule (if it is released).



1102
1103
1104
# File 'lib/stripe/resources/subscription_schedule.rb', line 1102

def released_subscription
  @released_subscription
end

#statusObject (readonly)

The present status of the subscription schedule. Possible values are not_started, active, completed, released, and canceled. You can read more about the different states in our behavior guide.



1104
1105
1106
# File 'lib/stripe/resources/subscription_schedule.rb', line 1104

def status
  @status
end

#subscriptionObject (readonly)

ID of the subscription managed by the subscription schedule.



1106
1107
1108
# File 'lib/stripe/resources/subscription_schedule.rb', line 1106

def subscription
  @subscription
end

#test_clockObject (readonly)

ID of the test clock this subscription schedule belongs to.



1108
1109
1110
# File 'lib/stripe/resources/subscription_schedule.rb', line 1108

def test_clock
  @test_clock
end

Class Method Details

.amend(schedule, params = {}, opts = {}) ⇒ Object

Amends an existing subscription schedule.



1121
1122
1123
1124
1125
1126
1127
1128
# File 'lib/stripe/resources/subscription_schedule.rb', line 1121

def self.amend(schedule, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s/amend", { schedule: CGI.escape(schedule) }),
    params: params,
    opts: opts
  )
end

.cancel(schedule, params = {}, opts = {}) ⇒ Object

Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.



1141
1142
1143
1144
1145
1146
1147
1148
# File 'lib/stripe/resources/subscription_schedule.rb', line 1141

def self.cancel(schedule, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s/cancel", { schedule: CGI.escape(schedule) }),
    params: params,
    opts: opts
  )
end

.create(params = {}, opts = {}) ⇒ Object

Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions.



1151
1152
1153
1154
1155
1156
1157
1158
# File 'lib/stripe/resources/subscription_schedule.rb', line 1151

def self.create(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: "/v1/subscription_schedules",
    params: params,
    opts: opts
  )
end

.field_remappingsObject



1213
1214
1215
# File 'lib/stripe/resources/subscription_schedule.rb', line 1213

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
# File 'lib/stripe/resources/subscription_schedule.rb', line 1200

def self.inner_class_types
  @inner_class_types = {
    billing_mode: BillingMode,
    billing_schedules: BillingSchedule,
    current_phase: CurrentPhase,
    default_settings: DefaultSettings,
    last_price_migration_error: LastPriceMigrationError,
    pause_schedules: PauseSchedule,
    phases: Phase,
    prebilling: Prebilling,
  }
end

.list(params = {}, opts = {}) ⇒ Object

Retrieves the list of your subscription schedules.



1161
1162
1163
1164
1165
1166
1167
1168
# File 'lib/stripe/resources/subscription_schedule.rb', line 1161

def self.list(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/subscription_schedules",
    params: params,
    opts: opts
  )
end

.object_nameObject



14
15
16
# File 'lib/stripe/resources/subscription_schedule.rb', line 14

def self.object_name
  "subscription_schedule"
end

.release(schedule, params = {}, opts = {}) ⇒ Object

Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property.



1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/stripe/resources/subscription_schedule.rb', line 1181

def self.release(schedule, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s/release", { schedule: CGI.escape(schedule) }),
    params: params,
    opts: opts
  )
end

.update(schedule, params = {}, opts = {}) ⇒ Object

Updates an existing subscription schedule.



1191
1192
1193
1194
1195
1196
1197
1198
# File 'lib/stripe/resources/subscription_schedule.rb', line 1191

def self.update(schedule, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s", { schedule: CGI.escape(schedule) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

#amend(params = {}, opts = {}) ⇒ Object

Amends an existing subscription schedule.



1111
1112
1113
1114
1115
1116
1117
1118
# File 'lib/stripe/resources/subscription_schedule.rb', line 1111

def amend(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s/amend", { schedule: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#cancel(params = {}, opts = {}) ⇒ Object

Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.



1131
1132
1133
1134
1135
1136
1137
1138
# File 'lib/stripe/resources/subscription_schedule.rb', line 1131

def cancel(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s/cancel", { schedule: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#release(params = {}, opts = {}) ⇒ Object

Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property.



1171
1172
1173
1174
1175
1176
1177
1178
# File 'lib/stripe/resources/subscription_schedule.rb', line 1171

def release(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscription_schedules/%<schedule>s/release", { schedule: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end