Class: Stripe::Discount

Inherits:
StripeObject show all
Defined in:
lib/stripe/resources/discount.rb

Overview

A discount represents the actual application of a [coupon](stripe.com/docs/api#coupons) or [promotion code](stripe.com/docs/api#promotion_codes). It contains information about when the discount began, when it will end, and what it is applied to.

Related guide: [Applying discounts to subscriptions](stripe.com/docs/billing/subscriptions/discounts)

Constant Summary collapse

OBJECT_NAME =
"discount"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#checkout_sessionObject (readonly)

The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode. Will not be present for subscription mode.



16
17
18
# File 'lib/stripe/resources/discount.rb', line 16

def checkout_session
  @checkout_session
end

#couponObject (readonly)

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](stripe.com/docs/api#subscriptions), [invoices](stripe.com/docs/api#invoices), [checkout sessions](stripe.com/docs/api/checkout/sessions), [quotes](stripe.com/docs/api#quotes), and more. Coupons do not work with conventional one-off [charges](stripe.com/docs/api#create_charge) or [payment intents](stripe.com/docs/api/payment_intents).



20
21
22
# File 'lib/stripe/resources/discount.rb', line 20

def coupon
  @coupon
end

#customerObject (readonly)

The ID of the customer associated with this discount.



22
23
24
# File 'lib/stripe/resources/discount.rb', line 22

def customer
  @customer
end

#deletedObject (readonly)

Always true for a deleted object



42
43
44
# File 'lib/stripe/resources/discount.rb', line 42

def deleted
  @deleted
end

#endObject (readonly)

If the coupon has a duration of ‘repeating`, the date that this discount will end. If the coupon has a duration of `once` or `forever`, this attribute will be null.



24
25
26
# File 'lib/stripe/resources/discount.rb', line 24

def end
  @end
end

#idObject (readonly)

The ID of the discount object. Discounts cannot be fetched by ID. Use ‘expand[]=discounts` in API calls to expand discount IDs in an array.



26
27
28
# File 'lib/stripe/resources/discount.rb', line 26

def id
  @id
end

#invoiceObject (readonly)

The invoice that the discount’s coupon was applied to, if it was applied directly to a particular invoice.



28
29
30
# File 'lib/stripe/resources/discount.rb', line 28

def invoice
  @invoice
end

#invoice_itemObject (readonly)

The invoice item ‘id` (or invoice line item `id` for invoice line items of type=’subscription’) that the discount’s coupon was applied to, if it was applied directly to a particular invoice item or invoice line item.



30
31
32
# File 'lib/stripe/resources/discount.rb', line 30

def invoice_item
  @invoice_item
end

#objectObject (readonly)

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



32
33
34
# File 'lib/stripe/resources/discount.rb', line 32

def object
  @object
end

#promotion_codeObject (readonly)

The promotion code applied to create this discount.



34
35
36
# File 'lib/stripe/resources/discount.rb', line 34

def promotion_code
  @promotion_code
end

#startObject (readonly)

Date that the coupon was applied.



36
37
38
# File 'lib/stripe/resources/discount.rb', line 36

def start
  @start
end

#subscriptionObject (readonly)

The subscription that this coupon is applied to, if it is applied to a particular subscription.



38
39
40
# File 'lib/stripe/resources/discount.rb', line 38

def subscription
  @subscription
end

#subscription_itemObject (readonly)

The subscription item that this coupon is applied to, if it is applied to a particular subscription item.



40
41
42
# File 'lib/stripe/resources/discount.rb', line 40

def subscription_item
  @subscription_item
end

Class Method Details

.object_nameObject



11
12
13
# File 'lib/stripe/resources/discount.rb', line 11

def self.object_name
  "discount"
end