awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
868 stars 473 forks source link

United Kingdom "Billing State / Province" checkout option #7116

Open johnnybrackett opened 5 years ago

johnnybrackett commented 5 years ago

Bug Report

Expected behavior

When paying by credit card and selecting "United Kingdom" as the "Billing Country" I expected the "Billing State / Province" option to be a list of British counties. There is already a required field for "Billing City" and so it would probably be more appropriate to have the State/Province option be only counties, eg: West Midlands.

Actual behavior

Instead, it seems to be a mixture of some cities and some counties. Some notable counties which are missing are Berkshire, West Midlands, and East Midlands. An example UK address would be: Billing Address: 123 Example Road Billing Address 2: Wednesfield Postal Code: WV1 12A City: Wolverhampton County: West Midlands

Steps to reproduce the behavior

1) Checkout 2) Select "Credit Card" option 3) Select "United Kingdom" in Billing Country option 4) Select "Billing State / Province" option

Information (if a specific version is affected):

PHP Version:

EDD Version (or branch):

WordPress Version:

Any other relevant information:

Enhancement Request

Explain your enhancement (please be detailed)

Justification or use case

The current list of a combination of cities/counties seems confusing. We had a customer contact us today who was unable to find their county of "Berkshire" and so instead selected a nearby city from the list.

jnorth commented 5 years ago

A customer is reporting that they can't checkout because of their billing location. They are getting an "failed to validate postal code" message with RG7 8NE, which is in "Berkshire". They've tried using "Reading", but the same validation error is given.

We're using Stripe. The EDD Payment Errors log shows:

{"code":"incorrect_zip","doc_url":"https://stripe.com/docs/error-codes/incorrect-zip","message":"The zip code you supplied failed validation.","param":"address_zip","type":"card_error"}

System info:

### Begin System Info (Generated 2019-06-03 23:20:59) ###

-- Hosting Provider

Host:                     WP Engine
PHP Version:              7.2.17-1+ubuntu18.04.1+deb.sury.org+3

-- WordPress Configuration

Version:                  5.1.1
Language:                 en_US
Permalink Structure:      /blog/%postname%/
Active Theme:             Pixel Union 7.1.4
Show On Front:            page
Page On Front:            Home (#14)
Page For Posts:           State of the Union (#334)
ABSPATH:                  /nas/content/live/pixelunion/
Remote Post:              wp_remote_post() works
Table Prefix:             Length: 3   Status: Acceptable
WP_DEBUG:                 Disabled
Memory Limit:             40M
Registered Post Stati:    publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, refunded, failed, revoked, abandoned, processing, active, inactive, acf-disabled, preapproval, cancelled

-- EDD Configuration

Version:                  2.9.15
Upgraded From:            2.9.1
Test Mode:                Disabled
AJAX:                     Enabled
Guest Checkout:           Enabled
Symlinks:                 Disabled
Download Method:          Direct
Currency Code:            USD
Currency Position:        before
Decimal Separator:        .
Thousands Separator:      ,
Upgrades Completed:       upgrade_payment_taxes,upgrade_customer_payments_association,upgrade_user_api_keys,remove_refunded_sale_logs,stripe_customer_id_migration,update_file_download_log_data
Download Link Expiration: 72 hour(s)

-- EDD Gateway Configuration

Enabled Gateways:         Stripe
Default Gateway:          Stripe

-- EDD Tax Configuration

Taxes:                    Enabled
Tax Rate:                 5
Display On Checkout:      Displayed
Prices Include Tax:       No
Country / State Rates:    
                          Country: CA, State: BC, Rate: 5
cklosowski commented 5 years ago

@jnorth this seems unrelated and is our of EDD's control. That's due to the face that you have postal code validation enabled within your Stripe account, but they are telling EDD it is invalid.

jnorth commented 5 years ago

We're not wanting to disable postal code validation, but it definitely could be an issue between the customer and the bank not having the same address on file.

We went the route of doing a manual invoice on Stripe and a manual purchase on EDD.

The only thing I'm left wondering is if it would have worked if EDD exposed Berkshire as a possible state, but looking at the ISO 3166-2 list it seems like that might not make sense either.

We have successful payments with other UK addresses, so we're good for now, thanks!

jnorth commented 5 years ago

We're still seeing higher than usual validation errors for UK customers.

One thing I'm noticing is that the card_state select options on the billing address are prefixed with GB- for UK states, but not for states in other countries. For example, Alberta Canada is AB while Aberdeen City is GB-ABE. The ISO 3166-2 lists for both include the prefixes (Canada, GB).

One merchant I'm talking to lives in Leighton Buzzard which is a city in the county of Bedfordshire. Wikipedia says: Bedfordshire is a county in the East of England. It is a ceremonial county and a historic county, covered by three unitary authorities: Bedford, Central Bedfordshire, and Luton.

Where my knowledge gets fuzzy is how all these regional concepts break down... Our checkout form has those three "unitary authorities" listed. But if the merchant says they live in Bedfordshire, and their bank agrees, who am I to contradict them?

An alternative approach I'd be willing to try is to have a plain text input for the UK—is that possible?

cklosowski commented 5 years ago

@jnorth Are the users with the Leighton Buzzard/Bedfordshire issues getting the same postal error message or are they getting a different error message?

If the error is still the postal code issue, Stripe doesn't use the address information other than postal code to make that determination for the error. If there is another error message for declining it could be something different.

To use an empty text field you could use something like this to see if that changes things:

function eddwp_change_states_fields( $states ) {
    return array();
}
add_filter( 'edd_united_kingdom_states', 'eddwp_change_states_fields', 10, 1 );
jnorth commented 5 years ago

@cklosowski Thanks again for the follow up. These payment attempts are also returning the incorrect_zip error, so it sounds like the state wouldn't affect them.

Thanks for the snippet—we might use that in either case since customers are also getting confused by the list.

tlartaud commented 5 years ago

Same issue here with some UK customers.

cklosowski commented 5 years ago

@tlartaud I'm not sure how we can resolve a postal code validation error on Stripe's end. We are simply passing the postal code to Stripe and they are doing the verification with the bank. The other address fields are not used in the postal code validation. My advise would be to contact Stripe and see why this postal code is returning as invalid for the customer.

Since it's only happening to 'some' customers, that leads me to believe either there is a validation error on Stripe's end, or the customer simply is putting in the incorrect postal code.

johnnybrackett commented 5 years ago

Hey guys,

I have some further feedback regarding the UK Billing State/Province field from a different customer who used the EDD checkout on our site recently. I told them I'd pass it along:

I may have missed something, but it seems that the dropdown options for United Kingdom 'Billing State / Province' have been set up incorrectly. The only option for 'London' is ' 'London, City of'. The city of London is a small administative area - literally the original city of London, comprising the EC postal codes (EC1, EC2 etc). For billing requirements, just use 'London' which incorporates all post codes in London. In other words, delete ", City of" from your drop down options.

Looking at the value in the dropdown for the "London, City of" option it looks like the code is correct but the wording may just need to be changed to simply "London".

Thanks!

John