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](stripe.com/docs/billing/subscriptions/subscription-schedules)

Defined Under Namespace

Classes: AmendParams, CancelParams, CreateParams, CurrentPhase, DefaultSettings, LastPriceMigrationError, ListParams, Phase, Prebilling, ReleaseParams, RetrieveParams, UpdateParams

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

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #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.



2726
2727
2728
# File 'lib/stripe/resources/subscription_schedule.rb', line 2726

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.



2729
2730
2731
# File 'lib/stripe/resources/subscription_schedule.rb', line 2729

def billing_behavior
  @billing_behavior
end

#canceled_atObject (readonly)

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



2732
2733
2734
# File 'lib/stripe/resources/subscription_schedule.rb', line 2732

def canceled_at
  @canceled_at
end

#completed_atObject (readonly)

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



2735
2736
2737
# File 'lib/stripe/resources/subscription_schedule.rb', line 2735

def completed_at
  @completed_at
end

#createdObject (readonly)

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



2738
2739
2740
# File 'lib/stripe/resources/subscription_schedule.rb', line 2738

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



2741
2742
2743
# File 'lib/stripe/resources/subscription_schedule.rb', line 2741

def current_phase
  @current_phase
end

#customerObject (readonly)

ID of the customer who owns the subscription schedule.



2744
2745
2746
# File 'lib/stripe/resources/subscription_schedule.rb', line 2744

def customer
  @customer
end

#default_settingsObject (readonly)

Attribute for field default_settings



2747
2748
2749
# File 'lib/stripe/resources/subscription_schedule.rb', line 2747

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.



2750
2751
2752
# File 'lib/stripe/resources/subscription_schedule.rb', line 2750

def end_behavior
  @end_behavior
end

#idObject (readonly)

Unique identifier for the object.



2753
2754
2755
# File 'lib/stripe/resources/subscription_schedule.rb', line 2753

def id
  @id
end

#last_price_migration_errorObject (readonly)

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



2756
2757
2758
# File 'lib/stripe/resources/subscription_schedule.rb', line 2756

def last_price_migration_error
  @last_price_migration_error
end

#livemodeObject (readonly)

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



2759
2760
2761
# File 'lib/stripe/resources/subscription_schedule.rb', line 2759

def livemode
  @livemode
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



2762
2763
2764
# File 'lib/stripe/resources/subscription_schedule.rb', line 2762

def 
  @metadata
end

#objectObject (readonly)

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



2765
2766
2767
# File 'lib/stripe/resources/subscription_schedule.rb', line 2765

def object
  @object
end

#phasesObject (readonly)

Configuration for the subscription schedule’s phases.



2768
2769
2770
# File 'lib/stripe/resources/subscription_schedule.rb', line 2768

def phases
  @phases
end

#prebillingObject (readonly)

Time period and invoice for a Subscription billed in advance.



2771
2772
2773
# File 'lib/stripe/resources/subscription_schedule.rb', line 2771

def prebilling
  @prebilling
end

#released_atObject (readonly)

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



2774
2775
2776
# File 'lib/stripe/resources/subscription_schedule.rb', line 2774

def released_at
  @released_at
end

#released_subscriptionObject (readonly)

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



2777
2778
2779
# File 'lib/stripe/resources/subscription_schedule.rb', line 2777

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](stripe.com/docs/billing/subscriptions/subscription-schedules).



2780
2781
2782
# File 'lib/stripe/resources/subscription_schedule.rb', line 2780

def status
  @status
end

#subscriptionObject (readonly)

ID of the subscription managed by the subscription schedule.



2783
2784
2785
# File 'lib/stripe/resources/subscription_schedule.rb', line 2783

def subscription
  @subscription
end

#test_clockObject (readonly)

ID of the test clock this subscription schedule belongs to.



2786
2787
2788
# File 'lib/stripe/resources/subscription_schedule.rb', line 2786

def test_clock
  @test_clock
end

Class Method Details

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

Amends an existing subscription schedule.



2799
2800
2801
2802
2803
2804
2805
2806
# File 'lib/stripe/resources/subscription_schedule.rb', line 2799

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.



2819
2820
2821
2822
2823
2824
2825
2826
# File 'lib/stripe/resources/subscription_schedule.rb', line 2819

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.



2829
2830
2831
2832
2833
2834
2835
2836
# File 'lib/stripe/resources/subscription_schedule.rb', line 2829

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

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

Retrieves the list of your subscription schedules.



2839
2840
2841
2842
2843
2844
2845
2846
# File 'lib/stripe/resources/subscription_schedule.rb', line 2839

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.



2859
2860
2861
2862
2863
2864
2865
2866
# File 'lib/stripe/resources/subscription_schedule.rb', line 2859

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(id, params = {}, opts = {}) ⇒ Object

Updates an existing subscription schedule.



2869
2870
2871
2872
2873
2874
2875
2876
# File 'lib/stripe/resources/subscription_schedule.rb', line 2869

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

Instance Method Details

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

Amends an existing subscription schedule.



2789
2790
2791
2792
2793
2794
2795
2796
# File 'lib/stripe/resources/subscription_schedule.rb', line 2789

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.



2809
2810
2811
2812
2813
2814
2815
2816
# File 'lib/stripe/resources/subscription_schedule.rb', line 2809

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.



2849
2850
2851
2852
2853
2854
2855
2856
# File 'lib/stripe/resources/subscription_schedule.rb', line 2849

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