Do not overwrite the customer profiles if Paypal doesn't return an address anyway

Created on 29 October 2014, almost 11 years ago
Updated 18 August 2025, 2 months ago

I have the following setting in my Paypal EC payment method:

Setting #1: Ask for a shipping address at PayPal if the order does not have one yet.
Setting #2: Update shipping customer profiles with address information the customer enters at PayPal.

I added some alterations so that the user won't be asked for any information related to shipping when they did not purchase anything that should be shipped [e.g., digital mp3s]

Since, I didn't ask for any shipping information even when going through Paypal (simply altered NOSHIPPING through hook_commerce_paypal_api_request_alter()), Paypal will not return any shipping info when Paypal EC performs GetExpressCheckoutDetails. Since Setting #2 is enabled, Paypal EC will create a profile anyway with empty values.

I suggest to not create a profile at all when Paypal doesn't return the address to prevent empty shipping informations to be created. Patch is attached.

I simply moved some code to create the address first, and if the address are just empty values, do not proceed with overwriting / creating the profile. I just moved the chunk where the new address is being built at the beginning and added an "override_address" flag.

πŸ’¬ Support request
Status

Closed: outdated

Version

2.0

Component

PayPal EC

Created by

πŸ‡¨πŸ‡¦Canada akosipax

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024