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)

Constant Summary collapse

OBJECT_NAME =
"subscription_schedule"

Constants inherited from StripeObject

Stripe::StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

Attributes inherited from APIResource

#save_with_parent

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

Class Method Details

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



36
37
38
39
40
41
42
43
# File 'lib/stripe/resources/subscription_schedule.rb', line 36

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

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



46
47
48
49
50
51
52
53
# File 'lib/stripe/resources/subscription_schedule.rb', line 46

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

Instance Method Details

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



16
17
18
19
20
21
22
23
# File 'lib/stripe/resources/subscription_schedule.rb', line 16

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.



26
27
28
29
30
31
32
33
# File 'lib/stripe/resources/subscription_schedule.rb', line 26

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