viesService

package module
v0.0.0-...-e9cf509 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

README

VIES VAT Validation

Info

This is based on the official endpoint of EU. For more information look here The system no longer returns company names and other info. Just if the VAT is a valid VIES number.

Usage

Usage is simple

info, err := GetViesVatInfo(vatString)

if the vat string is not in the proper format you will get an error and the info.Valid = false. If the vat string is invalid, but the correct format, you will get info.Valid = false but no error.

Documentation

Index

Constants

View Source
const (
	// europeanViesEndpoint is the current default vies endpoint
	VIESEndpoint = "http://ec.europa.eu/taxation_customs/vies/services/checkVatService"
)

Variables

View Source
var (
	ErrorVatTooShort        = errors.New("VAT number is too short")
	ErrorInvalidCountryCode = errors.New("invalid country code")
)

Functions

This section is empty.

Types

type ErrorInfo

type ErrorInfo struct {
	FaultCode   string `xml:"faultcode"`
	FaultString string `xml:"faultstring"`
}

ValidationErrorResponse message for invalid responses from VIES

type VATInfo

type VATInfo struct {
	CountryCode string `xml:"countryCode"`
	VatNumber   string `xml:"vatNumber"`
	RequestDate string `xml:"requestDate"`
	Valid       bool   `xml:"valid"`
	Name        string `xml:"name"`
	Address     string `xml:"address"`
}

ValidationVAT Response message for valid responses from VIES

func GetViesVatInfo

func GetViesVatInfo(vat string) (VATInfo, error)

type XMLBody

type XMLBody struct {
	XMLName xml.Name
	VATInfo VATInfo   `xml:"checkVatResponse"`
	Error   ErrorInfo `xml:"Fault"`
}

body is the body of a response

type XMLResponse

type XMLResponse struct {
	XMLName xml.Name
	Body    XMLBody
}

XMLResponse is the response from the vies service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL