MAJ Module Paypal vers 5.1.1 (comme en prod)

This commit is contained in:
2020-02-14 19:42:46 +01:00
parent 188923c03c
commit f00f4207dd
137 changed files with 12999 additions and 5036 deletions

View File

@@ -18,10 +18,11 @@
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author 2007-2019 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @copyright PayPal
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*
*/
include_once _PS_MODULE_DIR_.'paypal/classes/AbstractMethodPaypal.php';
@@ -31,6 +32,9 @@ include_once _PS_MODULE_DIR_.'paypal/controllers/front/abstract.php';
*/
class PaypalScInitModuleFrontController extends PaypalAbstarctModuleFrontController
{
/* @var $method AbstractMethodPaypal*/
protected $method;
public function init()
{
parent::init();
@@ -44,6 +48,12 @@ class PaypalScInitModuleFrontController extends PaypalAbstarctModuleFrontControl
$this->values['getToken'] = Tools::getvalue('getToken');
$this->values['credit_card'] = 0;
$this->values['short_cut'] = 1;
if ($this->module->paypal_method == 'MB') {
$methodType = 'EC';
} else {
$methodType = $this->module->paypal_method;
}
$this->setMethod(AbstractMethodPaypal::load($methodType));
}
public function postProcess()
@@ -56,13 +66,16 @@ class PaypalScInitModuleFrontController extends PaypalAbstarctModuleFrontControl
$this->prepareProduct();
}
$method = AbstractMethodPaypal::load(Configuration::get('PAYPAL_METHOD'));
if (Validate::isLoadedObject($this->context->cart) == false) {
return false;
}
try {
$method->setParameters($this->values);
$response = $method->init();
$this->method->setParameters($this->values);
$response = $this->method->init();
if ($this->values['getToken']) {
$this->jsonValues = array('success' => true, 'token' => $method->token);
$this->jsonValues = array('success' => true, 'token' => $this->method->token);
} else {
$this->redirectUrl = $response;
}
@@ -88,7 +101,7 @@ class PaypalScInitModuleFrontController extends PaypalAbstarctModuleFrontControl
{
switch ($this->values['source_page']) {
case 'cart':
if ($this->context->cart->checkQuantities()) {
if ($this->context->cart->checkQuantities() && $this->context->cart->hasProducts()) {
$this->jsonValues = array('success' => true);
} else {
$this->jsonValues = array('success' => false);
@@ -136,4 +149,9 @@ class PaypalScInitModuleFrontController extends PaypalAbstarctModuleFrontControl
$this->context->cart->updateQty($this->values['quantity'], $this->values['id_product']);
}
}
public function setMethod($method)
{
$this->method = $method;
}
}