I know that this won't be the be all end all answer to this question. However, based on the information online there are no concrete answers in regards to how SaaS companies are taxed and where they pay their taxes too.
Same as any other entity (or person).
Entity pays taxes in it's domicile jurisdiction.
Best you talk with a tax preparer in your home country to ensure you have all the details.
And... If you're a US citizen + your SAAS company is generating massive cash, likely best to organize your entity in a low tax jurisdiction, like Bermuda which is home to Google, Intel, Verizon, etc.
And... best wait till Trump's new tax bill passes. If he has his way, corporate taxes may drop to a point low enough to keep your business in the US.
Great question, when it comes to business federal taxing they are taxed as any other but as a virtual service provider (non-physical) every state has a different law on that. The general idea is that some states don't have an import or sales tax law and or out of state law - so technically speaking you may have to file taxes completely differently than any other business out there because each state may vary.
If you end up having to send a tech to that area, you may have to to file especially for that state - I'm not a tax professional and you may have to talk to a tax expert in this field. One of the tax preparers I trust is Perla, she owns a bookkeeping & tax service - firstname.lastname@example.org
As an example, when I file taxes because provide consultancy services that are not physical or create software that does not transfer to any physical object I don't have to file separately on states unless I happen to send something to them - then I would have to file for that state.
One thing that is missing from other answers is cash vs accrual accounting. Cash accounting is typically only done by small businesses and ones that do not have the same timing challenges as a SaaS company. The largest difference is the cash received from a customer and the deferred revenue created. As a simple example... You have one customer who pays you $1 million on July 1 for 12 months of service. Let's further assume your operating expenses and cash paid for this 12 months of service is $700k (ratable monthly). As a cash payer would record in year 1, the taxable income of $650k and a loss of $350k in year 2. An accrual tax payer would have taxable income of $150k in both years. There are other financial statement impacts, from converting from cash and accrual accounting methods.
Taxes are assessed at 3 levels: federal, state, and municipal. We will disregard employment and sales taxes for these purposes. Broadly speaking, you will not have to pay full double taxation in two countries. The taxes paid to the foreign country will receive a credit or a deduction by your home country. Secondly, international sales can involve transfer pricing to a subsidiary which will impact the profitability in the foreign country. This is the point where you will want to consult a tax professional who is familiar with your product and the tax regulations of the countries you are doing business with.
Assuming you're talking about income tax and not sales tax etc it works like this.
1. All companies apply the tax rules of whatever country they are resident in, which usually means their worldwide income is taxable in that country this is true for SaaS and non-SaaS.
A company could be tax resident in multiple countries or none depending on local corporate residency rules and tax treaties.
2. Aside from this companies are a also taxable in local source income wherever they operate. This gets tricky especially for SaaS companies because "where is the income sourced?" this will usually be where the work is taking place if there's a fixed place of business or management level work taking place there but might also be taxed where the customers are located if the income is considered royalties income.
You've got to dive into the details of your individual case to see how these apply to you and of course it's in your best interest to structure yourself to minimize these.
There's also many cases where maybe technically you should be taxable but realistically you've got no exposure so in practice you won't be.
Finally, you could also be taxable based on the ownership of the company but this gets a little more technical.
Contrary to what was listed above Bermuda is rarely a good place to set up a SaaS company.
Hope that helps.