Hi to all,
how can I define to PayPal login page language IL?
this option not Appears.>
Thanks/

Comments

ntigh52’s picture

Hi,
I added the il on:

commerce_paypal_wps.module

function commerce_paypal_wps_languages() {
  return drupal_map_assoc(array('AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'US', 'IL'));
}

tha , 'IL' in the end of array, and its work!
rszrama, Thanks again.

teebow’s picture

I run a multi language + multi currency website.

How can I get the module to send the visitors to the right PayPal WPS country site depending on the site language?
As of now, I believe we can only choose 1 PayPal screen language within the admin settings.

Basically, the URL differs depending on the country code specified within the URL:

Thanks

Toxid’s picture

@teebow,
You'd have to change the commerce_paypal_wps_server_url function into this:

<?php

function commerce_paypal_wps_server_url($server) {
  global $language ;
  $lang = strtoupper($language->language);
	
  switch ($server) {
    case 'sandbox':
      return 'https://www.sandbox.paypal.com/' . $lang . 'cgi-bin/webscr';
    case 'live':
      return 'https://www.paypal.com/' . $lang . 'cgi-bin/webscr';
  }
}
?>

Also, the settings for language appears to do nothing at this point. You'd have to do something like this to make the settings take effect:

<?php

function commerce_paypal_wps_server_url($server) {
  $pm = commerce_payment_method_instance_load('paypal_wps|commerce_payment_paypal_wps');
  $lang = $pm['settings']['language'];

  switch ($server) {
    case 'sandbox':
      return 'https://www.sandbox.paypal.com/' . $lang . 'cgi-bin/webscr';
    case 'live':
      return 'https://www.paypal.com/' . $lang . 'cgi-bin/webscr';
  }
}
?>
phirex’s picture

@Toxid
Hi, i'm also using a multi currency and multi lingual site.

I tried your code, but it doesnt work on my side. paypal login page is still selected from the lang menu..

Toxid’s picture

You're right, it seems that paypal only offers a limited amount of languages for login pages. If you try 'de' you get the german page. So it seems that the problem is on paypals end.

rszrama’s picture

Title: PayPal login page language » Change the login page language based on the user's current active language if possible
Category: support » feature

Yes, in fact I've just updated the list of supported languages and locales within the WPS module in this issue: [#]

You're not supposed to pass the parameter in via the URL but as part of the form (specifically the lc parameter). This only supports a subset of languages and locales, and those are now all represented as options on the settings form. As to the question above about selecting a different PayPal login page based on the current user's language, I think the best thing to do right now will be to alter the PayPal WPS parameters yourself using hook_commerce_paypal_wps_order_form_data_alter() (described in commerce_paypal_wps.api.php) to use whatever lc value you want based on your site's configuration.

I'm going to repurpose this as a feature request, though, to change the login page language based on the current user's language, but it's going to require more than a simple mapping of Drupal language codes since PayPal doesn't support every language and uses some customer 5 character codes for certain locales. We'll have to detect the current language, see if it maps to a known PayPal language, and change the lc parameter accordingly; otherwise we'll just leave it at the configured default login page language.

rszrama’s picture

Issue summary: View changes

1

guy_schneerson’s picture

Thanks @rszrama hook works perfectly for me.

For whoever is interested a simple example of changing the language to English

<?php
/**
 * Implements hook_commerce_paypal_wps_order_form_data_alter().
 */
function mymodule_commerce_paypal_wps_order_form_data_alter(&$data, $order) {
  global $language;
  if($language->language == 'en') {
    $data['lc'] = 'US';
  }
}
?>