If you cater to companies, it is easier. You ask for the VAT number and only if the company is from your own country, you add the VAT, otherwise its 0%.
If you cater to individuals, you need to use two different mechanisms to identify where the user is from (IP Address + Geo location and another one) and store this information, then you need to charge the VAT from that country and you need to signup for the EU Mini One Stop Shop (MoSS) with your local tax office, report your european VAT earnings quarterly.
Selling to a customer (business or individual) from outside the EU you can charge 0% VAT, so that is easy as well.
I recommend that you use either Recurly or Quaderno in combination with Stripe, because they generate the invoices for you and handle the VAT calculation perfectly.
I don't know about other countries than Germany (were we are located), but we also have to submit monthly VAT report to our tax office, all in all we pay our tax attorney 400-500 Euros per month, plus another 1000 for the yearly report. Maybe other EU countries allow startups to report quarterly or yearly? Idk.