Class: Stripe::Discount

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

Overview

A discount represents the actual application of a [coupon](api.stripe.com#coupons) or [promotion code](api.stripe.com#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](docs.stripe.com/billing/subscriptions/discounts)

Defined Under Namespace

Classes: ServicePeriodDetails, Source

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

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #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.



45
46
47
# File 'lib/stripe/resources/discount.rb', line 45

def checkout_session
  @checkout_session
end

#customerObject (readonly)

The ID of the customer associated with this discount.



47
48
49
# File 'lib/stripe/resources/discount.rb', line 47

def customer
  @customer
end

#customer_accountObject (readonly)

The ID of the account representing the customer associated with this discount.



49
50
51
# File 'lib/stripe/resources/discount.rb', line 49

def 
  @customer_account
end

#deletedObject (readonly)

Always true for a deleted object



51
52
53
# File 'lib/stripe/resources/discount.rb', line 51

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.



53
54
55
# File 'lib/stripe/resources/discount.rb', line 53

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.



55
56
57
# File 'lib/stripe/resources/discount.rb', line 55

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.



57
58
59
# File 'lib/stripe/resources/discount.rb', line 57

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.



59
60
61
# File 'lib/stripe/resources/discount.rb', line 59

def invoice_item
  @invoice_item
end

#objectObject (readonly)

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



61
62
63
# File 'lib/stripe/resources/discount.rb', line 61

def object
  @object
end

#promotion_codeObject (readonly)

The promotion code applied to create this discount.



63
64
65
# File 'lib/stripe/resources/discount.rb', line 63

def promotion_code
  @promotion_code
end

#scheduleObject (readonly)

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



65
66
67
# File 'lib/stripe/resources/discount.rb', line 65

def schedule
  @schedule
end

#service_period_detailsObject (readonly)

Attribute for field service_period_details



67
68
69
# File 'lib/stripe/resources/discount.rb', line 67

def service_period_details
  @service_period_details
end

#sourceObject (readonly)

Attribute for field source



69
70
71
# File 'lib/stripe/resources/discount.rb', line 69

def source
  @source
end

#startObject (readonly)

Date that the coupon was applied.



71
72
73
# File 'lib/stripe/resources/discount.rb', line 71

def start
  @start
end

#subscriptionObject (readonly)

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



73
74
75
# File 'lib/stripe/resources/discount.rb', line 73

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.



75
76
77
# File 'lib/stripe/resources/discount.rb', line 75

def subscription_item
  @subscription_item
end

Class Method Details

.field_remappingsObject



81
82
83
# File 'lib/stripe/resources/discount.rb', line 81

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



77
78
79
# File 'lib/stripe/resources/discount.rb', line 77

def self.inner_class_types
  @inner_class_types = { service_period_details: ServicePeriodDetails, source: Source }
end

.object_nameObject



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

def self.object_name
  "discount"
end