StripeElixir.Services.PlanService (stripe_elixir v0.1.0)

Copy Markdown View Source

Plan

You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.

Plans define the base price, currency, and billing cycle for recurring purchases of products. Products help you track inventory or provisioning, and plans help you track pricing. Different physical goods or levels of service should be represented by products, and pricing options should be represented by plans. This approach lets you change prices without having to change your provisioning scheme.

For example, you might have a single "gold" product that has plans for $10/month, $100/year, €9/month, and €90/year.

Related guides: Set up a subscription and more about products and prices.

Summary

Functions

create(client, params \\ %{}, opts \\ [])

@spec create(StripeElixir.Client.t(), map(), keyword()) ::
  {:ok, term()} | {:error, StripeElixir.Error.t()}

Create a plan

You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.

delete(client, plan, params \\ %{}, opts \\ [])

@spec delete(StripeElixir.Client.t(), String.t(), map(), keyword()) ::
  {:ok, term()} | {:error, StripeElixir.Error.t()}

Delete a plan

Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.

list(client, params \\ %{}, opts \\ [])

@spec list(StripeElixir.Client.t(), map(), keyword()) ::
  {:ok, term()} | {:error, StripeElixir.Error.t()}

List all plans

Returns a list of your plans.

retrieve(client, plan, params \\ %{}, opts \\ [])

@spec retrieve(StripeElixir.Client.t(), String.t(), map(), keyword()) ::
  {:ok, term()} | {:error, StripeElixir.Error.t()}

Retrieve a plan

Retrieves the plan with the given ID.

update(client, plan, params \\ %{}, opts \\ [])

@spec update(StripeElixir.Client.t(), String.t(), map(), keyword()) ::
  {:ok, term()} | {:error, StripeElixir.Error.t()}

Update a plan

Updates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan’s ID, amount, currency, or billing cycle.