Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Even if "PayPal login page language" is set to other than "US" it always redirects to https://www.paypal.com/us/.
I tried it with several languages clearing the cookie of browsers.
Comment | File | Size | Author |
---|---|---|---|
#17 | uc_paypal.patch.txt | 650 bytes | alh |
#8 | 1586424-paypal-default-country-all.patch | 3.45 KB | longwave |
#7 | 1586424-paypal-default-country.patch | 574 bytes | longwave |
Comments
Comment #1
longwaveThe URL you quote is not hardcoded anywhere in Ubercart, and the lc parameter is sent correctly. If you are in the US, perhaps PayPal is performing geolocation and redirecting you based on your IP address? You should try accessing your site through a proxy server located in another country to see if you are redirected differently there.
Comment #2
chinita7 CreditAttribution: chinita7 commented@longwave Thanks for your response. I'm actually using it in Japan. I tried all the languages listed in "PayPal login page language" but always redirected to the US version.
The exact URL looks like
https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=Ut8Z3gAK2-u6F...
By the way, Is it difficult to hard-code it instead ? I would like to see if it's paypal side thing or not if possible. Which part of the code should I modify for example to make it to just "JP" ?
Comment #3
chinita7 CreditAttribution: chinita7 commentedI eventually paid somebody to fix this problem and he found out that paypal was taking the country of "Billing information".
As I had removed "Billing information" from the checkout pane it was always redirected to "US".
Comment #4
TR CreditAttribution: TR commentedCan you provide a patch?
Comment #5
chinita7 CreditAttribution: chinita7 commentedSorry actually there is no patch for this. I just enable the "billing information" pane and set the country to "JP" and then unset it on checkout page just to hide it.
"Sent address selection" in "PayPal Website Payments Standard settings" we are forced to choose one of two options "Send billing address to PayPal" or "Send shipping address to PayPal" and I guess this option should be removed or something..
Comment #6
longwaveAccording to http://blog.brains4all.com/brainblog/archives/2008/04/paypal_language.html this is a limitation in PayPal, if you send a country code as part of the address then PayPal uses this in preference to the language parameter.
However, uc_paypal currently defaults to 'US' if the country is not available for any reason. It seems to make sense to alter uc_paypal to send the store default country by default, and also drop the 'lc' parameter entirely.
Comment #7
longwaveThis one line patch should ensure that the store default country is used when the billing pane is disabled, instead of defaulting to the US.
Comment #8
longwaveThis patch removes the PayPal language setting entirely, as it doesn't work when we send the country. Instead, it defaults the country to the store country for all PayPal operations.
Comment #9
janton CreditAttribution: janton commentedbut why do we need to send paypal the country? could we not let paypal deside what country to use, because paypal has a well known idee what language to set the checkout page... (as far as i know paypal knows what language to set there checkout)
I now face this problem, because i have a multilanguage website, i get orders from people all around the world but i only have a english and dutch website... but i also have "Billing information" not enabled on checkout page... so i'm looking for a way to break this code out...
For example a French user is now also shown the US page, because my website is only in English and Dutch. But should paypal not be French then?
Comment #10
TR CreditAttribution: TR commentedMarked #2310037: Paypal Login Language as a duplicate.
Comment #11
TR CreditAttribution: TR commentedComment #12
Jean-Francois CreditAttribution: Jean-Francois commentedMy observations with localization on Paypal were as follow (with Ubercart 7.x-3.10):
Our place of business is Montreal, where language is French (FR), and country is Canada (CA).
The Ubercart data transmitted to PayPal can be seen in the PayPal pages HTML code (connexion page and payment page):
1) Setting the PayPal Website Payments Standard "Paypal login page language" (admin/store/settings/payment/method/paypal_wps) to FR sends the following code to PayPal: lc=FR
2) And that the address country field, filled by the customer on checkout sends the following code to PayPal: country=CA
This results in the PayPal UI being French as desired, but the customer's address country field on the PayPal payment page is populated with "France"!
PayPal overrides the customer provided country info with the locale code (I suggested to them that this is a problem).
Here is some of the confused code we find further on their pages as a result of this treatment of the cart data:
"geolocation": "CA"…
"ipcountry": "CA"…
"locality": {
___"country": "FR",
___"lang": "fr"…
"merchant_country": "CA"…
"merchant_locale": "FR"…
"currency": "CAD"…
"shipping_address": {
___"country_code": "CA"…
checkoutSessionLocale=FR&checkoutShippingCountry=CA&ipCountry=CA&merchantCountry=CA"…
I've been told by PayPal that in order to have French as language and Canada as country, the cart should send a 4 letters format localization code to distinguish language from country. In our case this would be "fr_CA" for French Canada.
Otherwise, with two letters locale code, my understanding is that the PayPal page defaults to the language support priority 0 of this code. In the case of FR, the 0 priority sets the locale code to "fr_FR", that is French as language, and France as country.
See their table in this PayPal developers info page:
https://developer.paypal.com/docs/classic/api/locale_codes/
Country.....Country Code.....Language Support Priority.....Locale Code
FRANCE.....FR...................0.......................................fr_FR
FRANCE.....FR...................1.......................................en_US
CANADA....CA...................0.......................................en_US
CANADA....CA...................1.......................................fr_CA
Could uc_paypal send an assembled 4 letters locale code, extracting data from the language of the Drupal site UI (set by the customer in his account) and from the address country info provided by the customer on checkout?
Comment #13
liquidcms CreditAttribution: liquidcms commentedI am not sure if the error here is with PayPal or Ubercart; but pretty sure the issue remains. I also want the country to default to Canada; but it appears to be set by Ubercart's "PayPal login page language"; which makes no sense since language does not equal country.
#12 above sounds like he has found the issue; but no fix. I also want default country to be Canada, but Ubercart has no setting for country; only for language. Language options are US or GB for different versions of English, these set country to match, US and UK respectively. Ubercart needs a separate selector for country.
Comment #14
liquidcms CreditAttribution: liquidcms commentedtried patch in #7 and #8, neither works to set country to the store country (Canada).
also, in #12, i can confirm this:
Country.....Country Code.....Language Support Priority.....Locale Code
FRANCE.....FR...................0.......................................fr_FR
FRANCE.....FR...................1.......................................en_US
CANADA....CA...................0.......................................en_US
CANADA....CA...................1.......................................fr_CA
but wondering how en_US will set to Canada; perhaps a typo on PayPal's developer page?
eventually i ended up just hacking in this line:
'lc' => 'en_CA',
in the uc_paypal_wps_form function to get this to work (for WPS).
so PP's dev page is incorrect stating en_US for Canada. Also, i think a bigger patch required for Ubercart to put in proper iso codes based on both store country setting (or pulled from order) and language selection.
Comment #15
TR CreditAttribution: TR commentedMost of this was covered in #12, but ...
PayPal's API mandates that we send a country code in order to set the PayPal language. So even if it doesn't make sense (and it doesn't), that's what PayPal needs. See https://www.paypal.com/us/smarthelp/article/how-do-i-change-the-default-... :
(emphasis added)
Likewise, see https://developer.paypal.com/docs/classic/api/locale_codes/#supported-lo... :
So you see even though we provide a locale code, that's only the second priority - the first is the shipping address country provided by the merchant. Again, this is discussed in #12, that this shipping country overrides the "language" setting in the locale code we provide.
And again from https://developer.paypal.com/docs/classic/api/locale_codes/#supported-lo... :
I don't think en_US is a typo, because it's used for ALL countries when English is a supported language. I think this is just because PayPal's API sucks.
Regardless,
Yes. Can you make that patch and post it here for review? It's not as simple as putting in the proper ISO codes, because that's not what PayPal uses and because the ISO codes are sometimes ignored in favor of other means of determining the locale, as per the above. Likewise, the patch needs to work in the typical case that the Ubercart site only supports one language (this is the Drupal default and by far the most common use case). In that case, there will be no per-user language information to send to PayPal - the only thing available will be the site language and the customer's ship-to country. And even in a site with multiple languages enabled, you can't send an arbitrary ISO code because PayPal doesn't support them all - then what do you do? Does PayPal have a 'reasonable' fallback for unrecognized codes, or does Ubercart need to provide an admin UI to map installed languages to PayPal-supported languages?
Also be aware that the merchant settings on PayPal.com also play a role here. Ubercart *does* have merchant country ship-from setting, and Drupal *does* have a site country setting, but PayPal also has merchant language and country settings which we can't see and which override what we send them in some cases.
Comment #16
TR CreditAttribution: TR commentedMarked #3043240: Paypal web site standard localization as a duplicate.
Comment #17
alh CreditAttribution: alh commentedTR asked us to post our comment and patch here.
We experienced a new problem with PayPal Payments Standard not recognizing the country or address details for customers when they wanted to pay by credit card. Ran in a few circles before we worked out a solution with PayPal. We are in Canada so we need to support both English and French customers. The solution we are using now:
For English customers: Set the localization variable "lc" to NULL. Nothing else worked for us. PayPal tells us that this setting for "lc" allows their geolocation system to work and determine the language. This works fine now although it is a bit odd as our VPS is in the US. But no complaints as long as it keeps on working. Country is recognized and the customer details are correctly populated by PayPal.
For French/Canadian customers: We set the localization variable "lc" to "fr_CA". This works perfectly as the country is now recognized as Canada and the language as French with the address fields populated correctly (even with UTF-8 used for characters with accents).
The patch file we are using is enclosed and as recommended by PayPal all 'official' localization codes per the documentation found here are available for selection:
https://developer.paypal.com/docs/classic/api/locale_codes/.
As you can see from the patch, there is localization option of NULL which forces PayPal to use their geolocation algorithm.
Hope this helps.