stripity_stripe v2.7.0 Stripe.SubscriptionSchedule View Source

Work with Stripe subscription schedule objects.

Link to this section Summary

Functions

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.

Create a subscription schedule.

Retrieves the list of your subscription schedules.

Releases a subscription schedule

Retrieve a subscription schedule.

Update a subscription schedule. Takes the id and a map of changes.

Link to this section Types

Link to this type

phases() View Source
phases() :: %{
  application_fee_percent: float() | nil,
  end_date: Stripe.timestamp(),
  start_date: Stripe.timestamp(),
  tax_percent: float() | nil,
  trial_end: Stripe.timestamp(),
  plans: [plans()]
}

Link to this type

plans() View Source
plans() :: %{plan: String.t(), quantity: pos_integer()}

Link to this type

t() View Source
t() :: %Stripe.SubscriptionSchedule{
  billing: term(),
  billing_thresholds: Stripe.Types.subscription_billing_thresholds() | nil,
  canceled_at: Stripe.timestamp() | nil,
  collection_method: String.t(),
  completed_at: Stripe.timestamp() | nil,
  created: Stripe.timestamp(),
  current_phase: %{start_date: Stripe.timestamp(), end_date: Stripe.timestamp()},
  customer: Stripe.id() | Stripe.Customer.t(),
  default_payment_method: Stripe.id() | Stripe.PaymentMethod.t(),
  id: Stripe.id(),
  invoice_settings: %{days_until_due: integer()},
  livemode: boolean(),
  metadata: Stripe.Types.metadata(),
  object: String.t(),
  phases: [phases()],
  released_at: Stripe.timestamp() | nil,
  released_subscription: Stripe.id() | Stripe.Subscription.t() | nil,
  renewal_behavior: String.t(),
  renewal_interval: String.t(),
  revision: String.t(),
  status: String.t(),
  subscription: Stripe.id() | Stripe.Subscription.t()
}

Link to this section Functions

Link to this function

cancel(id, opts \\ []) View Source
cancel(Stripe.id() | t(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

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.

Takes the subscription schedule id.

Link to this function

create(params, opts \\ []) View Source
create(params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       optional(:customer) => Stripe.id(),
       optional(:billing) => String.t(),
       optional(:collection_method) => String.t(),
       optional(:from_subscription) => Stripe.id(),
       optional(:invoice_settings) => %{
         optional(:days_until_due) => non_neg_integer()
       },
       optional(:default_payment_method) => Stripe.id(),
       optional(:phases) => [
         %{
           :plans => [
             %{
               :plan => Stripe.id() | Stripe.Plan.t(),
               optional(:quantity) => non_neg_integer()
             }
           ],
           optional(:application_fee_percent) => non_neg_integer(),
           optional(:coupon) => String.t(),
           optional(:end_date) => Stripe.timestamp(),
           optional(:iterations) => non_neg_integer(),
           optional(:start_date) => Stripe.timestamp(),
           optional(:tax_percent) => float(),
           optional(:trial) => boolean(),
           optional(:trial_end) => Stripe.timestamp()
         }
       ],
       optional(:renewal_behavior) => String.t(),
       optional(:renewal_interval) => %{
         renewal_interval: String.t(),
         length: non_neg_integer()
       },
       optional(:start_date) => Stripe.timestamp()
     }

Create a subscription schedule.

Examples

Create subscription schedule from existing subscription

Stripe.SubscriptionSchedule.create(%{from_subscription: "sub_1234"})

Link to this function

list(params \\ %{}, opts \\ []) View Source
list(params, Stripe.options()) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()}
when params: %{
       optional(:canceled_at) => Stripe.date_query(),
       optional(:completed_at) => Stripe.date_query(),
       optional(:created) => Stripe.date_query(),
       optional(:customer) => Stripe.Customer.t() | Stripe.id(),
       optional(:ending_before) => t() | Stripe.id(),
       optional(:limit) => 1..100,
       optional(:released_at) => Stripe.date_query(),
       optional(:scheduled) => boolean(),
       optional(:starting_after) => t() | Stripe.id()
     }

Retrieves the list of your subscription schedules.

Link to this function

release(id, opts \\ []) View Source
release(Stripe.id() | t(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Releases a subscription schedule

Takes the subscription schedule id.

Link to this function

retrieve(id, opts \\ []) View Source
retrieve(Stripe.id() | t(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Retrieve a subscription schedule.

Link to this function

update(id, params, opts \\ []) View Source
update(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       optional(:billing) => String.t(),
       optional(:collection_method) => String.t(),
       optional(:invoice_settings) => %{
         optional(:days_until_due) => non_neg_integer()
       },
       optional(:default_payment_method) => Stripe.id(),
       optional(:phases) => [
         %{
           :plans => [
             %{
               :plan => Stripe.id() | Stripe.Plan.t(),
               optional(:quantity) => non_neg_integer()
             }
           ],
           optional(:application_fee_percent) => non_neg_integer(),
           optional(:coupon) => String.t(),
           optional(:end_date) => Stripe.timestamp(),
           optional(:iterations) => non_neg_integer(),
           optional(:start_date) => Stripe.timestamp(),
           optional(:tax_percent) => float(),
           optional(:trial) => boolean(),
           optional(:trial_end) => Stripe.timestamp()
         }
       ],
       optional(:renewal_behavior) => String.t(),
       optional(:prorate) => boolean(),
       optional(:renewal_interval) => %{
         renewal_interval: String.t(),
         length: non_neg_integer()
       }
     }

Update a subscription schedule. Takes the id and a map of changes.