stripity_stripe v1.6.0 Stripe.Coupons

Handles coupons to the Stripe API. (API ref: https://stripe.com/docs/api#coupons)

Operations:

  • create
  • retrieve
  • update (TODO)
  • delete (TODO)
  • list (TODO)

Summary

Functions

Creates a coupon with given options. :duration is required and must be either “forever”, “once”, or “repeating”. Returns a coupon if successful. Throws an error otherwise

Creates a coupon with given options using given API key. :duration is required and must be either “forever”, “once”, or “repeating”. Returns a coupon if successful. Throws an error otherwise

Retrieves the coupon with the given ID. Returns a coupon if a valid coupon ID was provided. Throws an error otherwise

Functions

create(opts \\ [])

Creates a coupon with given options. :duration is required and must be either “forever”, “once”, or “repeating”. Returns a coupon if successful. Throws an error otherwise.

Examples

  opts = [
    duration: "forever",
    id: "DISCOUNT20",
    percent_off: 25
  ]

  {:ok, result} = Stripe.Coupons.create opts
create(opts, key)

Creates a coupon with given options using given API key. :duration is required and must be either “forever”, “once”, or “repeating”. Returns a coupon if successful. Throws an error otherwise.

Examples

  opts = [
    duration: "forever",
    id: "DISCOUNT20",
    percent_off: 25
  ]

  {:ok, result} = Stripe.Coupons.create opts, key
retrieve(params)

Retrieves the coupon with the given ID. Returns a coupon if a valid coupon ID was provided. Throws an error otherwise.

Examples

  params = "free-1-month"

  {:ok, result} = Stripe.Coupons.retrieve params