View Source Stripe.Coupon (Striped v0.5.0) (generated)
A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer. Coupons may be applied to subscriptions, invoices, checkout sessions, quotes, and more. Coupons do not work with conventional one-off charges or payment intents.
Link to this section Summary
Functions
You can create coupons easily via the coupon management page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly.
You can delete coupons via the coupon management page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can’t redeem the coupon. You can also delete coupons via the API.
Returns a list of your coupons.
Retrieves the coupon with the given ID.
Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
Link to this section Types
@type applies_to() :: %{optional(:products) => [binary()]}
A hash containing directions for what this Coupon will apply discounts to.
@type t() :: %Stripe.Coupon{ amount_off: integer() | nil, applies_to: term(), created: integer(), currency: binary() | nil, currency_options: term(), duration: binary(), duration_in_months: integer() | nil, id: binary(), livemode: boolean(), max_redemptions: integer() | nil, metadata: term() | nil, name: binary() | nil, object: binary(), percent_off: term() | nil, redeem_by: integer() | nil, times_redeemed: integer(), valid: boolean() }
The coupon
type.
amount_off
Amount (in thecurrency
specified) that will be taken off the subtotal of any invoices for this customer.applies_to
created
Time at which the object was created. Measured in seconds since the Unix epoch.currency
Ifamount_off
has been set, the three-letter ISO code for the currency of the amount to take off.currency_options
Coupons defined in each available currency option. Each key must be a three-letter ISO currency code and a supported currency.duration
One offorever
,once
, andrepeating
. Describes how long a customer who applies this coupon will get the discount.duration_in_months
Ifduration
isrepeating
, the number of months the coupon applies. Null if couponduration
isforever
oronce
.id
Unique identifier for the object.livemode
Has the valuetrue
if the object exists in live mode or the valuefalse
if the object exists in test mode.max_redemptions
Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid.metadata
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.name
Name of the coupon displayed to customers on for instance invoices or receipts.object
String representing the object's type. Objects of the same type share the same value.percent_off
Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a %s100 invoice %s50 instead.redeem_by
Date after which the coupon can no longer be redeemed.times_redeemed
Number of times this coupon has been applied to a customer.valid
Taking account of the above properties, whether this coupon can still be applied to a customer.
Link to this section Functions
@spec create( client :: Stripe.t(), params :: %{ optional(:amount_off) => integer(), optional(:applies_to) => applies_to(), optional(:currency) => binary(), optional(:currency_options) => map(), optional(:duration) => :forever | :once | :repeating, optional(:duration_in_months) => integer(), optional(:expand) => [binary()], optional(:id) => binary(), optional(:max_redemptions) => integer(), optional(:metadata) => %{optional(binary()) => binary()} | binary(), optional(:name) => binary(), optional(:percent_off) => number(), optional(:redeem_by) => integer() }, opts :: Keyword.t() ) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
You can create coupons easily via the coupon management page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly.
A coupon has either a percent_off
or an amount_off
and currency
. If you set an amount_off
, that amount will be subtracted from any invoice’s subtotal. For example, an invoice with a subtotal of amount_off
of amount_off
of
Details
- Method:
post
- Path:
/v1/coupons
@spec delete(client :: Stripe.t(), coupon :: binary(), opts :: Keyword.t()) :: {:ok, Stripe.DeletedCoupon.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
You can delete coupons via the coupon management page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can’t redeem the coupon. You can also delete coupons via the API.
Details
- Method:
delete
- Path:
/v1/coupons/{coupon}
@spec list( client :: Stripe.t(), params :: %{ optional(:created) => created() | integer(), optional(:ending_before) => binary(), optional(:expand) => [binary()], optional(:limit) => integer(), optional(:starting_after) => binary() }, opts :: Keyword.t() ) :: {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Returns a list of your coupons.
Details
- Method:
get
- Path:
/v1/coupons
@spec retrieve( client :: Stripe.t(), coupon :: binary(), params :: %{optional(:expand) => [binary()]}, opts :: Keyword.t() ) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Retrieves the coupon with the given ID.
Details
- Method:
get
- Path:
/v1/coupons/{coupon}
@spec update( client :: Stripe.t(), coupon :: binary(), params :: %{ optional(:currency_options) => map(), optional(:expand) => [binary()], optional(:metadata) => %{optional(binary()) => binary()} | binary(), optional(:name) => binary() }, opts :: Keyword.t() ) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
Details
- Method:
post
- Path:
/v1/coupons/{coupon}