stripity_stripe v2.7.0 Stripe.Subscription View Source
Work with Stripe subscription objects.
You can:
- Create a subscription
- Retrieve a subscription
- Update a subscription
- Delete a subscription
Stripe API reference: https://stripe.com/docs/api#subscription
Link to this section Summary
Functions
Create a subscription.
Delete a subscription.
Delete a subscription.
DEPRECATED: Use Subscription.update/3
with cancel_at_period_end: true
instead.
Deletes the discount on a subscription.
List all subscriptions.
Retrieve a subscription.
Update a subscription.
Link to this section Types
t()
View Source
t() :: %Stripe.Subscription{
application_fee_percent: float() | nil,
billing: String.t() | nil,
billing_cycle_anchor: Stripe.timestamp() | nil,
billing_thresholds: Stripe.Types.subscription_billing_thresholds() | nil,
cancel_at: Stripe.timestamp() | nil,
cancel_at_period_end: boolean(),
canceled_at: Stripe.timestamp() | nil,
collection_method: String.t(),
created: Stripe.timestamp(),
current_period_end: Stripe.timestamp() | nil,
current_period_start: Stripe.timestamp() | nil,
customer: Stripe.id() | Stripe.Customer.t(),
days_until_due: integer() | nil,
default_payment_method: Stripe.id() | Stripe.PaymentMethod.t() | nil,
default_source: Stripe.id() | Stripe.Source.t() | nil,
default_tax_rates: [Stripe.TaxRate],
discount: Stripe.Discount.t() | nil,
ended_at: Stripe.timestamp() | nil,
id: Stripe.id(),
items: Stripe.List.t(Stripe.SubscriptionItem.t()),
latest_invoice: Stripe.id() | Stripe.Invoice.t() | nil,
livemode: boolean(),
metadata: Stripe.Types.metadata(),
object: String.t(),
pending_setup_intent: Stripe.SetupIntent.t() | nil,
plan: Stripe.Plan.t() | nil,
quantity: integer() | nil,
schedule: String.t() | nil,
start: Stripe.timestamp(),
start_date: Stripe.timestamp(),
status: String.t(),
tax_percent: float() | nil,
trial_end: Stripe.timestamp() | nil,
trial_start: Stripe.timestamp() | nil
}
t() :: %Stripe.Subscription{ application_fee_percent: float() | nil, billing: String.t() | nil, billing_cycle_anchor: Stripe.timestamp() | nil, billing_thresholds: Stripe.Types.subscription_billing_thresholds() | nil, cancel_at: Stripe.timestamp() | nil, cancel_at_period_end: boolean(), canceled_at: Stripe.timestamp() | nil, collection_method: String.t(), created: Stripe.timestamp(), current_period_end: Stripe.timestamp() | nil, current_period_start: Stripe.timestamp() | nil, customer: Stripe.id() | Stripe.Customer.t(), days_until_due: integer() | nil, default_payment_method: Stripe.id() | Stripe.PaymentMethod.t() | nil, default_source: Stripe.id() | Stripe.Source.t() | nil, default_tax_rates: [Stripe.TaxRate], discount: Stripe.Discount.t() | nil, ended_at: Stripe.timestamp() | nil, id: Stripe.id(), items: Stripe.List.t(Stripe.SubscriptionItem.t()), latest_invoice: Stripe.id() | Stripe.Invoice.t() | nil, livemode: boolean(), metadata: Stripe.Types.metadata(), object: String.t(), pending_setup_intent: Stripe.SetupIntent.t() | nil, plan: Stripe.Plan.t() | nil, quantity: integer() | nil, schedule: String.t() | nil, start: Stripe.timestamp(), start_date: Stripe.timestamp(), status: String.t(), tax_percent: float() | nil, trial_end: Stripe.timestamp() | nil, trial_start: Stripe.timestamp() | nil }
Link to this section Functions
create(params, opts \\ [])
View Source
create(params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
:customer => Stripe.id() | Stripe.Customer.t(),
optional(:application_fee_percent) => integer(),
optional(:billing) => String.t(),
optional(:billing_cycle_anchor) => Stripe.timestamp(),
optional(:cancel_at) => Stripe.timestamp(),
optional(:collection_method) => String.t(),
optional(:coupon) => Stripe.id() | Stripe.Coupon.t(),
optional(:days_until_due) => non_neg_integer(),
optional(:items) => [
%{
:plan => Stripe.id() | Stripe.Plan.t(),
optional(:quantity) => non_neg_integer()
}
],
optional(:metadata) => Stripe.Types.metadata(),
optional(:prorate) => boolean(),
optional(:tax_percent) => float(),
optional(:trial_end) => Stripe.timestamp(),
optional(:trial_from_plan) => boolean(),
optional(:trial_period_days) => non_neg_integer()
}
create(params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()} when params: %{ :customer => Stripe.id() | Stripe.Customer.t(), optional(:application_fee_percent) => integer(), optional(:billing) => String.t(), optional(:billing_cycle_anchor) => Stripe.timestamp(), optional(:cancel_at) => Stripe.timestamp(), optional(:collection_method) => String.t(), optional(:coupon) => Stripe.id() | Stripe.Coupon.t(), optional(:days_until_due) => non_neg_integer(), optional(:items) => [ %{ :plan => Stripe.id() | Stripe.Plan.t(), optional(:quantity) => non_neg_integer() } ], optional(:metadata) => Stripe.Types.metadata(), optional(:prorate) => boolean(), optional(:tax_percent) => float(), optional(:trial_end) => Stripe.timestamp(), optional(:trial_from_plan) => boolean(), optional(:trial_period_days) => non_neg_integer() }
Create a subscription.
delete(id)
View Source
delete(Stripe.id() | t()) :: {:ok, t()} | {:error, Stripe.Error.t()}
delete(Stripe.id() | t()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Delete a subscription.
Takes the subscription id
or a Stripe.Subscription
struct.
delete(id, opts)
View Source
delete(Stripe.id() | t(), %{at_period_end: true}) ::
{:ok, t()} | {:error, Stripe.Error.t()}
delete(Stripe.id() | t(), Stripe.options()) ::
{:ok, t()} | {:error, Stripe.Error.t()}
delete(Stripe.id() | t(), %{at_period_end: true}) :: {:ok, t()} | {:error, Stripe.Error.t()}
delete(Stripe.id() | t(), Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Delete a subscription.
Takes the subscription id
and an optional map of params
.
Deprecated Usage
Passing a map with at_period_end: true
to Subscription.delete/2
is deprecated. Use Subscription.update/2
with
cancel_at_period_end: true
instead.
delete(id, map, opts)
View Source
delete(Stripe.id() | t(), %{at_period_end: true}, Stripe.options()) ::
{:ok, t()} | {:error, Stripe.Error.t()}
delete(Stripe.id() | t(), %{at_period_end: true}, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
DEPRECATED: Use Subscription.update/3
with cancel_at_period_end: true
instead.
delete_discount(id, opts \\ [])
View Source
delete_discount(Stripe.id() | t(), Stripe.options()) ::
{:ok, t()} | {:error, Stripe.Error.t()}
delete_discount(Stripe.id() | t(), Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Deletes the discount on a subscription.
list(params \\ %{}, opts \\ [])
View Source
list(params, Stripe.options()) ::
{:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()}
when params: %{
optional(:billing) => String.t(),
optional(:created) => Stripe.date_query(),
optional(:customer) => Stripe.Customer.t() | Stripe.id(),
optional(:ending_before) => t() | Stripe.id(),
optional(:limit) => 1..100,
optional(:plan) => Stripe.Plan.t() | Stripe.id(),
optional(:starting_after) => t() | Stripe.id(),
optional(:status) => String.t()
}
list(params, Stripe.options()) :: {:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()} when params: %{ optional(:billing) => String.t(), optional(:created) => Stripe.date_query(), optional(:customer) => Stripe.Customer.t() | Stripe.id(), optional(:ending_before) => t() | Stripe.id(), optional(:limit) => 1..100, optional(:plan) => Stripe.Plan.t() | Stripe.id(), optional(:starting_after) => t() | Stripe.id(), optional(:status) => String.t() }
List all subscriptions.
retrieve(id, opts \\ [])
View Source
retrieve(Stripe.id() | t(), Stripe.options()) ::
{:ok, t()} | {:error, Stripe.Error.t()}
retrieve(Stripe.id() | t(), Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Retrieve a subscription.
update(id, params, opts \\ [])
View Source
update(Stripe.id() | t(), params, Stripe.options()) ::
{:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
optional(:application_fee_percent) => float(),
optional(:billing) => String.t(),
optional(:billing_cycle_anchor) => Stripe.timestamp(),
optional(:cancel_at) => Stripe.timestamp(),
optional(:cancel_at_period_end) => boolean(),
optional(:collection_method) => String.t(),
optional(:coupon) => Stripe.id() | Stripe.Coupon.t(),
optional(:days_until_due) => non_neg_integer(),
optional(:items) => [
%{
:plan => Stripe.id() | Stripe.Plan.t(),
optional(:quantity) => non_neg_integer()
}
],
optional(:metadata) => Stripe.Types.metadata(),
optional(:prorate) => boolean(),
optional(:proration_date) => Stripe.timestamp(),
optional(:tax_percent) => float(),
optional(:trial_end) => Stripe.timestamp(),
optional(:trial_from_plan) => boolean()
}
update(Stripe.id() | t(), params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()} when params: %{ optional(:application_fee_percent) => float(), optional(:billing) => String.t(), optional(:billing_cycle_anchor) => Stripe.timestamp(), optional(:cancel_at) => Stripe.timestamp(), optional(:cancel_at_period_end) => boolean(), optional(:collection_method) => String.t(), optional(:coupon) => Stripe.id() | Stripe.Coupon.t(), optional(:days_until_due) => non_neg_integer(), optional(:items) => [ %{ :plan => Stripe.id() | Stripe.Plan.t(), optional(:quantity) => non_neg_integer() } ], optional(:metadata) => Stripe.Types.metadata(), optional(:prorate) => boolean(), optional(:proration_date) => Stripe.timestamp(), optional(:tax_percent) => float(), optional(:trial_end) => Stripe.timestamp(), optional(:trial_from_plan) => boolean() }
Update a subscription.
Takes the id
and a map of changes.