Stripe.Subscription (stripity_stripe v2.17.2) View Source
Work with Stripe subscription objects.
You can:
- Create a subscription
- Retrieve a subscription
- Update a subscription
- Delete a subscription
- Search subscriptions
Stripe API reference: https://stripe.com/docs/api#subscription
Link to this section Summary
Functions
Create a subscription.
Delete a subscription.
Takes the subscription id
or a Stripe.Subscription
struct.
Delete a subscription.
Takes the subscription id
or a Stripe.Subscription
struct.
Second argument can be a map of cancellation params
, such as invoice_now
,
or a list of options, such as custom API key.
Delete a subscription.
Takes the subscription id
or a Stripe.Subscription
struct.
Second argument is a map of cancellation params
, such as invoice_now
.
Third argument is a list of options, such as custom API key.
Deletes the discount on a subscription.
List all subscriptions.
Retrieve a subscription.
Search subscriptions
Update a subscription.
Link to this section Types
Specs
pause_collection() :: %{behavior: String.t(), resumes_at: Stripe.timestamp()}
Specs
Specs
pending_update() :: %{ billing_cycle_anchor: Stripe.timestamp(), expires_at: Stripe.timestamp(), subscription_items: [Stripe.SubscriptionItem.t()], trial_end: Stripe.timestamp(), trial_from_plan: boolean() }
Specs
t() :: %Stripe.Subscription{ application_fee_percent: float() | nil, automatic_tax: map(), billing_cycle_anchor: Stripe.timestamp() | nil, billing_thresholds: map() | nil, cancel_at: Stripe.timestamp() | nil, cancel_at_period_end: boolean(), canceled_at: Stripe.timestamp() | nil, collection_method: String.t() | nil, collection_method_cycle_anchor: Stripe.timestamp() | nil, collection_method_thresholds: Stripe.Types.collection_method_thresholds() | nil, created: Stripe.timestamp(), currency: String.t() | nil, 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(), next_pending_invoice_item_invoice: Stripe.timestamp() | nil, object: String.t(), pause_collection: pause_collection() | nil, pending_invoice_item_interval: pending_invoice_item_interval() | nil, pending_setup_intent: Stripe.SetupIntent.t() | nil, pending_update: pending_update() | nil, plan: Stripe.Plan.t() | nil, promotion_code: pause_collection() | nil, quantity: integer() | nil, schedule: String.t() | nil, start_date: Stripe.timestamp(), status: String.t(), tax_rate: term(), test_clock: term(), transfer_data: map(), trial_end: Stripe.timestamp() | nil, trial_start: Stripe.timestamp() | nil }
Link to this section Functions
Specs
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_cycle_anchor) => Stripe.timestamp(), optional(:billing_thresholds) => map(), optional(:collection_method) => String.t(), optional(:collection_method_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(), :items => [ %{ optional(:plan) => Stripe.id() | Stripe.Plan.t(), optional(:price) => Stripe.id() | Stripe.Price.t(), optional(:billing_methods) => map(), optional(:metadata) => map(), optional(:quantity) => non_neg_integer(), optional(:tax_rates) => list() } ], optional(:default_payment_method) => Stripe.id(), optional(:default_tax_rates) => [Stripe.id()], optional(:expand) => [String.t()], optional(:metadata) => Stripe.Types.metadata(), optional(:payment_behavior) => String.t(), optional(:prorate) => boolean(), optional(:proration_behavior) => String.t(), optional(:promotion_code) => Stripe.id(), optional(:tax_rate) => Stripe.id() | Stripe.TaxRate.t(), optional(:trial_end) => Stripe.timestamp() | :now, optional(:trial_from_plan) => boolean(), optional(:trial_period_days) => non_neg_integer() }
Create a subscription.
Specs
delete(Stripe.id() | t()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Delete a subscription.
Takes the subscription id
or a Stripe.Subscription
struct.
Specs
delete(Stripe.id() | t(), Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
delete(Stripe.id() | t(), params) :: {:ok, t()} | {:error, Stripe.Error.t()} when params: %{ optional(:invoice_now) => boolean(), optional(:prorate) => boolean() }
Delete a subscription.
Takes the subscription id
or a Stripe.Subscription
struct.
Second argument can be a map of cancellation params
, such as invoice_now
,
or a list of options, such as custom API key.
Specs
delete(Stripe.id() | t(), params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()} when params: %{ optional(:invoice_now) => boolean(), optional(:prorate) => boolean() }
Delete a subscription.
Takes the subscription id
or a Stripe.Subscription
struct.
Second argument is a map of cancellation params
, such as invoice_now
.
Third argument is a list of options, such as custom API key.
Specs
delete_discount(Stripe.id() | t(), Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Deletes the discount on a subscription.
Specs
list(params, Stripe.options()) :: {:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()} when params: %{ optional(:collection_method) => 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(:price) => Stripe.Price.t() | Stripe.id(), optional(:starting_after) => t() | Stripe.id(), optional(:status) => String.t() }
List all subscriptions.
Specs
retrieve(Stripe.id() | t(), Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Retrieve a subscription.
Specs
search(params, Stripe.options()) :: {:ok, Stripe.SearchResult.t(t())} | {:error, Stripe.Error.t()} when params: %{ :query => Stripe.search_query(), optional(:limit) => 1..100, optional(:page) => String.t() }
Search subscriptions
Specs
update(Stripe.id() | t(), params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()} when params: %{ optional(:application_fee_percent) => float(), optional(:billing_cycle_anchor) => Stripe.timestamp(), optional(:billing_thresholds) => map(), optional(:collection_method) => String.t(), optional(:collection_method_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) => [ %{ optional(:id) => Stripe.id() | binary(), optional(:plan) => Stripe.id() | Stripe.Plan.t(), optional(:price) => Stripe.id() | Stripe.Price.t(), optional(:billing_methods) => map(), optional(:metadata) => map(), optional(:quantity) => non_neg_integer(), optional(:tax_rates) => list() } ], optional(:default_payment_method) => Stripe.id(), optional(:default_tax_rates) => [Stripe.id()], optional(:metadata) => Stripe.Types.metadata(), optional(:pause_collection) => pause_collection(), optional(:prorate) => boolean(), optional(:proration_behavior) => String.t(), optional(:proration_date) => Stripe.timestamp(), optional(:tax_rate) => Stripe.id() | Stripe.TaxRate.t(), optional(:trial_end) => Stripe.timestamp() | :now, optional(:trial_from_plan) => boolean() }
Update a subscription.
Takes the id
and a map of changes.