// Context part 27
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7812 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -31,13 +31,11 @@ class PaypalExpress extends Paypal
|
||||
|
||||
public function getAuthorisation()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
// Getting cart informations
|
||||
$cart = new Cart((int)($cookie->id_cart));
|
||||
$cart = $this->context->cart;
|
||||
if (!Validate::isLoadedObject($cart))
|
||||
$this->_logs[] = $this->l('Not a valid cart');
|
||||
$currency = new Currency((int)($cart->id_currency));
|
||||
$currency = new Currency($cart->id_currency);
|
||||
if (!Validate::isLoadedObject($currency))
|
||||
$this->_logs[] = $this->l('Not a valid currency');
|
||||
|
||||
@@ -85,10 +83,8 @@ class PaypalExpress extends Paypal
|
||||
|
||||
public function getCustomerInfos()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
// Making request
|
||||
$request = '&TOKEN='.urlencode(strval($cookie->paypal_token));
|
||||
$request = '&TOKEN='.urlencode(strval($this->context->cookie->paypal_token));
|
||||
|
||||
// Calling PayPal API
|
||||
include(_PS_MODULE_DIR_.'paypal/api/paypallib.php');
|
||||
|
||||
@@ -38,13 +38,12 @@ if (!$paypal->active)
|
||||
|
||||
$ppExpress = new PaypalExpress();
|
||||
$errors = array();
|
||||
|
||||
// #####
|
||||
// Functions
|
||||
|
||||
function getAuthorization()
|
||||
{
|
||||
global $ppExpress, $cookie;
|
||||
global $ppExpress;
|
||||
|
||||
$result = $ppExpress->getAuthorisation();
|
||||
$logs = $ppExpress->getLogs();
|
||||
@@ -54,9 +53,9 @@ function getAuthorization()
|
||||
{
|
||||
if (isset($result['TOKEN']))
|
||||
{
|
||||
$cookie->paypal_token = strval($result['TOKEN']);
|
||||
$cookie->paypal_token_date = time();
|
||||
header('Location: https://'.$ppExpress->getPayPalURL().'/webscr&cmd=_express-checkout&token='.urldecode(strval($cookie->paypal_token)));
|
||||
Context::getContext()->cookie->paypal_token = strval($result['TOKEN']);
|
||||
Context::getContext()->cookie->paypal_token_date = time();
|
||||
header('Location: https://'.$ppExpress->getPayPalURL().'/webscr&cmd=_express-checkout&token='.urldecode(strval(Context::getContext()->cookie->paypal_token)));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@@ -70,7 +69,7 @@ function getAuthorization()
|
||||
|
||||
function getInfos()
|
||||
{
|
||||
global $ppExpress, $cookie;
|
||||
global $ppExpress;
|
||||
|
||||
$result = $ppExpress->getCustomerInfos();
|
||||
$logs = $ppExpress->getLogs();
|
||||
@@ -80,7 +79,7 @@ function getInfos()
|
||||
$logs[] = '<b>'.$ppExpress->l('Cannot retrieve PayPal account information', 'submit').'</b>';
|
||||
$ppExpress->displayPayPalAPIError($ppExpress->l('PayPal returned error', 'submit'), $logs);
|
||||
}
|
||||
elseif (!isset($result['TOKEN']) OR $result['TOKEN'] != $cookie->paypal_token)
|
||||
elseif (!isset($result['TOKEN']) OR $result['TOKEN'] != Context::getContext()->cookie->paypal_token)
|
||||
{
|
||||
$logs[] = '<b>'.$ppExpress->l('Token given by PayPal is not the same as the cookie token', 'submit').'</b>';
|
||||
$ppExpress->displayPayPalAPIError($ppExpress->l('PayPal returned error', 'submit'), $logs);
|
||||
@@ -90,18 +89,16 @@ function getInfos()
|
||||
|
||||
function displayProcess($payerID)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$cookie->paypal_token = strval($cookie->paypal_token);
|
||||
$cookie->paypal_payer_id = $payerID;
|
||||
Context::getContext()->cookie->paypal_token = strval(Context::getContext()->cookie->paypal_token);
|
||||
Context::getContext()->cookie->paypal_payer_id = $payerID;
|
||||
Tools::redirect('index.php?controller=order&step=1&back=paypal');
|
||||
}
|
||||
|
||||
function displayConfirm()
|
||||
{
|
||||
global $cookie, $smarty, $ppExpress, $cart, $payerID;
|
||||
global $ppExpress, $payerID;
|
||||
|
||||
if (!$cookie->isLogged(true))
|
||||
if (!Context::getContext()->cookie->isLogged(true))
|
||||
die('Not logged');
|
||||
if (!$payerID AND !$payerID = Tools::htmlentitiesUTF8(strval(Tools::getValue('payerID'))))
|
||||
die('No payer ID');
|
||||
@@ -109,13 +106,13 @@ function displayConfirm()
|
||||
// Display all and exit
|
||||
include(_PS_ROOT_DIR_.'/header.php');
|
||||
|
||||
$smarty->assign(array(
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'back' => 'paypal',
|
||||
'logo' => $ppExpress->getLogo(),
|
||||
'ppToken' => strval($cookie->paypal_token),
|
||||
'cust_currency' => $cart->id_currency,
|
||||
'currencies' => $ppExpress->getCurrency((int)$cart->id_currency),
|
||||
'total' => $cart->getOrderTotal(true, Cart::BOTH),
|
||||
'ppToken' => strval(Context::getContext()->cookie->paypal_token),
|
||||
'cust_currency' => Context::getContext()->cart->id_currency,
|
||||
'currencies' => $ppExpress->getCurrency((int)Context::getContext()->cart->id_currency),
|
||||
'total' => Context::getContext()->cart->getOrderTotal(true, Cart::BOTH),
|
||||
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'. $ppExpress->name.'/',
|
||||
'payerID' => $payerID,
|
||||
'mode' => 'express/'
|
||||
@@ -128,18 +125,18 @@ function displayConfirm()
|
||||
|
||||
function submitConfirm()
|
||||
{
|
||||
global $cookie, $smarty, $ppExpress, $cart;
|
||||
global $ppExpress;
|
||||
|
||||
if (!$cookie->isLogged(true))
|
||||
if (!Context::getContext()->cookie->isLogged(true))
|
||||
die('Not logged');
|
||||
elseif (!$currency = (int)(Tools::getValue('currency_payement')))
|
||||
die('No currency');
|
||||
elseif (!$payerID = Tools::htmlentitiesUTF8(strval(Tools::getValue('payerID'))))
|
||||
die('No payer ID');
|
||||
elseif (!$cart->getOrderTotal(true, Cart::BOTH))
|
||||
elseif (!Context::getContext()->cart->getOrderTotal(true, Cart::BOTH))
|
||||
die('Empty cart');
|
||||
|
||||
$ppExpress->makePayPalAPIValidation($cookie, $cart, $currency, $payerID, 'express');
|
||||
$ppExpress->makePayPalAPIValidation(Context::getContext()->cookie, Context::getContext()->cart, $currency, $payerID, 'express');
|
||||
}
|
||||
|
||||
function submitAccount()
|
||||
@@ -250,20 +247,20 @@ function submitLogin()
|
||||
|
||||
function displayLogin()
|
||||
{
|
||||
global $cookie, $result, $email, $payerID, $errors, $ppExpress, $smarty;
|
||||
global $result, $email, $payerID, $errors, $ppExpress;
|
||||
|
||||
// Customer exists, login form
|
||||
|
||||
// If customer already logged, check if same mail than PayPal, and go through, or unlog
|
||||
if ($cookie->isLogged(true) AND isset($result['EMAIL']) AND $cookie->email == $result['EMAIL'])
|
||||
if (Context::getContext()->cookie->isLogged(true) AND isset($result['EMAIL']) AND Context::getContext()->cookie->email == $result['EMAIL'])
|
||||
displayProcess($payerID);
|
||||
elseif ($cookie->isLogged(true))
|
||||
$cookie->makeNewLog();
|
||||
elseif (Context::getContext()->cookie->isLogged(true))
|
||||
Context::getContext()->cookie->makeNewLog();
|
||||
|
||||
// Smarty assigns
|
||||
$smarty->assign(array(
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'email' => $email,
|
||||
'ppToken' => strval($cookie->paypal_token),
|
||||
'ppToken' => strval(Context::getContext()->cookie->paypal_token),
|
||||
'errors'=> $errors,
|
||||
'payerID' => $payerID
|
||||
));
|
||||
@@ -277,13 +274,13 @@ function displayLogin()
|
||||
|
||||
function displayAccount()
|
||||
{
|
||||
global $cookie, $result, $email, $payerID, $errors, $ppExpress, $smarty;
|
||||
global $result, $email, $payerID, $errors, $ppExpress;
|
||||
|
||||
// Customer does not exists, signup form
|
||||
|
||||
// If customer already logged, unlog him
|
||||
if ($cookie->isLogged(true))
|
||||
$cookie->makeNewLog();
|
||||
if (Context::getContext()->cookie->isLogged(true))
|
||||
Context::getContext()->cookie->makeNewLog();
|
||||
|
||||
// Generate years, months and days
|
||||
if (isset($_POST['years']) AND is_numeric($_POST['years']))
|
||||
@@ -303,10 +300,10 @@ function displayAccount()
|
||||
{
|
||||
$selectedCountry = Country::getByIso(strval($result['COUNTRYCODE']));
|
||||
}
|
||||
$countries = Country::getCountries((int)($cookie->id_lang), true);
|
||||
$countries = Country::getCountries((int)(Context::getContext()->cookie->id_lang), true);
|
||||
|
||||
// Smarty assigns
|
||||
$smarty->assign(array(
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'years' => $years,
|
||||
'sl_year' => (isset($selectedYears) ? $selectedYears : 0),
|
||||
'months' => $months,
|
||||
@@ -322,7 +319,7 @@ function displayAccount()
|
||||
'city' => (Tools::getValue('city') ? Tools::htmlentitiesUTF8(strval(Tools::getValue('city'))) : (isset($result['SHIPTOCITY']) ? $result['SHIPTOCITY'] : '')),
|
||||
'zip' => (Tools::getValue('postcode') ? Tools::htmlentitiesUTF8(strval(Tools::getValue('postcode'))) : (isset($result['SHIPTOZIP']) ? $result['SHIPTOZIP'] : '')),
|
||||
'payerID' => $payerID,
|
||||
'ppToken' => strval($cookie->paypal_token),
|
||||
'ppToken' => strval(Context::getContext()->cookie->paypal_token),
|
||||
'errors'=> $errors
|
||||
));
|
||||
|
||||
@@ -335,16 +332,16 @@ function displayAccount()
|
||||
|
||||
// #####
|
||||
// Process !!
|
||||
/*if (!$cookie->isLogged(true))
|
||||
/*if (!Context::getContext()->cookie->isLogged(true))
|
||||
{
|
||||
displayAccount();
|
||||
die('Not logged');
|
||||
}*/
|
||||
if (!$cart->getOrderTotal(true, Cart::BOTH))
|
||||
if (!Context::getContext()->cart->getOrderTotal(true, Cart::BOTH))
|
||||
die('Empty cart');
|
||||
|
||||
// No token, we need to get one by making PayPal Authorisation
|
||||
if (!isset($cookie->paypal_token) OR !$cookie->paypal_token)
|
||||
if (!isset(Context::getContext()->cookie->paypal_token) OR !Context::getContext()->cookie->paypal_token)
|
||||
getAuthorization();
|
||||
else
|
||||
{
|
||||
@@ -361,10 +358,10 @@ else
|
||||
// We got an error or we still not submit form
|
||||
if ((!Tools::isSubmit('submitAccount') AND !Tools::isSubmit('submitLogin')) OR sizeof($errors))
|
||||
{
|
||||
if (isset($cookie->paypal_token) AND isset($cookie->paypal_token_date) AND (time() - 10800 > $cookie->paypal_token_date))
|
||||
if (isset(Context::getContext()->cookie->paypal_token) AND isset(Context::getContext()->cookie->paypal_token_date) AND (time() - 10800 > Context::getContext()->cookie->paypal_token_date))
|
||||
{
|
||||
// Token expired, unset it
|
||||
unset($cookie->paypal_token);
|
||||
unset(Context::getContext()->cookie->paypal_token);
|
||||
Tools::redirect('modules/paypal/express/submit.php');
|
||||
}
|
||||
// We didn't submit form, getting PayPal informations
|
||||
@@ -386,7 +383,7 @@ else
|
||||
else
|
||||
{
|
||||
// Error in token, we need to make authorization again
|
||||
unset($cookie->paypal_token);
|
||||
unset(Context::getContext()->cookie->paypal_token);
|
||||
Tools::redirect('modules/paypal/express/submit.php');
|
||||
}
|
||||
if (Customer::customerExists($email) OR Tools::isSubmit('submitLogin'))
|
||||
|
||||
@@ -36,8 +36,7 @@ class PaypalPayment extends Paypal
|
||||
|
||||
public function getAuthorisation()
|
||||
{
|
||||
global $cookie, $cart;
|
||||
|
||||
$cart = Context::getContext()->cart;
|
||||
// Getting cart informations
|
||||
$currency = new Currency((int)($cart->id_currency));
|
||||
if (!Validate::isLoadedObject($currency))
|
||||
|
||||
@@ -46,7 +46,7 @@ $errors = array();
|
||||
|
||||
function getAuthorization()
|
||||
{
|
||||
global $ppPayment, $cookie, $cart;
|
||||
global $ppPayment;
|
||||
|
||||
$result = $ppPayment->getAuthorisation();
|
||||
$logs = $ppPayment->getLogs();
|
||||
@@ -56,9 +56,9 @@ function getAuthorization()
|
||||
{
|
||||
if (isset($result['TOKEN']))
|
||||
{
|
||||
$cookie->paypal_token = strval($result['TOKEN']);
|
||||
$cookie->paypal_token_date = time();
|
||||
header('Location: https://'.$ppPayment->getPayPalURL().'/webscr&cmd=_express-checkout&token='.urldecode(strval($cookie->paypal_token)).'&useraction=commit');
|
||||
Context::getContext()->cookie->paypal_token = strval($result['TOKEN']);
|
||||
Context::getContext()->cookie->paypal_token_date = time();
|
||||
header('Location: https://'.$ppPayment->getPayPalURL().'/webscr&cmd=_express-checkout&token='.urldecode(strval(Context::getContext()->cookie->paypal_token)).'&useraction=commit');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@@ -71,31 +71,31 @@ function getAuthorization()
|
||||
|
||||
function displayConfirm()
|
||||
{
|
||||
global $cookie, $smarty, $ppPayment, $cart;
|
||||
global $ppPayment;
|
||||
|
||||
if (!$cookie->isLogged(true))
|
||||
if (!Context::getContext()->cookie->isLogged(true))
|
||||
{
|
||||
header('location:../../../'); exit;
|
||||
die('Not logged');
|
||||
}
|
||||
unset($cookie->paypal_token);
|
||||
unset(Context::getContext()->cookie->paypal_token);
|
||||
|
||||
if ($cart->id_currency != $ppPayment->getCurrency((int)$cart->id_currency)->id)
|
||||
if (Context::getContext()->cart->id_currency != $ppPayment->getCurrency((int)Context::getContext()->cart->id_currency)->id)
|
||||
{
|
||||
$cart->id_currency = (int)($ppPayment->getCurrency((int)$cart->id_currency)->id);
|
||||
$cookie->id_currency = (int)($cart->id_currency);
|
||||
$cart->update();
|
||||
Context::getContext()->cart->id_currency = (int)($ppPayment->getCurrency((int)Context::getContext()->cart->id_currency)->id);
|
||||
Context::getContext()->cookie->id_currency = (int)(Context::getContext()->cart->id_currency);
|
||||
Context::getContext()->cart->update();
|
||||
Tools::redirect('modules/'.$ppPayment->name.'/payment/submit.php');
|
||||
}
|
||||
|
||||
// Display all and exit
|
||||
include(_PS_ROOT_DIR_.'/header.php');
|
||||
|
||||
$smarty->assign(array(
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'logo' => $ppPayment->getLogo(),
|
||||
'cust_currency' => $cart->id_currency,
|
||||
'currency' => $ppPayment->getCurrency((int)$cart->id_currency),
|
||||
'total' => $cart->getOrderTotal(true, Cart::BOTH),
|
||||
'cust_currency' => Context::getContext()->cart->id_currency,
|
||||
'currency' => $ppPayment->getCurrency((int)Context::getContext()->cart->id_currency),
|
||||
'total' => Context::getContext()->cart->getOrderTotal(true, Cart::BOTH),
|
||||
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'. $ppPayment->name.'/',
|
||||
'mode' => 'payment/'
|
||||
));
|
||||
@@ -107,54 +107,53 @@ function displayConfirm()
|
||||
|
||||
function submitConfirm()
|
||||
{
|
||||
global $cookie, $smarty, $ppPayment, $cart;
|
||||
global $ppPayment;
|
||||
|
||||
if (!$cookie->isLogged(true))
|
||||
if (!Context::getContext()->cookie->isLogged(true))
|
||||
{
|
||||
header('location:../../../'); exit;
|
||||
die('Not logged');
|
||||
}
|
||||
elseif (!$id_currency = (int)(Tools::getValue('currency_payement')))
|
||||
die('No currency');
|
||||
elseif (!$cart->getOrderTotal(true, Cart::BOTH))
|
||||
elseif (!Context::getContext()->cart->getOrderTotal(true, Cart::BOTH))
|
||||
die('Empty cart');
|
||||
$currency = new Currency((int)($id_currency));
|
||||
if (!Validate::isLoadedObject($currency))
|
||||
die('Invalid currency');
|
||||
$cookie->id_currency = (int)($id_currency);
|
||||
Context::getContext()->cookie->id_currency = (int)($id_currency);
|
||||
getAuthorization();
|
||||
}
|
||||
|
||||
function validOrder()
|
||||
{
|
||||
global $cookie, $cart, $ppPayment;
|
||||
if (!$cookie->isLogged(true))
|
||||
global $ppPayment;
|
||||
if (!Context::getContext()->cookie->isLogged(true))
|
||||
{
|
||||
header('location:../../../'); exit;
|
||||
die('Not logged');
|
||||
}
|
||||
elseif (!$cart->getOrderTotal(true, Cart::BOTH))
|
||||
elseif (!Context::getContext()->cart->getOrderTotal(true, Cart::BOTH))
|
||||
die('Empty cart');
|
||||
if (!$token = Tools::htmlentitiesUTF8(strval(Tools::getValue('token'))))
|
||||
{
|
||||
global $smarty;
|
||||
$smarty->assign('paypalError', 'Invalid token');
|
||||
Context::getContext()->smarty->assign('paypalError', 'Invalid token');
|
||||
displayConfirm();
|
||||
die('Invalid token');
|
||||
}
|
||||
if ($token != strval($cookie->paypal_token))
|
||||
if ($token != strval(Context::getContext()->cookie->paypal_token))
|
||||
die('Invalid cookie token');
|
||||
if (!$payerID = Tools::htmlentitiesUTF8(strval(Tools::getValue('PayerID'))))
|
||||
die('Invalid payerID');
|
||||
$ppPayment->makePayPalAPIValidation($cookie, $cart, $cart->id_currency, $payerID, 'payment');
|
||||
$ppPayment->makePayPalAPIValidation(Context::getContext()->cookie, Context::getContext()->cart, Context::getContext()->cart->id_currency, $payerID, 'payment');
|
||||
}
|
||||
|
||||
// #####
|
||||
// Process !!
|
||||
|
||||
if (!$cookie->isLogged(true))
|
||||
if (!Context::getContext()->cookie->isLogged(true))
|
||||
die('Not logged');
|
||||
elseif (!$cart->getOrderTotal(true, Cart::BOTH))
|
||||
elseif (!Context::getContext()->cart->getOrderTotal(true, Cart::BOTH))
|
||||
die('Empty cart');
|
||||
|
||||
// No submit, confirmation page
|
||||
@@ -162,7 +161,7 @@ if (!Tools::isSubmit('submitPayment') AND !Tools::getValue('fromPayPal'))
|
||||
displayConfirm();
|
||||
else
|
||||
{
|
||||
if (!isset($cookie->paypal_token) OR !$cookie->paypal_token)
|
||||
if (!isset(Context::getContext()->cookie->paypal_token) OR !Context::getContext()->cookie->paypal_token)
|
||||
submitConfirm();
|
||||
validOrder();
|
||||
}
|
||||
|
||||
+23
-55
@@ -57,9 +57,8 @@ class PayPal extends PaymentModule
|
||||
if (file_exists(_PS_ROOT_DIR_.'/modules/paypalapi/paypalapi.php') AND $this->active)
|
||||
$this->warning = $this->l('All features of Paypal API module are be include in the new Paypal module. In order to don\'t have any conflict, please don\'t use and remove PayPalAPI module.');
|
||||
|
||||
global $cookie;
|
||||
$context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5)));
|
||||
$content = @file_get_contents('https://www.prestashop.com/partner/preactivation/preactivation-warnings.php?version=1.0&partner=paypal&iso_country='.Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))).'&iso_lang='.Tools::strtolower(Language::getIsoById(intval($cookie->id_lang))).'&id_lang='.(int)$cookie->id_lang.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $context);
|
||||
$content = @file_get_contents('https://www.prestashop.com/partner/preactivation/preactivation-warnings.php?version=1.0&partner=paypal&iso_country='.Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))).'&iso_lang='.Tools::strtolower($this->context->language->iso_code).'&id_lang='.(int)$this->context->language->id.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $context);
|
||||
$content = explode('|', $content);
|
||||
if ($content[0] == 'OK')
|
||||
{
|
||||
@@ -180,8 +179,6 @@ class PayPal extends PaymentModule
|
||||
|
||||
public function hookPayment($params)
|
||||
{
|
||||
global $smarty;
|
||||
|
||||
if (!$this->active)
|
||||
return ;
|
||||
/*
|
||||
@@ -196,8 +193,8 @@ class PayPal extends PaymentModule
|
||||
{
|
||||
if ($this->_isPayPalAPIAvailable())
|
||||
{
|
||||
$smarty->assign('integral', (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0 ? 1 : 0));
|
||||
$smarty->assign('logo', _MODULE_DIR_.$this->name.'/paypal.gif');
|
||||
$this->context->smarty->assign('integral', (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0 ? 1 : 0));
|
||||
$this->context->smarty->assign('logo', _MODULE_DIR_.$this->name.'/paypal.gif');
|
||||
return $this->display(__FILE__, 'payment/payment.tpl');
|
||||
}
|
||||
else
|
||||
@@ -209,14 +206,12 @@ class PayPal extends PaymentModule
|
||||
|
||||
public function hookShoppingCartExtra($params)
|
||||
{
|
||||
global $cookie, $smarty;
|
||||
|
||||
if (!$this->active)
|
||||
return ;
|
||||
|
||||
if (Configuration::get('PAYPAL_EXPRESS_CHECKOUT') AND !$cookie->isLogged(true) AND $this->_isPayPalAPIAvailable())
|
||||
if (Configuration::get('PAYPAL_EXPRESS_CHECKOUT') AND !$this->context->cookie->isLogged(true) AND $this->_isPayPalAPIAvailable())
|
||||
{
|
||||
$smarty->assign('logo', $this->getLogo(true));
|
||||
$this->context->smarty->assign('logo', $this->getLogo(true));
|
||||
return $this->display(__FILE__, 'express/shopping_cart.tpl');
|
||||
}
|
||||
}
|
||||
@@ -231,10 +226,8 @@ class PayPal extends PaymentModule
|
||||
|
||||
public function hookRightColumn($params)
|
||||
{
|
||||
global $smarty, $cookie;
|
||||
|
||||
$smarty->assign('iso_code', Tools::strtolower(Language::getIsoById($cookie->id_lang ? (int)($cookie->id_lang) : 1)));
|
||||
$smarty->assign('logo', $this->getLogo(false, true));
|
||||
$this->context->smarty->assign('iso_code', Tools::strtolower($this->context->language));
|
||||
$this->context->smarty->assign('logo', $this->getLogo(false, true));
|
||||
return $this->display(__FILE__, 'column.tpl');
|
||||
}
|
||||
|
||||
@@ -251,13 +244,11 @@ class PayPal extends PaymentModule
|
||||
/* Only execute if you use PayPal API for payment */
|
||||
if (Configuration::get('PAYPAL_PAYMENT_METHOD') != _PAYPAL_INTEGRAL_EVOLUTION_ AND $this->_isPayPalAPIAvailable())
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if ($params['module'] != $this->name)
|
||||
return false;
|
||||
if (!$token = $cookie->paypal_token)
|
||||
if (!$token = $this->context->cookie->paypal_token)
|
||||
return false;
|
||||
if (!$payerID = $cookie->paypal_payer_id)
|
||||
if (!$payerID = $this->context->cookie->paypal_payer_id)
|
||||
return false;
|
||||
Tools::redirect('modules/paypal/express/submit.php?confirm=1&token='.$token.'&payerID='.$payerID);
|
||||
}
|
||||
@@ -375,8 +366,6 @@ class PayPal extends PaymentModule
|
||||
|
||||
public function makePayPalAPIValidation($cookie, $cart, $id_currency, $payerID, $type)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if (!$this->active)
|
||||
return ;
|
||||
if (!$this->_isPayPalAPIAvailable())
|
||||
@@ -558,11 +547,9 @@ class PayPal extends PaymentModule
|
||||
|
||||
public function getLogo($ppExpress = false, $vertical = false)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if ($ppExpress)
|
||||
{
|
||||
$iso_code = Tools::strtoupper(Language::getIsoById($cookie->id_lang ? (int)$cookie->id_lang : 1));
|
||||
$iso_code = Tools::strtoupper($this->context->language);
|
||||
$logo = array(
|
||||
'FR' => 'FR',
|
||||
'DE' => 'DE',
|
||||
@@ -612,18 +599,13 @@ class PayPal extends PaymentModule
|
||||
|
||||
public function getCountryCode()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$cart = new Cart((int)$cookie->id_cart);
|
||||
$address = new Address((int)$cart->id_address_invoice);
|
||||
$country = new Country((int)$address->id_country);
|
||||
$address = new Address($this->context->cart->id_address_invoice);
|
||||
$country = new Country($address->id_country);
|
||||
return $country->iso_code;
|
||||
}
|
||||
|
||||
public function displayPayPalAPIError($message, $log = false)
|
||||
{
|
||||
global $cookie, $smarty;
|
||||
|
||||
$send = true;
|
||||
// Sanitize log
|
||||
foreach ($log AS $key => $string)
|
||||
@@ -644,11 +626,11 @@ class PayPal extends PaymentModule
|
||||
}
|
||||
|
||||
include(dirname(__FILE__).'/../../header.php');
|
||||
$smarty->assign('message', $message);
|
||||
$smarty->assign('logs', $log);
|
||||
$this->context->smarty->assign('message', $message);
|
||||
$this->context->smarty->assign('logs', $log);
|
||||
$data = array('{logs}' => implode('<br />', $log));
|
||||
if ($send)
|
||||
Mail::Send((int)($cookie->id_lang), 'error_reporting', Mail::l('Error reporting from your PayPal module'), $data, Configuration::get('PS_SHOP_EMAIL'), NULL, NULL, NULL, NULL, NULL, _PS_MODULE_DIR_.$this->name.'/mails/');
|
||||
Mail::Send($this->context->language->id, 'error_reporting', Mail::l('Error reporting from your PayPal module'), $data, Configuration::get('PS_SHOP_EMAIL'), NULL, NULL, NULL, NULL, NULL, _PS_MODULE_DIR_.$this->name.'/mails/');
|
||||
echo $this->display(__FILE__, 'error.tpl');
|
||||
include_once(dirname(__FILE__).'/../../footer.php');
|
||||
die;
|
||||
@@ -747,14 +729,12 @@ class PayPal extends PaymentModule
|
||||
|
||||
private function _getSolutionTabHtml()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$paymentMethod = (int)(Tools::getValue('payment_method', Configuration::get('PAYPAL_PAYMENT_METHOD')));
|
||||
$paypalExpress = (int)(Tools::isSubmit('paypal_express') ? 1 : Configuration::get('PAYPAL_EXPRESS_CHECKOUT'));
|
||||
$paypalDebug = (int)(Tools::isSubmit('paypal_debug') ? 1 : Configuration::get('PAYPAL_DEBUG_MODE'));
|
||||
|
||||
$link = 'http://altfarm.mediaplex.com/ad/ck/3484-23403-8030-88?ID=PROCPRESTA';
|
||||
$lang = new Language((int)$cookie->id_lang);
|
||||
$lang = $this->context->language;
|
||||
if (strtolower($lang->iso_code) == 'es')
|
||||
$link = 'http://altfarm.mediaplex.com/ad/ck/3484-34334-12439-1';
|
||||
else if (strtolower($lang->iso_code) == 'it')
|
||||
@@ -783,9 +763,7 @@ class PayPal extends PaymentModule
|
||||
|
||||
private function _getSettingsTabHtml()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$lang = new Language((int)$cookie->id_lang);
|
||||
$lang = $this->context->language;
|
||||
$sandboxMode = (int)(Tools::getValue('sandbox_mode', Configuration::get('PAYPAL_SANDBOX')));
|
||||
$paypalCapture = (int)(Tools::getValue('paypal_capture', Configuration::get('PAYPAL_CAPTURE')));
|
||||
|
||||
@@ -838,9 +816,7 @@ class PayPal extends PaymentModule
|
||||
|
||||
private function _getPersonalizationsTabHtml()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$lang = new Language((int)$cookie->id_lang);
|
||||
$lang = $this->context->language;
|
||||
$template_paypal = Tools::getValue('template_paypal', Configuration::get('PAYPAL_TEMPLATE'));
|
||||
|
||||
return '
|
||||
@@ -879,8 +855,6 @@ class PayPal extends PaymentModule
|
||||
|
||||
private function _postProcess()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if (Tools::isSubmit('submitPayPal'))
|
||||
{
|
||||
$template_available = array('A', 'B', 'C');
|
||||
@@ -944,7 +918,7 @@ class PayPal extends PaymentModule
|
||||
if ($response['ACK'] == 'Success')
|
||||
{
|
||||
if ($response['PAYMENTSTATUS'] == 'Completed' OR $response['PAYMENTSTATUS'] == 'Reversed' OR ($response['PAYMENTSTATUS'] == 'Pending' AND $response['PENDINGREASON'] == 'authorization'))
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=validationOk&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)));
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=validationOk&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id));
|
||||
else
|
||||
$this->_html .= '<p><b>'.$this->l('Status').':</b> '.$response['PAYMENTSTATUS'].' ('.$this->l('Reason:').' '.$response['PENDINGREASON'].')</p>';
|
||||
}
|
||||
@@ -962,9 +936,9 @@ class PayPal extends PaymentModule
|
||||
if ($response['ACK'] == 'Success')
|
||||
{
|
||||
if ($response['PAYMENTSTATUS'] == 'Completed')
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=captureOk&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)));
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=captureOk&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id));
|
||||
else
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=captureError&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)));
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=captureError&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id));
|
||||
}
|
||||
else
|
||||
$this->_html .= '<p style="color:red;">'.$this->l('Error from PayPal: ').$response['L_LONGMESSAGE0'].' (#'.$response['L_ERRORCODE0'].')</p>';
|
||||
@@ -980,9 +954,9 @@ class PayPal extends PaymentModule
|
||||
if ($response['ACK'] == 'Success')
|
||||
{
|
||||
if ($response['REFUNDTRANSACTIONID'] != '')
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=refundOk&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)));
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=refundOk&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id));
|
||||
else
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=refundError&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)));
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&id_order='.(int)(Tools::getValue('id_order')).'&vieworder&paypal=refundError&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id));
|
||||
}
|
||||
else
|
||||
$this->_html .= '<p style="color:red;">'.$this->l('Error from PayPal: ').$response['L_LONGMESSAGE0'].' (#'.$response['L_ERRORCODE0'].')</p>';
|
||||
@@ -1041,8 +1015,6 @@ class PayPal extends PaymentModule
|
||||
|
||||
private function _doTotalRefund($id_order)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if (!$this->_isPayPalAPIAvailable())
|
||||
return false;
|
||||
if (!$id_order)
|
||||
@@ -1089,8 +1061,6 @@ class PayPal extends PaymentModule
|
||||
|
||||
private function _doCapture($id_order)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
include_once(_PS_MODULE_DIR_.'paypal/api/paypallib.php');
|
||||
|
||||
if (!$this->_isPayPalAPIAvailable())
|
||||
@@ -1129,8 +1099,6 @@ class PayPal extends PaymentModule
|
||||
|
||||
private function _updatePaymentStatusOfOrder($id_order)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
include_once(_PS_MODULE_DIR_.'paypal/api/paypallib.php');
|
||||
|
||||
if (!$this->_isPayPalAPIAvailable())
|
||||
|
||||
Reference in New Issue
Block a user