Class: Stripe::Tax::Transaction

Inherits:
APIResource show all
Defined in:
lib/stripe/resources/tax/transaction.rb

Overview

A Tax Transaction records the tax collected from or refunded to your customer.

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

Defined Under Namespace

Classes: CreateFromCalculationParams, CreateReversalParams, CustomerDetails, ListLineItemsParams, RetrieveParams, Reversal, ShipFromDetails, ShippingCost

Constant Summary collapse

OBJECT_NAME =
"tax.transaction"

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 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

#createdObject (readonly)

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



250
251
252
# File 'lib/stripe/resources/tax/transaction.rb', line 250

def created
  @created
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).



252
253
254
# File 'lib/stripe/resources/tax/transaction.rb', line 252

def currency
  @currency
end

#customerObject (readonly)

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



254
255
256
# File 'lib/stripe/resources/tax/transaction.rb', line 254

def customer
  @customer
end

#customer_detailsObject (readonly)

Attribute for field customer_details



256
257
258
# File 'lib/stripe/resources/tax/transaction.rb', line 256

def customer_details
  @customer_details
end

#idObject (readonly)

Unique identifier for the transaction.



258
259
260
# File 'lib/stripe/resources/tax/transaction.rb', line 258

def id
  @id
end

#line_itemsObject (readonly)

The tax collected or refunded, by line item.



260
261
262
# File 'lib/stripe/resources/tax/transaction.rb', line 260

def line_items
  @line_items
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.



262
263
264
# File 'lib/stripe/resources/tax/transaction.rb', line 262

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.



264
265
266
# File 'lib/stripe/resources/tax/transaction.rb', line 264

def 
  @metadata
end

#objectObject (readonly)

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



266
267
268
# File 'lib/stripe/resources/tax/transaction.rb', line 266

def object
  @object
end

#posted_atObject (readonly)

The Unix timestamp representing when the tax liability is assumed or reduced.



268
269
270
# File 'lib/stripe/resources/tax/transaction.rb', line 268

def posted_at
  @posted_at
end

#referenceObject (readonly)

A custom unique identifier, such as ‘myOrder_123’.



270
271
272
# File 'lib/stripe/resources/tax/transaction.rb', line 270

def reference
  @reference
end

#reversalObject (readonly)

If ‘type=reversal`, contains information about what was reversed.



272
273
274
# File 'lib/stripe/resources/tax/transaction.rb', line 272

def reversal
  @reversal
end

#ship_from_detailsObject (readonly)

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



274
275
276
# File 'lib/stripe/resources/tax/transaction.rb', line 274

def ship_from_details
  @ship_from_details
end

#shipping_costObject (readonly)

The shipping cost details for the transaction.



276
277
278
# File 'lib/stripe/resources/tax/transaction.rb', line 276

def shipping_cost
  @shipping_cost
end

#tax_dateObject (readonly)

Timestamp of date at which the tax rules and rates in effect applies for the calculation.



278
279
280
# File 'lib/stripe/resources/tax/transaction.rb', line 278

def tax_date
  @tax_date
end

#typeObject (readonly)

If ‘reversal`, this transaction reverses an earlier transaction.



280
281
282
# File 'lib/stripe/resources/tax/transaction.rb', line 280

def type
  @type
end

Class Method Details

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

Creates a Tax Transaction from a calculation, if that calculation hasn’t expired. Calculations expire after 90 days.



283
284
285
286
287
288
289
290
# File 'lib/stripe/resources/tax/transaction.rb', line 283

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

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

Partially or fully reverses a previously created Transaction.



293
294
295
296
297
298
299
300
# File 'lib/stripe/resources/tax/transaction.rb', line 293

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

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

Retrieves the line items of a committed standalone transaction as a collection.



313
314
315
316
317
318
319
320
# File 'lib/stripe/resources/tax/transaction.rb', line 313

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

.object_nameObject



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

def self.object_name
  "tax.transaction"
end

Instance Method Details

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

Retrieves the line items of a committed standalone transaction as a collection.



303
304
305
306
307
308
309
310
# File 'lib/stripe/resources/tax/transaction.rb', line 303

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