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, CurrentPhase, DefaultSettings, Phase

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.



539
540
541
# File 'lib/stripe/resources/subscription_schedule.rb', line 539

def application
  @application
end

#billing_modeObject (readonly)

The billing mode of the subscription.



541
542
543
# File 'lib/stripe/resources/subscription_schedule.rb', line 541

def billing_mode
  @billing_mode
end

#canceled_atObject (readonly)

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



543
544
545
# File 'lib/stripe/resources/subscription_schedule.rb', line 543

def canceled_at
  @canceled_at
end

#completed_atObject (readonly)

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



545
546
547
# File 'lib/stripe/resources/subscription_schedule.rb', line 545

def completed_at
  @completed_at
end

#createdObject (readonly)

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



547
548
549
# File 'lib/stripe/resources/subscription_schedule.rb', line 547

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.



549
550
551
# File 'lib/stripe/resources/subscription_schedule.rb', line 549

def current_phase
  @current_phase
end

#customerObject (readonly)

ID of the customer who owns the subscription schedule.



551
552
553
# File 'lib/stripe/resources/subscription_schedule.rb', line 551

def customer
  @customer
end

#customer_accountObject (readonly)

ID of the account who owns the subscription schedule.



553
554
555
# File 'lib/stripe/resources/subscription_schedule.rb', line 553

def 
  @customer_account
end

#default_settingsObject (readonly)

Attribute for field default_settings



555
556
557
# File 'lib/stripe/resources/subscription_schedule.rb', line 555

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.



557
558
559
# File 'lib/stripe/resources/subscription_schedule.rb', line 557

def end_behavior
  @end_behavior
end

#idObject (readonly)

Unique identifier for the object.



559
560
561
# File 'lib/stripe/resources/subscription_schedule.rb', line 559

def id
  @id
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.



561
562
563
# File 'lib/stripe/resources/subscription_schedule.rb', line 561

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.



563
564
565
# File 'lib/stripe/resources/subscription_schedule.rb', line 563

def 
  @metadata
end

#objectObject (readonly)

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



565
566
567
# File 'lib/stripe/resources/subscription_schedule.rb', line 565

def object
  @object
end

#phasesObject (readonly)

Configuration for the subscription schedule's phases.



567
568
569
# File 'lib/stripe/resources/subscription_schedule.rb', line 567

def phases
  @phases
end

#released_atObject (readonly)

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



569
570
571
# File 'lib/stripe/resources/subscription_schedule.rb', line 569

def released_at
  @released_at
end

#released_subscriptionObject (readonly)

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



571
572
573
# File 'lib/stripe/resources/subscription_schedule.rb', line 571

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.



573
574
575
# File 'lib/stripe/resources/subscription_schedule.rb', line 573

def status
  @status
end

#subscriptionObject (readonly)

ID of the subscription managed by the subscription schedule.



575
576
577
# File 'lib/stripe/resources/subscription_schedule.rb', line 575

def subscription
  @subscription
end

#test_clockObject (readonly)

ID of the test clock this subscription schedule belongs to.



577
578
579
# File 'lib/stripe/resources/subscription_schedule.rb', line 577

def test_clock
  @test_clock
end

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.



590
591
592
593
594
595
596
597
# File 'lib/stripe/resources/subscription_schedule.rb', line 590

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.



600
601
602
603
604
605
606
607
# File 'lib/stripe/resources/subscription_schedule.rb', line 600

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

.field_remappingsObject



658
659
660
# File 'lib/stripe/resources/subscription_schedule.rb', line 658

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



649
650
651
652
653
654
655
656
# File 'lib/stripe/resources/subscription_schedule.rb', line 649

def self.inner_class_types
  @inner_class_types = {
    billing_mode: BillingMode,
    current_phase: CurrentPhase,
    default_settings: DefaultSettings,
    phases: Phase,
  }
end

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

Retrieves the list of your subscription schedules.



610
611
612
613
614
615
616
617
# File 'lib/stripe/resources/subscription_schedule.rb', line 610

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.



630
631
632
633
634
635
636
637
# File 'lib/stripe/resources/subscription_schedule.rb', line 630

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.



640
641
642
643
644
645
646
647
# File 'lib/stripe/resources/subscription_schedule.rb', line 640

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

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



580
581
582
583
584
585
586
587
# File 'lib/stripe/resources/subscription_schedule.rb', line 580

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.



620
621
622
623
624
625
626
627
# File 'lib/stripe/resources/subscription_schedule.rb', line 620

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