Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

On PayPal payment user shipping address gets set with uncorrect firstname and lastname values if they contain a space #226

Closed
mdesantis opened this issue Jun 6, 2019 · 6 comments · Fixed by #271

Comments

@mdesantis
Copy link
Contributor

mdesantis commented Jun 6, 2019

When a user pays with Braintree PayPal (vault flow), the authorization callback gets parsed by the JavaScript code, and then submitted to server. The PayPal authorization callback provides the shipping address with a single field for the user lastname and firstname, recipientName. The client side code tries to infer the firstname and the lastname splitting this recipientName by space:

first_name = payload_address.recipientName.split(" ")[0];
last_name = payload_address.recipientName.split(" ")[1];

The problem is that, if your name is for example Maurizio De Santis, the lastname will be set to Maurizio and the lastname to De, discarding the rest.

What's really wrong to me is that after that this shipping address value is submitted to the server, which updates the shipping address thus setting wrong values. But with the Braintree PayPal vault flow you can't change the shipping address via PayPal, so it's redundant to update it after the authorization call with the values that PayPal provides: the shipping address is the one that is already present on the server.

mdesantis added a commit to mdesantis/solidus_paypal_braintree that referenced this issue Jun 10, 2019
Closes solidusio#226. When PayPal sends the authorization response to the server,
it format the address with a single field the first name and the last
name, `recipientName`. We can’t safely infer the first name and the last
name from that field (see solidusio#226), so we have to skip the user address
updating. The good news is that the user address updating in this case
is redundant, since Solidus always requires the address to be set before
the payment happens, and such address is sent to PayPal with the
`shippingAddressEditable` configuration set to `false`, so the address
is necessarily the same as the one stored anyway.
mdesantis added a commit to mdesantis/solidus_paypal_braintree that referenced this issue Jun 10, 2019
Closes solidusio#226. When PayPal sends the authorization response to the server,
it format the address with a single field for the first name and the
last name, `recipientName`. We can’t safely infer the first name and the
last name from that field (see solidusio#226), so we have to skip the user
address updating. The good news is that the user address updating in
this case is redundant, since Solidus always requires the address to be
set before the payment happens, and such address is sent to PayPal with
the `shippingAddressEditable` configuration set to `false`, so the
address is necessarily the same as the one stored anyway.
@tvdeyen
Copy link
Member

tvdeyen commented Jun 10, 2019

A common issue I am very well aware of personally ;)

Solidus removed the presence validation of last_name long time ago. We should continue that work and rename the column to name in core and deprecate last_name.

Until then we should just store the full name as first_name

@mdesantis
Copy link
Contributor Author

@tvdeyen thank you for the information! so you would suggest to save recipientName into first_name?

mdesantis added a commit to mdesantis/solidus_paypal_braintree that referenced this issue Jun 10, 2019
Closes solidusio#226. When PayPal sends the authorization response to the server,
it format the address with a single field for the first name and the
last name, `recipientName`. We can’t safely infer the first name and the
last name from that field (see solidusio#226), so we have to skip the user
address updating. The good news is that the user address updating in
this case is redundant, since Solidus always requires the address to be
set before the payment happens, and such address is sent to PayPal with
the `shippingAddressEditable` configuration set to `false`, so the
address is necessarily the same as the one stored anyway.
@tvdeyen
Copy link
Member

tvdeyen commented Jun 10, 2019 via email

@kennyadsl
Copy link
Member

What about using https://github.com/basecamp/name_of_person instead?

@tvdeyen
Copy link
Member

tvdeyen commented Jun 20, 2019

@kennyadsl

From the README

Presenting names for English-language applications where a basic model of first and last name(s) combined is sufficient. This approach is not meant to cover all possible naming cases, deal with other languages, or even titulations. Just the basics.

🤷‍♂️

@kennyadsl
Copy link
Member

@tvdeyen Yeah, you are right, nevermind... I'm ok with storing everything in the first_name, one day we'll get rid of last_name at all.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants