Packages
stripity_stripe
3.3.1
3.3.2
3.3.1
3.2.0
3.1.1
3.1.0
3.0.0
2.17.3
2.17.2
2.17.1
2.17.0
2.16.0
2.15.1
2.15.0
2.14.1
2.14.0
2.13.0
2.12.1
2.12.0
2.11.0
2.10.0
2.9.0
2.8.0
2.7.2
2.7.1
2.7.0
2.6.0
2.5.0
2.4.0
2.3.0
2.2.3
2.2.2
2.2.1
2.2.0
2.1.0
2.0.1
2.0.0
2.0.0-alpha.11
2.0.0-alpha.10
2.0.0-alpha.9
2.0.0-alpha.8
2.0.0-alpha.7
2.0.0-alpha.6
2.0.0-alpha.5
2.0.0-alpha.4
2.0.0-alpha.3
2.0.0-alpha.2
2.0.0-alpha.1
1.6.2
1.6.1
1.6.0
1.4.0
1.3.0
1.2.0
1.1.0
0.5.0
0.4.0
0.3.0
0.2.0
A Stripe client for Elixir.
Current section
Files
Jump to
Current section
Files
lib/generated/subscription_schedule.ex
defmodule Stripe.SubscriptionSchedule do
use Stripe.Entity
@moduledoc "A subscription schedule allows you to create and manage the lifecycle of a subscription by predefining expected changes.\n\nRelated guide: [Subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules)"
(
defstruct [
:application,
:billing_mode,
:canceled_at,
:completed_at,
:created,
:current_phase,
:customer,
:default_settings,
:end_behavior,
:id,
:livemode,
:metadata,
:object,
:phases,
:released_at,
:released_subscription,
:status,
:subscription,
:test_clock
]
@typedoc "The `subscription_schedule` type.\n\n * `application` ID of the Connect Application that created the schedule.\n * `billing_mode` \n * `canceled_at` Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch.\n * `completed_at` Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `current_phase` Object representing the start and end dates for the current phase of the subscription schedule, if it is `active`.\n * `customer` ID of the customer who owns the subscription schedule.\n * `default_settings` \n * `end_behavior` 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.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://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.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `phases` Configuration for the subscription schedule's phases.\n * `released_at` Time at which the subscription schedule was released. Measured in seconds since the Unix epoch.\n * `released_subscription` ID of the subscription once managed by the subscription schedule (if it is released).\n * `status` 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](https://stripe.com/docs/billing/subscriptions/subscription-schedules).\n * `subscription` ID of the subscription managed by the subscription schedule.\n * `test_clock` ID of the test clock this subscription schedule belongs to.\n"
@type t :: %__MODULE__{
application: (binary | term | term) | nil,
billing_mode: term,
canceled_at: integer | nil,
completed_at: integer | nil,
created: integer,
current_phase: term | nil,
customer: binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t(),
default_settings: term,
end_behavior: binary,
id: binary,
livemode: boolean,
metadata: term | nil,
object: binary,
phases: term,
released_at: integer | nil,
released_subscription: binary | nil,
status: binary,
subscription: (binary | Stripe.Subscription.t()) | nil,
test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil
}
)
(
@typedoc nil
@type add_invoice_items :: %{
optional(:discounts) => list(discounts),
optional(:metadata) => %{optional(binary) => binary},
optional(:period) => period,
optional(:price) => binary,
optional(:price_data) => price_data,
optional(:quantity) => integer,
optional(:tax_rates) => list(binary) | binary
}
)
(
@typedoc "Automatic tax settings for this phase."
@type automatic_tax :: %{optional(:enabled) => boolean, optional(:liability) => liability}
)
(
@typedoc "Controls how prorations and invoices for subscriptions are calculated and orchestrated."
@type billing_mode :: %{
optional(:flexible) => flexible,
optional(:type) => :classic | :flexible
}
)
(
@typedoc nil
@type billing_thresholds :: %{
optional(:amount_gte) => integer,
optional(:reset_billing_cycle_anchor) => boolean
}
)
(
@typedoc nil
@type canceled_at :: %{
optional(:gt) => integer,
optional(:gte) => integer,
optional(:lt) => integer,
optional(:lte) => integer
}
)
(
@typedoc nil
@type completed_at :: %{
optional(:gt) => integer,
optional(:gte) => integer,
optional(:lt) => integer,
optional(:lte) => integer
}
)
(
@typedoc nil
@type created :: %{
optional(:gt) => integer,
optional(:gte) => integer,
optional(:lt) => integer,
optional(:lte) => integer
}
)
(
@typedoc "Object representing the subscription schedule's default settings."
@type default_settings :: %{
optional(:application_fee_percent) => number,
optional(:automatic_tax) => automatic_tax,
optional(:billing_cycle_anchor) => :automatic | :phase_start,
optional(:billing_thresholds) => billing_thresholds | binary,
optional(:collection_method) => :charge_automatically | :send_invoice,
optional(:default_payment_method) => binary,
optional(:description) => binary | binary,
optional(:invoice_settings) => invoice_settings,
optional(:on_behalf_of) => binary | binary,
optional(:transfer_data) => transfer_data | binary
}
)
(
@typedoc nil
@type discounts :: %{
optional(:coupon) => binary,
optional(:discount) => binary,
optional(:promotion_code) => binary
}
)
(
@typedoc "The number of intervals the phase should last. If set, `end_date` must not be set."
@type duration :: %{
optional(:interval) => :day | :month | :week | :year,
optional(:interval_count) => integer
}
)
(
@typedoc "End of the invoice item period."
@type end_field :: %{
optional(:timestamp) => integer,
optional(:type) => :min_item_period_end | :phase_end | :timestamp
}
)
(
@typedoc "Configure behavior for flexible billing mode."
@type flexible :: %{optional(:proration_discounts) => :included | :itemized}
)
(
@typedoc "All invoices will be billed using the specified settings."
@type invoice_settings :: %{
optional(:account_tax_ids) => list(binary) | binary,
optional(:days_until_due) => integer,
optional(:issuer) => issuer
}
)
(
@typedoc "The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account."
@type issuer :: %{optional(:account) => binary, optional(:type) => :account | :self}
)
(
@typedoc nil
@type items :: %{
optional(:billing_thresholds) => billing_thresholds | binary,
optional(:discounts) => list(discounts) | binary,
optional(:metadata) => %{optional(binary) => binary},
optional(:plan) => binary,
optional(:price) => binary,
optional(:price_data) => price_data,
optional(:quantity) => integer,
optional(:tax_rates) => list(binary) | binary
}
)
(
@typedoc "The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account."
@type liability :: %{optional(:account) => binary, optional(:type) => :account | :self}
)
(
@typedoc "The period associated with this invoice item. If not set, `period.start.type` defaults to `max_item_period_start` and `period.end.type` defaults to `min_item_period_end`."
@type period :: %{optional(:end) => end_field, optional(:start) => start}
)
(
@typedoc nil
@type phases :: %{
optional(:add_invoice_items) => list(add_invoice_items),
optional(:application_fee_percent) => number,
optional(:automatic_tax) => automatic_tax,
optional(:billing_cycle_anchor) => :automatic | :phase_start,
optional(:billing_thresholds) => billing_thresholds | binary,
optional(:collection_method) => :charge_automatically | :send_invoice,
optional(:currency) => binary,
optional(:default_payment_method) => binary,
optional(:default_tax_rates) => list(binary) | binary,
optional(:description) => binary | binary,
optional(:discounts) => list(discounts) | binary,
optional(:duration) => duration,
optional(:end_date) => integer,
optional(:invoice_settings) => invoice_settings,
optional(:items) => list(items),
optional(:metadata) => %{optional(binary) => binary},
optional(:on_behalf_of) => binary,
optional(:proration_behavior) => :always_invoice | :create_prorations | :none,
optional(:transfer_data) => transfer_data,
optional(:trial) => boolean,
optional(:trial_end) => integer
}
)
(
@typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline."
@type price_data :: %{
optional(:currency) => binary,
optional(:product) => binary,
optional(:recurring) => recurring,
optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
optional(:unit_amount) => integer,
optional(:unit_amount_decimal) => binary
}
)
(
@typedoc "The recurring components of a price such as `interval` and `interval_count`."
@type recurring :: %{
optional(:interval) => :day | :month | :week | :year,
optional(:interval_count) => integer
}
)
(
@typedoc nil
@type released_at :: %{
optional(:gt) => integer,
optional(:gte) => integer,
optional(:lt) => integer,
optional(:lte) => integer
}
)
(
@typedoc "Start of the invoice item period."
@type start :: %{
optional(:timestamp) => integer,
optional(:type) => :max_item_period_start | :phase_start | :timestamp
}
)
(
@typedoc nil
@type transfer_data :: %{
optional(:amount_percent) => number,
optional(:destination) => binary
}
)
(
nil
@doc "<p>Retrieves the list of your subscription schedules.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_schedules`\n"
(
@spec list(
params :: %{
optional(:canceled_at) => canceled_at | integer,
optional(:completed_at) => completed_at | integer,
optional(:created) => created | integer,
optional(:customer) => binary,
optional(:ending_before) => binary,
optional(:expand) => list(binary),
optional(:limit) => integer,
optional(:released_at) => released_at | integer,
optional(:scheduled) => boolean,
optional(:starting_after) => binary
},
opts :: Keyword.t()
) ::
{:ok, Stripe.List.t(Stripe.SubscriptionSchedule.t())}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def list(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/subscription_schedules", [], [])
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Retrieves the details of an existing subscription schedule. You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation.</p>\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_schedules/{schedule}`\n"
(
@spec retrieve(
schedule :: binary(),
params :: %{optional(:expand) => list(binary)},
opts :: Keyword.t()
) ::
{:ok, Stripe.SubscriptionSchedule.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def retrieve(schedule, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/subscription_schedules/{schedule}",
[
%{
__struct__: OpenApiGen.Blueprint.Parameter,
in: "path",
name: "schedule",
required: true,
schema: %{
__struct__: OpenApiGen.Blueprint.Parameter.Schema,
any_of: [],
items: [],
name: "schedule",
properties: [],
title: nil,
type: "string"
}
}
],
[schedule]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:get)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules`\n"
(
@spec create(
params :: %{
optional(:billing_mode) => billing_mode,
optional(:customer) => binary,
optional(:default_settings) => default_settings,
optional(:end_behavior) => :cancel | :none | :release | :renew,
optional(:expand) => list(binary),
optional(:from_subscription) => binary,
optional(:metadata) => %{optional(binary) => binary} | binary,
optional(:phases) => list(phases),
optional(:start_date) => integer | :now
},
opts :: Keyword.t()
) ::
{:ok, Stripe.SubscriptionSchedule.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def create(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/subscription_schedules", [], [])
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>Updates an existing subscription schedule.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules/{schedule}`\n"
(
@spec update(
schedule :: binary(),
params :: %{
optional(:default_settings) => default_settings,
optional(:end_behavior) => :cancel | :none | :release | :renew,
optional(:expand) => list(binary),
optional(:metadata) => %{optional(binary) => binary} | binary,
optional(:phases) => list(phases),
optional(:proration_behavior) => :always_invoice | :create_prorations | :none
},
opts :: Keyword.t()
) ::
{:ok, Stripe.SubscriptionSchedule.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def update(schedule, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/subscription_schedules/{schedule}",
[
%{
__struct__: OpenApiGen.Blueprint.Parameter,
in: "path",
name: "schedule",
required: true,
schema: %{
__struct__: OpenApiGen.Blueprint.Parameter.Schema,
any_of: [],
items: [],
name: "schedule",
properties: [],
title: nil,
type: "string"
}
}
],
[schedule]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>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 <code>not_started</code> or <code>active</code>.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules/{schedule}/cancel`\n"
(
@spec cancel(
schedule :: binary(),
params :: %{
optional(:expand) => list(binary),
optional(:invoice_now) => boolean,
optional(:prorate) => boolean
},
opts :: Keyword.t()
) ::
{:ok, Stripe.SubscriptionSchedule.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def cancel(schedule, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/subscription_schedules/{schedule}/cancel",
[
%{
__struct__: OpenApiGen.Blueprint.Parameter,
in: "path",
name: "schedule",
required: true,
schema: %{
__struct__: OpenApiGen.Blueprint.Parameter.Schema,
any_of: [],
items: [],
name: "schedule",
properties: [],
title: nil,
type: "string"
}
}
],
[schedule]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
(
nil
@doc "<p>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 <code>not_started</code> or <code>active</code>. If the subscription schedule is currently associated with a subscription, releasing it will remove its <code>subscription</code> property and set the subscription’s ID to the <code>released_subscription</code> property.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules/{schedule}/release`\n"
(
@spec release(
schedule :: binary(),
params :: %{
optional(:expand) => list(binary),
optional(:preserve_cancel_date) => boolean
},
opts :: Keyword.t()
) ::
{:ok, Stripe.SubscriptionSchedule.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def release(schedule, params \\ %{}, opts \\ []) do
path =
Stripe.OpenApi.Path.replace_path_params(
"/v1/subscription_schedules/{schedule}/release",
[
%{
__struct__: OpenApiGen.Blueprint.Parameter,
in: "path",
name: "schedule",
required: true,
schema: %{
__struct__: OpenApiGen.Blueprint.Parameter.Schema,
any_of: [],
items: [],
name: "schedule",
properties: [],
title: nil,
type: "string"
}
}
],
[schedule]
)
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
end