Validating postal code
When writing out the postal address for a location within Canada, the postal code follows the abbreviation for the province or territory.In the late 1960s, however, the Post Office began implementing a three-digit zone number scheme in major cities to replace existing one and two-digit zone numbers, starting in Montreal, Toronto and Vancouver.While entering the Zip code, the customers will need to type it as 12345 or 12345-6789.If the input Zip code does not match with the system format, an error notification will appear.Armed with this new found knowledge and more, I opened up my editor and started coding.With a number of Ruby projects, ranging from Rails and Sinatra apps, to quick and dirty scripts, something flexible would be the most useful.If the zip check has failed, it's because the bank is telling the payment processor that the zip code does not match the one it has on file.
It was good start but validation was what we were really after, so it was off to Wikipedia to figure out postcode formats from around the world.
For people that are using Stripe as their payment processor, if the payment is being declined and you'd like you accept it, you may want to see if the “Decline charges that fail zip code validation” setting is on.
You can verify this from the Account Settings page in Stripe.
This means that they have to be written standalone without additional characters when they are not covered by the format.
Like British and Dutch postcodes, Canada's postal codes are alphanumeric.
If you're confident accepting payment from this customer when the zip/postal code doesn't match, you may wish to turn that option off temporarily to allow you to accept their payment.