Search documentation of tiger_stripe

# Stripe.Services.CouponService (tiger_stripe v0.1.1)

Copy Markdown View Source

Coupon

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.

## Summary

### Functions

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

Create a coupon

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

Delete a coupon

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

List all coupons

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

Retrieve a coupon

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

Update a coupon

## Functions

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

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

Create a coupon

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 100 will have a final total of 0 if a coupon with an `amount_off` of 200 is applied to it and an invoice with a subtotal of 300 will have a final total of 100 if a coupon with an `amount_off` of 200 is applied to it.

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

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

Delete a coupon

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.

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

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

List all coupons

Returns a list of your coupons.

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

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

Retrieve a coupon

Retrieves the coupon with the given ID.

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

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

Update a coupon

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