Class: Stripe::TaxRate

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/tax_rate.rb

Overview

Tax rates can be applied to [invoices](stripe.com/docs/billing/invoices/tax-rates), [subscriptions](stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax.

Related guide: [Tax rates](stripe.com/docs/billing/taxes/tax-rates)

Defined Under Namespace

Classes: FlatAmount

Constant Summary collapse

OBJECT_NAME =
"tax_rate"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

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

#activeObject (readonly)

Defaults to ‘true`. When set to `false`, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set.



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

def active
  @active
end

#countryObject (readonly)

Two-letter country code ([ISO 3166-1 alpha-2](en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).



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

def country
  @country
end

#createdObject (readonly)

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



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

def created
  @created
end

#descriptionObject (readonly)

An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.



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

def description
  @description
end

#display_nameObject (readonly)

The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.



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

def display_name
  @display_name
end

#effective_percentageObject (readonly)

Actual/effective tax rate percentage out of 100. For tax calculations with automatic_tax=true, this percentage reflects the rate actually used to calculate tax based on the product’s taxability and whether the user is registered to collect taxes in the corresponding jurisdiction.



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

def effective_percentage
  @effective_percentage
end

#flat_amountObject (readonly)

The amount of the tax rate when the ‘rate_type` is `flat_amount`. Tax rates with `rate_type` `percentage` can vary based on the transaction, resulting in this field being `null`. This field exposes the amount and currency of the flat tax rate.



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

def flat_amount
  @flat_amount
end

#idObject (readonly)

Unique identifier for the object.



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

def id
  @id
end

#inclusiveObject (readonly)

This specifies if the tax rate is inclusive or exclusive.



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

def inclusive
  @inclusive
end

#jurisdictionObject (readonly)

The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer’s invoice.



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

def jurisdiction
  @jurisdiction
end

#jurisdiction_levelObject (readonly)

The level of the jurisdiction that imposes this tax rate. Will be ‘null` for manually defined tax rates.



44
45
46
# File 'lib/stripe/resources/tax_rate.rb', line 44

def jurisdiction_level
  @jurisdiction_level
end

#livemodeObject (readonly)

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



46
47
48
# File 'lib/stripe/resources/tax_rate.rb', line 46

def livemode
  @livemode
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



48
49
50
# File 'lib/stripe/resources/tax_rate.rb', line 48

def 
  @metadata
end

#objectObject (readonly)

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



50
51
52
# File 'lib/stripe/resources/tax_rate.rb', line 50

def object
  @object
end

#percentageObject (readonly)

Tax rate percentage out of 100. For tax calculations with automatic_tax=true, this percentage includes the statutory tax rate of non-taxable jurisdictions.



52
53
54
# File 'lib/stripe/resources/tax_rate.rb', line 52

def percentage
  @percentage
end

#rate_typeObject (readonly)

Indicates the type of tax rate applied to the taxable amount. This value can be ‘null` when no tax applies to the location.



54
55
56
# File 'lib/stripe/resources/tax_rate.rb', line 54

def rate_type
  @rate_type
end

#stateObject (readonly)

[ISO 3166-2 subdivision code](en.wikipedia.org/wiki/ISO_3166-2:US), without country prefix. For example, “NY” for New York, United States.



56
57
58
# File 'lib/stripe/resources/tax_rate.rb', line 56

def state
  @state
end

#tax_typeObject (readonly)

The high-level tax type, such as ‘vat` or `sales_tax`.



58
59
60
# File 'lib/stripe/resources/tax_rate.rb', line 58

def tax_type
  @tax_type
end

Class Method Details

.create(params = {}, opts = {}) ⇒ Object

Creates a new tax rate.



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

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/tax_rates", params: params, opts: opts)
end

.list(filters = {}, opts = {}) ⇒ Object

Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most recently created tax rates appearing first.



66
67
68
# File 'lib/stripe/resources/tax_rate.rb', line 66

def self.list(filters = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/tax_rates", params: filters, opts: opts)
end

.object_nameObject



14
15
16
# File 'lib/stripe/resources/tax_rate.rb', line 14

def self.object_name
  "tax_rate"
end

.update(id, params = {}, opts = {}) ⇒ Object

Updates an existing tax rate.



71
72
73
74
75
76
77
78
# File 'lib/stripe/resources/tax_rate.rb', line 71

def self.update(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/tax_rates/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end