Class: Stripe::Tax::Calculation

Inherits:
APIResource show all
Extended by:
APIOperations::Create
Defined in:
lib/stripe/resources/tax/calculation.rb

Overview

A Tax Calculation allows you to calculate the tax to collect from your customer.

Related guide: [Calculate tax in your custom payment flow](docs.stripe.com/tax/custom)

Defined Under Namespace

Classes: CustomerDetails, ShipFromDetails, ShippingCost, TaxBreakdown

Constant Summary collapse

OBJECT_NAME =
"tax.calculation"

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

Instance Method Summary collapse

Methods included from APIOperations::Create

create

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

#==, #[], #[]=, #_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

#amount_totalObject (readonly)

Total amount after taxes in the [smallest currency unit](docs.stripe.com/currencies#minor-units).



247
248
249
# File 'lib/stripe/resources/tax/calculation.rb', line 247

def amount_total
  @amount_total
end

#currencyObject (readonly)

Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).



249
250
251
# File 'lib/stripe/resources/tax/calculation.rb', line 249

def currency
  @currency
end

#customerObject (readonly)

The ID of an existing [Customer](docs.stripe.com/api/customers/object) used for the resource.



251
252
253
# File 'lib/stripe/resources/tax/calculation.rb', line 251

def customer
  @customer
end

#customer_detailsObject (readonly)

Attribute for field customer_details



253
254
255
# File 'lib/stripe/resources/tax/calculation.rb', line 253

def customer_details
  @customer_details
end

#expires_atObject (readonly)

Timestamp of date at which the tax calculation will expire.



255
256
257
# File 'lib/stripe/resources/tax/calculation.rb', line 255

def expires_at
  @expires_at
end

#idObject (readonly)

Unique identifier for the calculation.



257
258
259
# File 'lib/stripe/resources/tax/calculation.rb', line 257

def id
  @id
end

#line_itemsObject (readonly)

The list of items the customer is purchasing.



259
260
261
# File 'lib/stripe/resources/tax/calculation.rb', line 259

def line_items
  @line_items
end

#livemodeObject (readonly)

If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.



261
262
263
# File 'lib/stripe/resources/tax/calculation.rb', line 261

def livemode
  @livemode
end

#objectObject (readonly)

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



263
264
265
# File 'lib/stripe/resources/tax/calculation.rb', line 263

def object
  @object
end

#ship_from_detailsObject (readonly)

The details of the ship from location, such as the address.



265
266
267
# File 'lib/stripe/resources/tax/calculation.rb', line 265

def ship_from_details
  @ship_from_details
end

#shipping_costObject (readonly)

The shipping cost details for the calculation.



267
268
269
# File 'lib/stripe/resources/tax/calculation.rb', line 267

def shipping_cost
  @shipping_cost
end

#tax_amount_exclusiveObject (readonly)

The amount of tax to be collected on top of the line item prices.



269
270
271
# File 'lib/stripe/resources/tax/calculation.rb', line 269

def tax_amount_exclusive
  @tax_amount_exclusive
end

#tax_amount_inclusiveObject (readonly)

The amount of tax already included in the line item prices.



271
272
273
# File 'lib/stripe/resources/tax/calculation.rb', line 271

def tax_amount_inclusive
  @tax_amount_inclusive
end

#tax_breakdownObject (readonly)

Breakdown of individual tax amounts that add up to the total.



273
274
275
# File 'lib/stripe/resources/tax/calculation.rb', line 273

def tax_breakdown
  @tax_breakdown
end

#tax_dateObject (readonly)

The calculation uses the tax rules and rates that are in effect at this timestamp. You can use a date up to 31 days in the past or up to 31 days in the future. If you use a future date, Stripe doesn’t guarantee that the expected tax rules and rate being used match the actual rules and rate that will be in effect on that date. We deploy tax changes before their effective date, but not within a fixed window.



275
276
277
# File 'lib/stripe/resources/tax/calculation.rb', line 275

def tax_date
  @tax_date
end

Class Method Details

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

Calculates tax based on the input and returns a Tax Calculation object.



278
279
280
281
282
283
284
285
# File 'lib/stripe/resources/tax/calculation.rb', line 278

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

.field_remappingsObject



316
317
318
# File 'lib/stripe/resources/tax/calculation.rb', line 316

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



307
308
309
310
311
312
313
314
# File 'lib/stripe/resources/tax/calculation.rb', line 307

def self.inner_class_types
  @inner_class_types = {
    customer_details: CustomerDetails,
    ship_from_details: ShipFromDetails,
    shipping_cost: ShippingCost,
    tax_breakdown: TaxBreakdown,
  }
end

.list_line_items(calculation, params = {}, opts = {}) ⇒ Object

Retrieves the line items of a tax calculation as a collection, if the calculation hasn’t expired.



298
299
300
301
302
303
304
305
# File 'lib/stripe/resources/tax/calculation.rb', line 298

def self.list_line_items(calculation, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/tax/calculations/%<calculation>s/line_items", { calculation: CGI.escape(calculation) }),
    params: params,
    opts: opts
  )
end

.object_nameObject



13
14
15
# File 'lib/stripe/resources/tax/calculation.rb', line 13

def self.object_name
  "tax.calculation"
end

Instance Method Details

#list_line_items(params = {}, opts = {}) ⇒ Object

Retrieves the line items of a tax calculation as a collection, if the calculation hasn’t expired.



288
289
290
291
292
293
294
295
# File 'lib/stripe/resources/tax/calculation.rb', line 288

def list_line_items(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/tax/calculations/%<calculation>s/line_items", { calculation: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end