If this is your first visit, check our documentation. To post, register or login.
Forums / PayPal Express Checkout support / Empty state causes duplicate entry of city

Empty state causes duplicate entry of city

Locked

Started by simon1066 on 18 Jul 2020, 11:20 AM · Views: 3,213

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
18 Jul 2020, 11:20 AM
#1
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Empty state causes duplicate entry of city

ZCv1.56c
OPC v2.3.2

It doesn't feel like an OPC related issue.

Checking out, as a guest, I enter

Street Address
Address Line 2 [left blank]
City
County/State/Province [left blank]
Post/Zip Code
Country

In PayPal EC Checkout my selected address is

Street Address
City
County/State/Province
Post/Zip Code

On completing the order with PayPal and returning to Site I get this message:

The delivery address that you entered (Name, StreetAddress, City, , PostCode, Country) was replaced by the address you selected at PayPal. Please review your order and contact us if an update is needed.

Reviewing the order on the checkout_success page, the delivery address is:

Name
StreetAddress
City, City
PostCode
Country

The blank State field in the checkout process has been populated with a duplicate of City.

Simon

18 Jul 2020, 11:41 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,759
Plugin Contributions:
56

Re: Empty state causes duplicate entry of city

This might just be the browser's autofill doing this. Have you tried another browser ?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

18 Jul 2020, 11:54 AM
#3
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Empty state causes duplicate entry of city

There's no visual evidence of the State field being populated during checkout but I'll take from your post that it might the autofill my Dashlane password manager uses - I'll disable that (and try another browser).

Simon

19 Jul 2020, 3:53 PM
#4
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,904
Plugin Contributions:
23

Re: Empty state causes duplicate entry of city

I would think the bigger concern here is that the system accepts an address without the state since it is listed as required in guest checkout.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

19 Jul 2020, 3:57 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Empty state causes duplicate entry of city

Does it only happen with PayPal?
Does it only happen with UK addresses (vs a US one for example)? I wonder if the internal matching of the address returned by PayPal isn't finding a proper City-State-Country match and is filling in the city for an empty placeholder.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Jul 2020, 5:20 PM
#6
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Empty state causes duplicate entry of city

dbltoe:

I would think the bigger concern here is that the system accepts an address without the state since it is listed as required in guest checkout.

I believe that I made the state field optional - Minimum Values > State > Minimum length of state = [blank], I can't find any reference to it being 'required' in guest checkout.

Simon

19 Jul 2020, 5:33 PM
#7
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,904
Plugin Contributions:
23

Re: Empty state causes duplicate entry of city

This from 1.5.7 with OPC.

[Attachment no longer available]

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

19 Jul 2020, 5:47 PM
#8
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Empty state causes duplicate entry of city

DrByte:

Does it only happen with PayPal?
I'll do a Square test and see whether it's just PayPal.
DrByte:

Does it only happen with UK addresses (vs a US one for example)?
I could try a US PayPal shipping address I guess. This is the only time I've seen this - the majority of sales have been virtual orders without shipping addresses and it seems that the physical order customers (UK) did in fact enter their state(county) - typical!
DrByte:

I wonder if the internal matching of the address returned by PayPal isn't finding a proper City-State-Country match and is filling in the city for an empty placeholder.
To me that sounds like it could be the reason.

Simon

19 Jul 2020, 5:50 PM
#9
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Empty state causes duplicate entry of city

simon1066:

... and it seems that the physical order customers (UK) did in fact enter their state(county) - typical!

Probably a good reason to reinstate the State as being a required field.

Simon

19 Jul 2020, 5:54 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Empty state causes duplicate entry of city

simon1066:

This is the only time I've seen this - the majority of sales have been virtual orders without shipping addresses and it seems that the physical order customers (UK) did in fact enter their state(county) - typical!
Good point. I hadn't thought of virtual vs physical too.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Jul 2020, 6:01 PM
#11
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,904
Plugin Contributions:
23

Re: Empty state causes duplicate entry of city

simon1066:

I believe that I made the state field optional - Minimum Values > State > Minimum length of state = [blank], I can't find any reference to it being 'required' in guest checkout.Maybe I'm really missing the business model that says, "Remove the requirement for the customer to enter their state and then complain that PayPal doesn't give it to me on return." is the right way to go.
I'm surprised that PayPal doesn't throw at least a warning in this scenario. Are you not posting the PayPal check out button on the shopping cart?

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

19 Jul 2020, 6:04 PM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Empty state causes duplicate entry of city

@dbltoe ... have you worked much with UK addresses? There's no such thing as a "State" there.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Jul 2020, 6:09 PM
#13
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,904
Plugin Contributions:
23

Re: Empty state causes duplicate entry of city

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

19 Jul 2020, 6:13 PM
#14
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Empty state causes duplicate entry of city

dbltoe:

Maybe I'm really missing the business model that says, "Remove the requirement for the customer to enter their state and then complain that PayPal doesn't give it to me on return." is the right way to go.
I'm surprised that PayPal doesn't throw at least a warning in this scenario. Are you not posting the PayPal check out button on the shopping cart?

Yes, I guess there's no business model in that sense, I set up the no state feature ages ago - just to give customers one less field to enter. (perhaps most people use autofill these days). If I'm offering PayPal as an option then I guess I should really get the state during checkout.

I don't have the PayPal EC button - just PayPal as one of the payment options

Simon

26 Jul 2020, 5:44 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Empty state causes duplicate entry of city

@simon,

I may have found it.

In the PayPal Pro module I'd written this comment:

      // if State is not supplied, repeat the city so that it's not blank, otherwise PayPal croaks
      if ((!isset($optionsShip['SHIPTOSTATE']) || trim($optionsShip['SHIPTOSTATE']) == '') && isset($optionsShip['SHIPTOCITY'])) $optionsShip['SHIPTOSTATE'] = $optionsShip['SHIPTOCITY'];

... presumably because PayPal was rejecting orders that had no State filled in.

In the Express Checkout module the same logic is also present:```
// if State is not supplied, repeat the city so that it's not blank, otherwise PayPal croaks
if ((!isset($options['PAYMENTREQUEST_0_SHIPTOSTATE']) || trim($options['PAYMENTREQUEST_0_SHIPTOSTATE']) == '') && !empty($options['PAYMENTREQUEST_0_SHIPTOCITY'])) {
$options['PAYMENTREQUEST_0_SHIPTOSTATE'] = $options['PAYMENTREQUEST_0_SHIPTOCITY'];
}

... and later ...

'ship_state' => (isset($response['PAYMENTREQUEST_0_SHIPTOSTATE']) && $response['PAYMENTREQUEST_0_SHIPTOSTATE'] !='' ? urldecode($response['PAYMENTREQUEST_0_SHIPTOSTATE']) : urldecode($response['PAYMENTREQUEST_0_SHIPTOCITY'])),


When receiving the order back from PayPal and creating address-book entries for it, there's no checking to see whether the city and state are identical strings in order to revert the duplication.
Granted, it's not always true that an exact duplication is "wrong". Consider the city of "New York" in the state of "New York".
I suppose in the NY case though there's likely already a Zone for it, so maybe we could only blank-out the State if it matches the City and there's no Zone found for it? ZC only uses the State name if there's no zone match, so that'd probably be a safe cleanup.

I suppose the simple way to test whether the problem is still relevant is to change the logic to use an empty string instead of doing the city substitution, and see if the same order gives you any errors.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Jul 2020, 10:30 AM
#16
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Empty state causes duplicate entry of city

Thank you for looking into this more deeply. It's good to be able to identify the reason behind the duplication.

This is getting a tad complicated. I'll probably have to hold my hands up, opt for the easy way out, and reinstate the requirement for a state.

Simon