我们遇到过许多国家/地区提供的在线商店的问题。 人们输入他们的 - 例如 - 德国地址,并从下拉列表中选择一个不同的国家以获得更低的税率(按国家/地区计算的税率)。 我们需要一个验证器来检查给定的zip是否属于所选国家/地区。 有没有可以随时使用的可能性?
答案 0 :(得分:0)
What you need is some kind of address validation for international zip codes.
As a solution, you could use the International Address Validator API made by SmartyStreets. Here is the demo page to see how it might look.
Here is the documentation page with instructions on how to use the API.
You should go to the demo page linked above and see if your data will work well with it. You can enter an address in "free form" all on one line by changing one of the field dropdowns to "freeform". Or, you can enter the address information one field at a time, with "country" on one line, "postal code" on another line, and street address on "address1".
Also, remember, it is hard to make an API that works for multiple countries. Addresses can have very different formats in other countries. Because of that, I don't think you can search for a zip code alone. You have to search for an address with a zip code, and the validator can then tell you if the zip code is in that country.
Full disclosure: I work for SmartyStreets.