I wrote Python (<a href="https://github.com/wbond/vat_moss-python" rel="nofollow">https://github.com/wbond/vat_moss-python</a>) and JS (<a href="https://github.com/wbond/vat-moss.js" rel="nofollow">https://github.com/wbond/vat-moss.js</a>) libraries for this. They include docs about how to handle other aspects of VAT MOSS also.<p>Included are methods to determine the applicable rate based on self-declared location, billing address, phone number or IP address. The Python library includes functionality to grab exchange rates and perform VAT ID validation.