Stripe.Price (stripity_stripe v2.17.2) View Source
Work with Stripe price objects.
The Prices API adds more flexibility to how you charge customers.
It also replaces the Plans API, so Stripe recommends migrating your existing integration to work with prices.
To migrate, you need to identify how you use plans, products, and payment flows and then update these parts of your integration to use the Prices API.
Migrating to Prices guide: https://stripe.com/docs/billing/migration/migrating-prices
You can:
- Create a price
- Retrieve a price
- Update a price
- List all prices
- Search prices
Stripe API reference: https://stripe.com/docs/api/prices
Example:
{
"id": "plan_HJ8MK9HTYgniMM",
"object": "price",
"active": true,
"billing_scheme": "per_unit",
"created": 1589897226,
"currency": "usd",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"product": "prod_HJ8MOtuM1vD2jd",
"recurring": {
"aggregate_usage": null,
"interval": "month",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
"tax_behavior": "unspecified",
"tiers": null,
"tiers_mode": null,
"transform_lookup_key": false,
"transform_quantity": null,
"type": "recurring",
"unit_amount": 999,
"unit_amount_decimal": "999"
}
Link to this section Summary
Link to this section Types
Specs
Specs
Specs
recurring() :: %{ optional(:aggregate_usage) => String.t(), optional(:interval) => String.t(), optional(:interval_count) => pos_integer(), optional(:trial_period_days) => pos_integer(), optional(:usage_type) => String.t() }
Specs
t() :: %Stripe.Price{ active: boolean(), billing_scheme: String.t(), created: Stripe.timestamp(), currency: String.t(), id: Stripe.id(), livemode: boolean(), lookup_key: String.t(), metadata: Stripe.Types.metadata(), nickname: String.t(), object: String.t(), product: Stripe.id() | Stripe.Product.t(), recurring: recurring(), tax_behavior: String.t(), tiers: [price_tier()], tiers_mode: String.t(), transform_lookup_key: boolean(), transform_quantity: transform_quantity(), type: String.t(), unit_amount: pos_integer(), unit_amount_decimal: String.t() }
Specs
transform_quantity() :: %{divide_by: pos_integer(), round: String.t()}
Link to this section Functions
Specs
create(params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()} when params: %{ :currency => String.t(), optional(:unit_amount) => pos_integer(), optional(:active) => boolean(), optional(:metadata) => Stripe.Types.metadata(), optional(:nickname) => String.t(), optional(:product) => Stripe.id() | Stripe.Product.t(), optional(:product_data) => product_data(), optional(:recurring) => recurring(), optional(:tax_behavior) => String.t(), optional(:tiers) => [price_tier()], optional(:tiers_mode) => String.t(), optional(:billing_scheme) => String.t(), optional(:lookup_key) => String.t(), optional(:transfer_lookup_key) => boolean(), optional(:transform_quantity) => transform_quantity(), optional(:unit_amount_decimal) => String.t() } | %{}
Create a price.
Specs
list(params, Stripe.options()) :: {:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()} when params: %{ optional(:active) => boolean(), optional(:currency) => String.t(), optional(:product) => Stripe.Product.t() | Stripe.id(), optional(:type) => String.t(), optional(:created) => Stripe.timestamp(), optional(:ending_before) => t() | Stripe.id(), optional(:limit) => 1..100, optional(:lookup_keys) => [String.t()], optional(:recurring) => recurring() | nil, optional(:starting_after) => t() | Stripe.id() } | %{}
List all prices.
Specs
retrieve(Stripe.id() | t(), Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
Retrieve a price.
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 prices
Specs
update(Stripe.id() | t(), params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()} when params: %{ optional(:active) => boolean(), optional(:metadata) => Stripe.Types.metadata(), optional(:nickname) => String.t(), optional(:recurring) => recurring(), optional(:lookup_key) => String.t(), optional(:transfer_lookup_key) => boolean() } | %{}
Update a price.
Takes the id
and a map of changes.