class

Stripe::Coupon

Inherits OpenApi::Json < OpenApi::Validatable < JSON::Serializable::Unmapped < JSON::Serializable < Reference < Object

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.

Constants

ERROR_MESSAGE_FOR_DURATION = "invalid value for \"duration\", must be one of [forever, once, repeating]."
ERROR_MESSAGE_FOR_OBJECT = "invalid value for \"object\", must be one of [coupon]."
MAX_LENGTH_FOR_ID = 5000
MAX_LENGTH_FOR_NAME = 5000
VALID_VALUES_FOR_DURATION = String.static_array("forever", "once", "repeating")
VALID_VALUES_FOR_OBJECT = String.static_array("coupon")

Constructors

new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source
new(*, amount_off : Int64 | Nil = nil, created : Int64 | Nil = nil, currency : String | Nil = nil, duration : String | Nil = nil, duration_in_months : Int64 | Nil = nil, id : String | Nil = nil, livemode : Bool | Nil = nil, max_redemptions : Int64 | Nil = nil, metadata : Hash(String, String) | Nil = nil, name : String | Nil = nil, object : String | Nil = nil, percent_off : Float64 | Nil = nil, redeem_by : Int64 | Nil = nil, times_redeemed : Int64 | Nil = nil, valid : Bool | Nil = nil, applies_to : Stripe::CouponAppliesTo | Nil = nil, currency_options : Hash(String, Stripe::CouponCurrencyOption) | Nil = nil)

Initializes the object @param [Hash] attributes Model attributes in the form of hash

Source

Instance methods

==(other : self)

Generates #hash and #== methods from all fields #== @return [Bool] #hash calculates hash code according to all attributes. #hash @return [UInt64] Hash code

amount_off

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

Source
amount_off=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] amount_off Object to be assigned

Source
applies_to
Source
applies_to=(new_value : Stripe::CouponAppliesTo | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] applies_to Object to be assigned

Source
created

Time at which the object was created. Measured in seconds since the Unix epoch.

Source
created=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] created Object to be assigned

Source
currency

If amount_off has been set, the three-letter ISO code for the currency of the amount to take off.

Source
currency=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] currency Object to be assigned

Source
currency_options
Source
currency_options=(new_value : Hash(String, Stripe::CouponCurrencyOption) | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] currency_options Object to be assigned

Source
duration

One of forever, once, and repeating. Describes how long a customer who applies this coupon will get the discount.

Source
duration=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] duration Object to be assigned

Source
duration_in_months

If duration is repeating, the number of months the coupon applies. Null if coupon duration is forever or once.

Source
duration_in_months=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] duration_in_months Object to be assigned

Source
hash(hasher)

Generates #hash and #== methods from all fields #== @return [Bool] #hash calculates hash code according to all attributes. #hash @return [UInt64] Hash code

id

Unique identifier for the object.

Source
id=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] id Object to be assigned

Source
list_invalid_properties

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

Source
livemode

Has the value true if the object exists in live mode or the value false if the object exists in test mode.

Source
livemode=(new_value : Bool | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] livemode Object to be assigned

Source
max_redemptions

Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid.

Source
max_redemptions=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] max_redemptions Object to be assigned

Source
metadata
Source
metadata=(new_value : Hash(String, String) | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] metadata Object to be assigned

Source
name

Name of the coupon displayed to customers on for instance invoices or receipts.

Source
name=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] name Object to be assigned

Source
object

String representing the object's type. Objects of the same type share the same value.

Source
object=(new_value : String | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] object Object to be assigned

Source
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 $ (or local equivalent)100 invoice $ (or local equivalent)50 instead.

Source
percent_off=(new_value : Float64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] percent_off Object to be assigned

Source
redeem_by

Date after which the coupon can no longer be redeemed.

Source
redeem_by=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] redeem_by Object to be assigned

Source
times_redeemed

Number of times this coupon has been applied to a customer.

Source
times_redeemed=(new_value : Int64 | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] times_redeemed Object to be assigned

Source
valid

Taking account of the above properties, whether this coupon can still be applied to a customer.

Source
valid=(new_value : Bool | Nil)

Custom attribute writer method checking allowed values (enum). @param [Object] valid Object to be assigned

Source
valid?

Check to see if the all the properties in the model are valid @return true if the model is valid

Source