项目作者: mattes

项目描述 :
EU VAT number validation in Go using VIES SOAP service
高级语言: Go
项目地址: git://github.com/mattes/vat.git
创建时间: 2015-03-06T14:49:54Z
项目社区:https://github.com/mattes/vat

开源协议:The Unlicense

下载


Golang VAT number validation

Build Status
GoDoc

Uses the official VIES VAT number validation SOAP web service
to validate european VAT numbers.

Unfortunately their service is super unreliable.

Install

  1. go get -u github.com/mattes/vat

Usage with Go

  1. import "github.com/mattes/vat"
  2. response, err := vat.CheckVAT("IE6388047V")
  3. if err != nil {
  4. // do sth with err
  5. }
  6. fmt.Println(response.Name, response.Valid)
  7. // or ...
  8. valid, err := vat.IsValidVAT("IE6388047V")
  9. // increase timeout (default 10 seconds)
  10. vat.Timeout = 10
  11. // get VAT rates for EU countries
  12. rate, ok := vat.StandardRate("DE")
  13. // get applicable tax and if reverse charge is allowed,
  14. // depending on VAT number and country
  15. // (use at own risk!)
  16. rate, reverseCharge, err := GetApplicableTax("DE", "")
  17. rate, reverseCharge, err := GetApplicableTax("IE", "IE6388047V")
  18. rate, reverseCharge, err := GetApplicableTax("CH", "")

Usage via Console

There is a small cli included in this package.

Install with go get -u github.com/mattes/vat/vat-check

  1. $ vat-check IE6388047V
  2. Request date: 2015-03-06 00:00:00 +0100 CET
  3. VAT number: 6388047V
  4. Country: IE
  5. Name: GOOGLE IRELAND LIMITED
  6. Address: 3RD FLOOR ,GORDON HOUSE ,BARROW STREET ,DUBLIN 4
  7. Success: The VAT number is valid!

Exit code is 0 if VAT number is valid.