docs/stripe/7_stripe_tax.md
Collecting tax is easy with Stripe and Pay. You'll need to enable Stripe Tax in the dashboard and configure your Tax registrations where you're required to collect tax.
An address is required on the Customer for tax calculations.
class User < ApplicationRecord
pay_customer stripe_attributes: :stripe_attributes
def stripe_attributes(pay_customer)
{
address: {
country: "US",
postal_code: "90210"
}
}
end
end
To update the customer address anytime it's changed, call the following method:
@user.payment_processor.update_api_record
This will make an API request to update the Stripe::Customer with the current stripe_attributes.
See the Stripe Docs for more information about update tax addresses on a customer. https://stripe.com/docs/api/customers/update#update_customer-tax-ip_address
To enable tax for a subscription, you can pass in automatic_tax:
@user.payment_processor.subscribe(plan: "growth", automatic_tax: { enabled: true })
For Stripe Checkout, you can do the same thing:
@user.payment_processor.checkout(mode: "payment", line_items: "price_1234", automatic_tax: { enabled: true })
@user.payment_processor.checkout(mode: "subscription", line_items: "price_1234", automatic_tax: { enabled: true })
Taxes are saved on the Pay::Charge model.
tax - the total tax chargedtotal_tax_amounts - The tax rates for each jurisidction on the charge