Calculate tax for custom payment flows via Stripe's standalone Tax Calculations API.
Lifecycle
Create a calculation with create/3, inspect it with retrieve/3 or
list_line_items/4, then (within roughly 90 days, before expires_at)
record tax by creating a LatticeStripe.Tax.Transaction from the calculation ID.
Calculations are ephemeral working snapshots — they are not durable tax records.
Relationship to other tax surfaces
This module is not LatticeStripe.Invoice.AutomaticTax. Automatic tax on
Invoices, Subscriptions, and Quotes is configured via nested automatic_tax
settings on those Billing resources. Use this Calculations API when you own
the payment flow and need explicit tax amounts before charging. Filing,
returns, and threshold monitoring are out of SDK scope.
Usage
{:ok, calc} =
LatticeStripe.Tax.Calculation.create(client, %{
"currency" => "usd",
"customer_details" => %{
"address" => %{
"line1" => "123 Main St",
"city" => "Seattle",
"state" => "WA",
"postal_code" => "98101",
"country" => "US"
},
"address_source" => "shipping"
},
"line_items" => [
%{
"amount" => 1000,
"reference" => "line-1",
"tax_behavior" => "exclusive",
"tax_code" => "txcd_99999999"
}
]
})See Standalone Tax API for the canonical calculate → record → reverse workflow.
Summary
Functions
Creates a Tax Calculation.
Like create/3 but raises on failure.
Lists line items for a Tax Calculation.
Like list_line_items/4 but raises on failure.
Retrieves a Tax Calculation by ID.
Like retrieve/3 but raises on failure.
Types
@type t() :: %LatticeStripe.Tax.Calculation{ amount_total: integer() | nil, currency: String.t() | nil, customer: LatticeStripe.Customer.t() | String.t() | nil, customer_details: LatticeStripe.Tax.CustomerDetails.t() | nil, expires_at: integer() | nil, extra: map(), id: String.t() | nil, line_items: LatticeStripe.List.t() | nil, livemode: boolean() | nil, object: String.t(), ship_from_details: LatticeStripe.Tax.ShipFromDetails.t() | nil, shipping_cost: LatticeStripe.Tax.ShippingCost.t() | nil, tax_amount_exclusive: integer() | nil, tax_amount_inclusive: integer() | nil, tax_breakdown: [LatticeStripe.Tax.TaxBreakdown.t()] | nil, tax_date: integer() | nil }
Functions
@spec create(LatticeStripe.Client.t(), map(), keyword()) :: {:ok, t()} | {:error, LatticeStripe.Error.t()}
Creates a Tax Calculation.
@spec create!(LatticeStripe.Client.t(), map(), keyword()) :: t()
Like create/3 but raises on failure.
@spec list_line_items(LatticeStripe.Client.t(), String.t(), map(), keyword()) :: {:ok, LatticeStripe.Response.t()} | {:error, LatticeStripe.Error.t()}
Lists line items for a Tax Calculation.
@spec list_line_items!(LatticeStripe.Client.t(), String.t(), map(), keyword()) :: LatticeStripe.Response.t()
Like list_line_items/4 but raises on failure.
@spec retrieve(LatticeStripe.Client.t(), String.t(), keyword()) :: {:ok, t()} | {:error, LatticeStripe.Error.t()}
Retrieves a Tax Calculation by ID.
@spec retrieve!(LatticeStripe.Client.t(), String.t(), keyword()) :: t()
Like retrieve/3 but raises on failure.