I am using Adyen's custom card integration to build a payment form. I would like to collect the user's billing address and pass it along to Adyen's Address Verification System.
According to that documentation, AVS expects to receive the billing address as an object with separate keys for the houseNumberOrName
and street
. However, I would like my front-end to have a form where users write their address with the house number/name and street in a combined input. I do not want to have a separate input for the house number. I feel that it is more customary, at least according to my experience. Here is an example of what I am trying to achieve, visually:
A payment form where the house number and street name are written in one input
Therefore I would like to have a reliable way to parse out the house number/name from the street name. To me this seems like a task more complicated than I personally could handle with regular expressions, because there are many different formats of addresses. I have tried a basic regular expression implementation to parse out the house number, which worked for addresses that I might consider to be "normal". But I could not think of a reliable regex pattern to match house names which seem much more freeform — not to mention some countries use street address formats that I might not be aware of.
# number + street name
123 Main St
# number with letter suffix
123A Main St
# street name featuring numbers
123 E 42nd St
# house number comes after street name
Rosenthalerstr. 12
# named house which has no house number nor street name
House of McGee
I am curious if anyone in the community is willing to share an implementation that they think was successful. I can't really think of any solutions to this problem beyond using a third party API like Google's Address Validation, which I'd rather avoid in order to save money.
If nothing else, I know I can just amend my design to have a separate inputs for house number/name and street name. Still I'd like to give this is a shot!
Many thanks