Scope
Can my line items in a subscription have different tax rates?
Can I apply tax rates as per the product type and generate an invoice?
Summary
Suppose you have different charges added to your subscription and you want each item line to have different tax rates, you can achieve that via API and have the invoice created with the tax rates applied.
Note: tax profiles must be created and you can apply tax only from the settings which are set on your tax profiles. Read more about tax profiles here
Solution
Step 1: Create the desired tax profile with the label tax and tax rate
For example, this country has 3 tax profiles.
And each tax profile has labeled tax and rates defined
Step 3: Use the API for creating invoices for items and one-time charges and pick the invoice attributes and tax attributes for the invoice
Step 4: Generate the invoice now for your charge and line items via API and give the amount for the tax rate as you have defined and the exact name matching to the label tax under your tax profiles.
For example: Here the secondary tax profile is used.
Step 5: Check for the invoice being generated and the tax applied to the line items