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';
@@ -32,34 +33,36 @@ include_once _PS_MODULE_DIR_.'paypal/controllers/front/abstract.php';
*/
class PaypalEcInitModuleFrontController extends PaypalAbstarctModuleFrontController
{
/* @var $method AbstractMethodPaypal*/
protected $method;
public function init()
{
parent::init();
$this->values['getToken'] = Tools::getvalue('getToken');
$this->values['credit_card'] = Tools::getvalue('credit_card');
$this->values['short_cut'] = 0;
$this->setMethod(AbstractMethodPaypal::load('EC'));
}
/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
$paypal = Module::getInstanceByName($this->name);
$method_ec = AbstractMethodPaypal::load('EC');
try {
$method_ec->setParameters($this->values);
$url = $method_ec->init();
$this->method->setParameters($this->values);
$url = $this->method->init();
if ($this->values['getToken']) {
$this->jsonValues = array('success' => true, 'token' => $method_ec->token);
$this->jsonValues = array('success' => true, 'token' => $this->method->token);
} else {
$this->redirectUrl = $url.'&useraction=commit';
}
} catch (PayPal\Exception\PPConnectionException $e) {
$this->errors['error_msg'] = $paypal->l('Error connecting to ', pathinfo(__FILE__)['filename']) . $e->getUrl();
$this->errors['error_msg'] = $this->module->l('Error connecting to ', pathinfo(__FILE__)['filename']) . $e->getUrl();
} catch (PayPal\Exception\PPMissingCredentialException $e) {
$this->errors['error_msg'] = $e->errorMessage();
} catch (PayPal\Exception\PPConfigurationException $e) {
$this->errors['error_msg'] = $paypal->l('Invalid configuration. Please check your configuration file', pathinfo(__FILE__)['filename']);
$this->errors['error_msg'] = $this->module->l('Invalid configuration. Please check your configuration file', pathinfo(__FILE__)['filename']);
} catch (PaypalAddons\classes\PaypalException $e) {
$this->errors['error_code'] = $e->getCode();
$this->errors['error_msg'] = $e->getMessage();
@@ -77,4 +80,9 @@ class PaypalEcInitModuleFrontController extends PaypalAbstarctModuleFrontControl
}
}
}
public function setMethod($method)
{
$this->method = $method;
}
}