Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False error when VIES return an error message #3

Closed
ntea opened this issue Oct 23, 2017 · 4 comments
Closed

False error when VIES return an error message #3

ntea opened this issue Oct 23, 2017 · 4 comments

Comments

@ntea
Copy link
Contributor

ntea commented Oct 23, 2017

When the VIES return an error message, this library return the error "service returned invalid request date".
That is not correct. It should return the error message returned by VIES.

You can correct it by changing the response structure by :
var rd struct {
XMLName xml.Name xml:"Envelope"
Soap struct {
XMLName xml.Name xml:"Body"
Soap struct {
XMLName xml.Name xml:"checkVatResponse"
CountryCode string xml:"countryCode"
VATnumber string xml:"vatNumber"
RequestDate string xml:"requestDate" // 2015-03-06+01:00
Valid bool xml:"valid"
Name string xml:"name"
Address string xml:"address"
}

		SoapFault struct {
			XMLName string `xml:"Fault"`
			Code    string `xml:"faultcode"`
			Message string `xml:"faultstring"`
		}
	}
}

And check the error after the unmarshal :
if rd.Soap.SoapFault.Message != "" {
return nil, errors.New("service returned an error : " + rd.Soap.SoapFault.Message)
}

@mattes
Copy link
Owner

mattes commented Oct 23, 2017

Thanks for bringing this up. Do you have time to work on a PR for this?

@ntea
Copy link
Contributor Author

ntea commented Oct 27, 2017

Hello,
Yes, I can make a PR with these changes if you give the rigths

@mattes
Copy link
Owner

mattes commented Oct 27, 2017

Great! Just fork and I will merge.

@mattes
Copy link
Owner

mattes commented Nov 2, 2017

closed by #4

@mattes mattes closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants