Class PromotionCode

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

public class PromotionCode extends ApiResource implements HasId, MetadataStore<PromotionCode>
A Promotion Code represents a customer-redeemable code for a coupon. You can create multiple codes for a single coupon.

If you enable promotion codes in your customer portal configuration, then customers can redeem a code themselves when updating a subscription in the portal. Customers can also view the currently active promotion codes and coupons on each of their subscriptions in the portal.

  • Constructor Details

    • PromotionCode

      public PromotionCode()
  • Method Details

    • getCustomer

      public String getCustomer()
      Get ID of expandable customer object.
    • setCustomer

      public void setCustomer(String id)
    • getCustomerObject

      public Customer getCustomerObject()
      Get expanded customer.
    • setCustomerObject

      public void setCustomerObject(Customer expandableObject)
    • create

      public static PromotionCode create(Map<String,Object> params) throws StripeException
      A promotion code points to a coupon. You can optionally restrict the code to a specific customer, redemption limit, and expiration date.
      Throws:
      StripeException
    • create

      public static PromotionCode create(Map<String,Object> params, RequestOptions options) throws StripeException
      A promotion code points to a coupon. You can optionally restrict the code to a specific customer, redemption limit, and expiration date.
      Throws:
      StripeException
    • create

      public static PromotionCode create(PromotionCodeCreateParams params) throws StripeException
      A promotion code points to a coupon. You can optionally restrict the code to a specific customer, redemption limit, and expiration date.
      Throws:
      StripeException
    • create

      public static PromotionCode create(PromotionCodeCreateParams params, RequestOptions options) throws StripeException
      A promotion code points to a coupon. You can optionally restrict the code to a specific customer, redemption limit, and expiration date.
      Throws:
      StripeException
    • list

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

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

      Returns a list of your promotion codes.
      Throws:
      StripeException
    • list

      public static PromotionCodeCollection list(PromotionCodeListParams params, RequestOptions options) throws StripeException
      Returns a list of your promotion codes.
      Throws:
      StripeException
    • retrieve

      public static PromotionCode retrieve(String promotionCode) throws StripeException
      Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use list with the desired code.
      Throws:
      StripeException
    • retrieve

      public static PromotionCode retrieve(String promotionCode, RequestOptions options) throws StripeException
      Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use list with the desired code.
      Throws:
      StripeException
    • retrieve

      public static PromotionCode retrieve(String promotionCode, Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use list with the desired code.
      Throws:
      StripeException
    • retrieve

      public static PromotionCode retrieve(String promotionCode, PromotionCodeRetrieveParams params, RequestOptions options) throws StripeException
      Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use list with the desired code.
      Throws:
      StripeException
    • update

      public PromotionCode update(Map<String,Object> params) throws StripeException
      Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable.
      Specified by:
      update in interface MetadataStore<PromotionCode>
      Throws:
      StripeException
    • update

      public PromotionCode update(Map<String,Object> params, RequestOptions options) throws StripeException
      Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable.
      Specified by:
      update in interface MetadataStore<PromotionCode>
      Throws:
      StripeException
    • update

      Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable.
      Throws:
      StripeException
    • update

      public PromotionCode update(PromotionCodeUpdateParams params, RequestOptions options) throws StripeException
      Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable.
      Throws:
      StripeException
    • setResponseGetter

      public void setResponseGetter(StripeResponseGetter responseGetter)
      Minimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work).
      Specified by:
      setResponseGetter in interface StripeActiveObject
      Overrides:
      setResponseGetter in class ApiResource
      Parameters:
      responseGetter - the StripeResponseGetter instance to use for making further requests.
    • getActive

      public Boolean getActive()
      Whether the promotion code is currently active. A promotion code is only active if the coupon is also valid.
    • getCode

      public String getCode()
      The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), and digits (0-9).
    • getCoupon

      public Coupon getCoupon()
      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.
    • getCreated

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

      public String getCustomerAccount()
      The account that this promotion code can be used by.
    • getExpiresAt

      public Long getExpiresAt()
      Date at which the promotion code can no longer be redeemed.
    • 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 promotion code can be redeemed.
    • getObject

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

      Equal to promotion_code.

    • getRestrictions

      public PromotionCode.Restrictions getRestrictions()
    • getTimesRedeemed

      public Long getTimesRedeemed()
      Number of times this promotion code has been used.
    • setActive

      public void setActive(Boolean active)
      Whether the promotion code is currently active. A promotion code is only active if the coupon is also valid.
    • setCode

      public void setCode(String code)
      The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), and digits (0-9).
    • setCoupon

      public void setCoupon(Coupon 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.
    • setCreated

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

      public void setCustomerAccount(String customerAccount)
      The account that this promotion code can be used by.
    • setExpiresAt

      public void setExpiresAt(Long expiresAt)
      Date at which the promotion code can no longer be redeemed.
    • 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 promotion code can be redeemed.
    • 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.
    • setObject

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

      Equal to promotion_code.

    • setRestrictions

      public void setRestrictions(PromotionCode.Restrictions restrictions)
    • setTimesRedeemed

      public void setTimesRedeemed(Long timesRedeemed)
      Number of times this promotion code has been used.
    • 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<PromotionCode>