Collect tax and pay out
Tax and payouts are settings on your Stripe account, not things you create per sale. Your account has exactly one set of tax settings and one payout schedule. Declaring them in your Stack keeps every stage’s account configured the same way.
Turn on Stripe Tax defaults
Section titled “Turn on Stripe Tax defaults”TaxSettings holds where your business is and how prices treat tax when
they don’t say:
import * as Alchemy from "alchemy";import * as Stripe from "@alchemy.run/stripe";import * as Effect from "effect/Effect";
export default Alchemy.Stack( "Billing", { providers: Stripe.providers(), state: Alchemy.localState() }, Effect.gen(function* () { yield* Stripe.TaxSettings("Tax", { headOffice: { address: { country: "US", state: "CA" } }, defaults: { taxBehavior: "exclusive", taxCode: "txcd_10103001" }, }); }),);Stripe never unsets these once they’re set. A price or product that sets
its own taxBehavior or taxCode overrides the default; see
Price your product.
Show your tax id on invoices
Section titled “Show your tax id on invoices”A tax id is your business’s VAT, GST or EIN number. Stripe prints it on invoices and receipts:
yield* Stripe.TaxId("Vat", { type: "eu_vat", value: "DE123456789" });Changing the value creates a new tax id and deletes the old one. A
customer’s own tax id is a CustomerTaxId instead.
Exempt a customer
Section titled “Exempt a customer”A customer’s billing address decides which tax applies, and taxExempt
can switch tax off for them or move it to the buyer with a reverse charge:
yield* Stripe.Customer("Acme", { email: "billing@acme.example", businessName: "Acme GmbH", address: { line1: "Hauptstraße 1", city: "Berlin", postalCode: "10115", country: "DE" }, taxExempt: "reverse",});Customers your app signs up while it runs are created with
Stripe.CreateCustomer(), which takes Stripe’s own field names
(address, tax_exempt).
Set the payout schedule
Section titled “Set the payout schedule”BalanceSettings decides when Stripe pays your balance out to your bank,
what the bank statement says, and how much to hold back:
yield* Stripe.BalanceSettings("Payouts", { payments: { payouts: { schedule: { interval: "weekly", weeklyPayoutDays: ["friday"] }, statementDescriptor: "ACME PAYOUT", minimumBalanceByCurrency: { usd: 10_000 }, }, },});Destroy puts it back
Section titled “Destroy puts it back”These settings belong to the account, so destroying the Stack doesn’t delete them. It writes back the values they had before the first deploy.
Only the fields you set are recorded and restored. A field that was empty before is cleared again where Stripe allows it, like the statement descriptor.