Class Coupon

All Implemented Interfaces:
HasId, MetadataStore<Coupon>, StripeActiveObject, StripeObjectInterface

public class Coupon extends ApiResource implements HasId, MetadataStore<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.
  • Constructor Details

    • Coupon

      public Coupon()
  • Method Details

    • create

      public static Coupon create(Map<String,Object> params) throws StripeException
      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.

      Throws:
      StripeException
    • create

      public static Coupon create(Map<String,Object> params, RequestOptions options) throws StripeException
      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.

      Throws:
      StripeException
    • create

      public static Coupon create(CouponCreateParams params) throws StripeException
      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.

      Throws:
      StripeException
    • create

      public static Coupon create(CouponCreateParams params, RequestOptions options) throws StripeException
      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.

      Throws:
      StripeException
    • delete

      public Coupon delete() throws StripeException
      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.
      Throws:
      StripeException
    • delete

      public Coupon delete(RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • delete

      public Coupon delete(Map<String,Object> params) throws StripeException
      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.
      Throws:
      StripeException
    • delete

      public Coupon delete(Map<String,Object> params, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • list

      public static CouponCollection list(Map<String,Object> params) throws StripeException
      Returns a list of your coupons.
      Throws:
      StripeException
    • list

      public static CouponCollection list(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of your coupons.
      Throws:
      StripeException
    • list

      public static CouponCollection list(CouponListParams params) throws StripeException
      Returns a list of your coupons.
      Throws:
      StripeException
    • list

      public static CouponCollection list(CouponListParams params, RequestOptions options) throws StripeException
      Returns a list of your coupons.
      Throws:
      StripeException
    • retrieve

      public static Coupon retrieve(String coupon) throws StripeException
      Retrieves the coupon with the given ID.
      Throws:
      StripeException
    • retrieve

      public static Coupon retrieve(String coupon, RequestOptions options) throws StripeException
      Retrieves the coupon with the given ID.
      Throws:
      StripeException
    • retrieve

      public static Coupon retrieve(String coupon, Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieves the coupon with the given ID.
      Throws:
      StripeException
    • retrieve

      public static Coupon retrieve(String coupon, CouponRetrieveParams params, RequestOptions options) throws StripeException
      Retrieves the coupon with the given ID.
      Throws:
      StripeException
    • update

      public Coupon update(Map<String,Object> params) throws StripeException
      Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
      Specified by:
      update in interface MetadataStore<Coupon>
      Throws:
      StripeException
    • update

      public Coupon update(Map<String,Object> params, RequestOptions options) throws StripeException
      Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
      Specified by:
      update in interface MetadataStore<Coupon>
      Throws:
      StripeException
    • update

      public Coupon update(CouponUpdateParams params) throws StripeException
      Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
      Throws:
      StripeException
    • update

      public Coupon update(CouponUpdateParams params, RequestOptions options) throws StripeException
      Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
      Throws:
      StripeException
    • setResponseGetter

      public void setResponseGetter(StripeResponseGetter responseGetter)
      Description copied from interface: StripeActiveObject
      Method is used by the containing object or StripeResponseGetter implementations to set the StripeResponseGetter instance used to make further requests.
      Specified by:
      setResponseGetter in interface StripeActiveObject
      Overrides:
      setResponseGetter in class ApiResource
      Parameters:
      responseGetter - the StripeResponseGetter instance to use for making further requests.
    • getAmountOff

      public Long getAmountOff()
      Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer.
    • getAppliesTo

      public Coupon.AppliesTo getAppliesTo()
    • getCreated

      public Long getCreated()
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • getCurrency

      public String getCurrency()
      If amount_off has been set, the three-letter ISO code for the currency of the amount to take off.
    • getCurrencyOptions

      public Map<String,Coupon.CurrencyOption> getCurrencyOptions()
      Coupons defined in each available currency option. Each key must be a three-letter ISO currency code and a supported currency.
    • getDeleted

      public Boolean getDeleted()
      Always true for a deleted object.
    • getDuration

      public String getDuration()
      One of forever, once, and repeating. Describes how long a customer who applies this coupon will get the discount.
    • getDurationInMonths

      public Long getDurationInMonths()
      If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once.
    • getLivemode

      public Boolean getLivemode()
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • getMaxRedemptions

      public Long getMaxRedemptions()
      Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid.
    • getName

      public String getName()
      Name of the coupon displayed to customers on for instance invoices or receipts.
    • getObject

      public String getObject()
      String representing the object's type. Objects of the same type share the same value.

      Equal to coupon.

    • getPercentOff

      public BigDecimal getPercentOff()
      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 $ (or local equivalent)100 invoice $ (or local equivalent)50 instead.
    • getRedeemBy

      public Long getRedeemBy()
      Date after which the coupon can no longer be redeemed.
    • getTimesRedeemed

      public Long getTimesRedeemed()
      Number of times this coupon has been applied to a customer.
    • getValid

      public Boolean getValid()
      Taking account of the above properties, whether this coupon can still be applied to a customer.
    • setAmountOff

      public void setAmountOff(Long amountOff)
      Amount (in the currency specified) that will be taken off the subtotal of any invoices for this customer.
    • setAppliesTo

      public void setAppliesTo(Coupon.AppliesTo appliesTo)
    • setCreated

      public void setCreated(Long created)
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • setCurrency

      public void setCurrency(String currency)
      If amount_off has been set, the three-letter ISO code for the currency of the amount to take off.
    • setCurrencyOptions

      public void setCurrencyOptions(Map<String,Coupon.CurrencyOption> currencyOptions)
      Coupons defined in each available currency option. Each key must be a three-letter ISO currency code and a supported currency.
    • setDeleted

      public void setDeleted(Boolean deleted)
      Always true for a deleted object.
    • setDuration

      public void setDuration(String duration)
      One of forever, once, and repeating. Describes how long a customer who applies this coupon will get the discount.
    • setDurationInMonths

      public void setDurationInMonths(Long durationInMonths)
      If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once.
    • setId

      public void setId(String id)
      Unique identifier for the object.
    • setLivemode

      public void setLivemode(Boolean livemode)
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • setMaxRedemptions

      public void setMaxRedemptions(Long maxRedemptions)
      Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid.
    • setMetadata

      public void setMetadata(Map<String,String> 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.
    • setName

      public void setName(String name)
      Name of the coupon displayed to customers on for instance invoices or receipts.
    • setObject

      public void setObject(String object)
      String representing the object's type. Objects of the same type share the same value.

      Equal to coupon.

    • setPercentOff

      public void setPercentOff(BigDecimal percentOff)
      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 $ (or local equivalent)100 invoice $ (or local equivalent)50 instead.
    • setRedeemBy

      public void setRedeemBy(Long redeemBy)
      Date after which the coupon can no longer be redeemed.
    • setTimesRedeemed

      public void setTimesRedeemed(Long timesRedeemed)
      Number of times this coupon has been applied to a customer.
    • setValid

      public void setValid(Boolean valid)
      Taking account of the above properties, whether this coupon can still be applied to a customer.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Unique identifier for the object.
      Specified by:
      getId in interface HasId
    • getMetadata

      public Map<String,String> getMetadata()
      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.
      Specified by:
      getMetadata in interface MetadataStore<Coupon>