Stripe.Coupon (stripity_stripe v2.17.3) View Source

Work with Stripe coupon objects.

You can:

  • Create a coupon
  • Retrieve a coupon
  • Update a coupon
  • Delete a coupon
  • list all coupons

Stripe API reference: https://stripe.com/docs/api#coupons

Link to this section Summary

Functions

Create a coupon.

Delete a coupon.

Retrieve a coupon.

Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.

Link to this section Types

Specs

t() :: %Stripe.Coupon{
  amount_off: pos_integer() | nil,
  applies_to: map() | nil,
  created: Stripe.timestamp(),
  currency: String.t() | nil,
  deleted: boolean() | nil,
  duration: String.t(),
  duration_in_months: pos_integer() | nil,
  id: Stripe.id(),
  livemode: boolean(),
  max_redemptions: pos_integer() | nil,
  metadata: Stripe.Types.metadata(),
  name: String.t() | nil,
  object: String.t(),
  percent_off: number() | nil,
  redeem_by: Stripe.timestamp() | nil,
  times_redeemed: non_neg_integer(),
  valid: boolean()
}

Link to this section Functions

Link to this function

create(params, opts \\ [])

View Source

Specs

create(params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       optional(:id) => String.t(),
       :duration => String.t(),
       optional(:amount_off) => pos_integer(),
       optional(:duration_in_months) => pos_integer(),
       optional(:currency) => String.t(),
       optional(:max_redemptions) => pos_integer(),
       optional(:metadata) => Stripe.Types.metadata(),
       optional(:name) => String.t(),
       optional(:percent_off) => number(),
       optional(:redeem_by) => Stripe.timestamp()
     }

Create a coupon.

Specs

delete(Stripe.id() | t(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Delete a coupon.

Link to this function

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

View Source

Specs

list(params, Stripe.options()) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()}
when params: %{
       optional(:created) => Stripe.date_query(),
       optional(:ending_before) => t() | Stripe.id(),
       optional(:limit) => 1..100,
       optional(:starting_after) => t() | Stripe.id()
     }

List all coupons.

Link to this function

retrieve(id, opts \\ [])

View Source

Specs

retrieve(Stripe.id() | t(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Retrieve a coupon.

Link to this function

update(id, params, opts \\ [])

View Source

Specs

update(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params:
       %{
         optional(:metadata) => Stripe.Types.metadata(),
         optional(:name) => String.t()
       }
       | %{}

Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.

Takes the id and a map of changes.