download all files

This commit is contained in:
Roman Pyrih
2025-06-24 14:14:35 +02:00
parent ebed09c00b
commit 4c71b5d9c2
72007 changed files with 10407727 additions and 40029 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 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)
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalAddons\classes\AbstractMethodPaypal;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder;
use Symfony\Component\HttpFoundation\JsonResponse;
use PaypalAddons\classes\AdminPayPalController;
class AdminPayPalHelpController extends AdminPayPalController
{
public function init()
{
parent::init();
if (Tools::isSubmit('registerHooks')) {
if ($this->registerHooks()) {
$this->confirmations[] = $this->l('Hooks successfully registered');
}
}
}
public function initContent()
{
parent::initContent();
$countryDefault = new Country((int)\Configuration::get('PS_COUNTRY_DEFAULT'), $this->context->language->id);
$method = AbstractMethodPaypal::load($this->method);
if ($method->isSandbox()) {
$settingLink = 'https://www.sandbox.paypal.com/businessprofile/settings/info/edit';
} else {
$settingLink = 'https://www.paypal.com/businessprofile/settings/info/edit';
}
$this->context->smarty->assign('settingLink', $settingLink);
$tpl_vars = array(
'psCheckoutBtnText' => $this->getCheckoutBtnText(),
'showPsCheckout' => in_array($countryDefault->iso_code, $this->module->countriesApiCartUnavailable),
'settingLink' => $settingLink
);
$this->context->smarty->assign($tpl_vars);
$this->content = $this->context->smarty->fetch($this->getTemplatePath() . 'help.tpl');
$this->context->smarty->assign('content', $this->content);
$this->addJS(_PS_MODULE_DIR_ . $this->module->name . '/views/js/helpAdmin.js');
}
protected function getCheckoutBtnText()
{
$moduleManagerBuilder = ModuleManagerBuilder::getInstance();
$moduleManager = $moduleManagerBuilder->build();
if ($moduleManager->isInstalled('ps_checkout')) {
$psCheckoutBtnText = $this->l('Configure PrestaShop Checkout');
} elseif (is_dir(_PS_MODULE_DIR_ . 'ps_checkout')) {
$psCheckoutBtnText = $this->l('Install PrestaShop Checkout');
} else {
$psCheckoutBtnText = $this->l('Download PrestaShop Checkout');
}
return $psCheckoutBtnText;
}
public function displayAjaxCheckCredentials()
{
$response = new JsonResponse($this->_checkRequirements());
return $response->send();
}
public function registerHooks()
{
$result = true;
$hooksUnregistered = $this->module->getHooksUnregistered();
if (empty($hooksUnregistered)) {
return $result;
}
foreach ($hooksUnregistered as $hookName) {
$result &= $this->module->registerHook($hookName);
}
return $result;
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 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)
*/
require_once _PS_MODULE_DIR_ . 'paypal/controllers/admin/AdminPaypalProcessLogger.php';
class AdminPayPalLogsController extends AdminPayPalProcessLoggerController
{
public function initContent()
{
$this->context->smarty->assign('showWarningForUserBraintree', $this->module->showWarningForUserBraintree());
$this->context->smarty->assign('moduleDir', _MODULE_DIR_);
$this->content = $this->context->smarty->fetch($this->getTemplatePath() . '_partials/headerLogo.tpl');
$this->content .= parent::initContent();
}
public function setMedia($isNewTheme = false)
{
parent::setMedia($isNewTheme);
$this->addCSS(_PS_MODULE_DIR_ . $this->module->name . '/views/css/paypal_bo.css');
}
}

View File

@@ -0,0 +1,366 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 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)
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalAddons\classes\API\Onboarding\PaypalGetAuthToken;
use PaypalPPBTlib\Install\ModuleInstaller;
use Symfony\Component\HttpFoundation\JsonResponse;
use PaypalAddons\classes\AdminPayPalController;
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\API\Onboarding\PaypalGetCredentials;
class AdminPayPalSetupController extends AdminPayPalController
{
protected $headerToolBar = true;
public function __construct()
{
parent::__construct();
$this->parametres = array(
'paypal_api_intent',
'paypal_sandbox',
'paypal_ec_secret_sandbox',
'paypal_ec_secret_live',
'paypal_ec_clientid_sandbox',
'paypal_ec_clientid_live',
'paypal_sandbox_clientid',
'paypal_live_clientid',
'paypal_sandbox_secret',
'paypal_live_secret',
'paypal_mb_sandbox_clientid',
'paypal_mb_live_clientid',
'paypal_mb_sandbox_secret',
'paypal_mb_live_secret'
);
}
public function init()
{
parent::init();
if (Tools::getValue('useWithoutBraintree')) {
Configuration::updateValue('PAYPAL_USE_WITHOUT_BRAINTREE', 1);
}
}
public function initContent()
{
parent::initContent();
if ($this->module->showWarningForUserBraintree()) {
$this->content = $this->context->smarty->fetch($this->getTemplatePath() . '_partials/messages/forBraintreeUsers.tpl');
$this->context->smarty->assign('content', $this->content);
return;
}
if ($this->method == 'PPP' && $this->module->showWarningForPayPalPlusUsers()) {
$this->warnings[] = $this->context->smarty->fetch($this->getTemplatePath() . '_partials/messages/forPayPalPlusUsers.tpl');
}
$tpl_vars = array();
$this->initAccountSettingsBlock();
$formAccountSettings = $this->renderForm();
$this->clearFieldsForm();
$tpl_vars['formAccountSettings'] = $formAccountSettings;
if (in_array($this->method, array('EC', 'MB'))) {
$this->initPaymentSettingsBlock();
$formPaymentSettings = $this->renderForm();
$this->clearFieldsForm();
$tpl_vars['formPaymentSettings'] = $formPaymentSettings;
}
$this->initEnvironmentSettings();
$formEnvironmentSettings = $this->renderForm();
$this->clearFieldsForm();
$tpl_vars['formEnvironmentSettings'] = $formEnvironmentSettings;
$this->initStatusBlock();
$formStatus = $this->renderForm();
$this->clearFieldsForm();
$tpl_vars['formStatus'] = $formStatus;
$this->context->smarty->assign($tpl_vars);
$this->content = $this->context->smarty->fetch($this->getTemplatePath() . 'setup.tpl');
$this->context->smarty->assign('content', $this->content);
$this->addJS(_PS_MODULE_DIR_ . $this->module->name . '/views/js/adminSetup.js?v=' . $this->module->version);
}
public function initAccountSettingsBlock()
{
$this->fields_form['form']['form'] = array(
'legend' => array(
'title' => $this->l('Account settings'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => 'html',
'html_content' => $this->getHtmlBlockAccountSetting(),
'name' => '',
'col' => 12,
'label' => '',
)
),
'id_form' => 'pp_config_account'
);
$countryDefault = new Country((int)\Configuration::get('PS_COUNTRY_DEFAULT'), $this->context->language->id);
if ($this->method == 'MB' || in_array($countryDefault->iso_code, array('IN', 'JP'))) {
$this->fields_form['form']['form']['submit'] = array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right button',
'name' => 'saveMbCredentialsForm'
);
}
}
public function getHtmlBlockAccountSetting()
{
$method = AbstractMethodPaypal::load($this->method);
$tpl_vars = $method->getTplVars();
$tpl_vars['method'] = $this->method;
$this->context->smarty->assign($tpl_vars);
$html_content = $this->context->smarty->fetch($this->getTemplatePath() . '_partials/accountSettingsBlock.tpl');
return $html_content;
}
public function initPaymentSettingsBlock()
{
$inputGroup = array();
if ($this->isPaymentModeSetted() == false) {
$inputGroup[] = array(
'type' => 'html',
'html_content' => $this->module->displayWarning($this->l('An error occurred while saving "Payment action" configuration. Please save this configuration again for avoiding any payment errors.')),
'name' => '',
'col' => 12,
'label' => '',
);
}
$paymentModeInput = array(
'type' => 'select',
'name' => 'paypal_api_intent',
'options' => array(
'query' => array(
array(
'id' => 'sale',
'name' => $this->l('Sale')
),
array(
'id' => 'authorize',
'name' => $this->l('Authorize')
)
),
'id' => 'id',
'name' => 'name'
),
);
if ($this->method == 'MB') {
$paymentModeInput['label'] = $this->l('Payment action (for PayPal Express Checkout only)');
$paymentModeInput['hint'] = $this->l('You can change the payment action only for PayPal Express Checkout payments. If you are using PayPal Plus the "Sale" action is the only possible action.');
} else {
$paymentModeInput['label'] = $this->l('Payment action');
}
$inputGroup[] = $paymentModeInput;
$inputGroup[] = array(
'type' => 'html',
'name' => '',
'html_content' => $this->module->displayInformation($this->l('We recommend Authorize process only for lean manufacturers and craft products sellers.'))
);
$this->fields_form['form']['form'] = array(
'legend' => array(
'title' => $this->l('Payment settings'),
'icon' => 'icon-cogs',
),
'input' => $inputGroup,
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right button',
),
'id_form' => 'pp_config_payment'
);
$values = array(
'paypal_api_intent' => Configuration::get('PAYPAL_API_INTENT'),
);
$this->tpl_form_vars = array_merge($this->tpl_form_vars, $values);
}
public function initEnvironmentSettings()
{
$this->context->smarty->assign('sandbox', (int)\Configuration::get('PAYPAL_SANDBOX'));
$html_content = $this->context->smarty->fetch($this->getTemplatePath() . '_partials/switchSandboxBlock.tpl');
$this->fields_form['form']['form'] = array(
'legend' => array(
'title' => $this->l('Environment Settings'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => 'html',
'html_content' => $html_content,
'name' => '',
'col' => 12,
'label' => '',
),
array(
'type' => 'hidden',
'name' => 'paypal_sandbox',
'col' => 12,
'label' => '',
)
),
'id_form' => 'pp_config_environment'
);
$values = array(
'paypal_sandbox' => !(int)Configuration::get('PAYPAL_SANDBOX')
);
$this->tpl_form_vars = array_merge($this->tpl_form_vars, $values);
}
public function initStatusBlock()
{
$countryDefault = new \Country((int)\Configuration::get('PS_COUNTRY_DEFAULT'), $this->context->language->id);
$method = AbstractMethodPaypal::load($this->method);
$tpl_vars = array(
'merchantCountry' => $countryDefault->name,
'tlsVersion' => $this->_checkTLSVersion(),
'accountConfigured' => $method == null ? false : $method->isConfigured(),
'sslActivated' => $this->module->isSslActive()
);
$this->context->smarty->assign($tpl_vars);
$html_content = $this->context->smarty->fetch($this->getTemplatePath() . '_partials/statusBlock.tpl');
$this->fields_form[]['form'] = array(
'legend' => array(
'title' => $this->l('Status'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => 'html',
'html_content' => $html_content,
'name' => '',
'col' => 12,
'label' => '',
)
)
);
}
public function displayAjaxLogoutAccount()
{
$response = new JsonResponse();
$content = array(
'status' => false,
'redirectUrl' => ''
);
if (Tools::getValue('token') == Tools::getAdminTokenLite($this->controller_name)) {
$method = AbstractMethodPaypal::load($this->method);
$method->logOut();
$content['status'] = true;
$content['redirectUrl'] = $this->context->link->getAdminLink($this->controller_name);
}
$response->setContent(\Tools::jsonEncode($content));
return $response->send();
}
public function displayAjaxCheckCredentials()
{
$this->initStatusBlock();
$response = new JsonResponse($this->renderForm());
return $response->send();
}
public function saveForm()
{
$result = parent::saveForm();
$method = AbstractMethodPaypal::load($this->method);
$method->checkCredentials();
if (Tools::isSubmit('paypal_sandbox') == false) {
$this->errors = array_merge($this->errors, $method->errors);
}
// We need use some functionality of EC method, so need also to configure MethodEC
if(Tools::isSubmit('saveMbCredentialsForm')) {
$methodEC = AbstractMethodPaypal::load('EC');
$methodEC->setConfig(array(
'clientId' => $method->getClientId(),
'secret' => $method->getSecret()
));
$methodEC->checkCredentials();
}
return $result;
}
public function displayAjaxHandleOnboardingResponse()
{
$method = AbstractMethodPaypal::load();
$authCode = Tools::getValue('authCode');
$sharedId = Tools::getValue('sharedId');
$sellerNonce = $method->getSellerNonce();
$paypalOnboarding = new PaypalGetAuthToken($authCode, $sharedId, $sellerNonce, $method->isSandbox());
$result = $paypalOnboarding->execute();
if ($result->isSuccess() === false) {
$this->log($result->getError()->getMessage());
return;
}
$partnerId = $method->isSandbox() ? PayPal::PAYPAL_PARTNER_ID_SANDBOX : PayPal::PAYPAL_PARTNER_ID_LIVE;
$paypalGetCredentials = new PaypalGetCredentials($result->getAuthToken(), $partnerId, $method->isSandbox());
$result = $paypalGetCredentials->execute();
if ($result->isSuccess()) {
$params = [
'clientId' => $result->getClientId(),
'secret' => $result->getSecret()
];
$method->setConfig($params);
} else {
$this->log($result->getError()->getMessage());
}
}
protected function isPaymentModeSetted()
{
return in_array(Configuration::get('PAYPAL_API_INTENT'), array('sale', 'authorize'));
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 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)
*/
class AdminPaypalConfigurationController extends \ModuleAdminController
{
/** @var Module Instance of your module automatically set by ModuleAdminController */
public $module;
public function __construct()
{
parent::__construct();
Tools::redirect($this->context->link->getAdminLink('AdminPayPalSetup', true));
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 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)
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalPPBTlib\Extensions\ProcessLogger\ProcessLoggerHandler;
class AdminPaypalGetCredentialsController extends ModuleAdminController
{
public function init()
{
parent::init();
// We can wait for authToken max 10 sec
$maxDuration = 10;
$start = time();
$wait = true;
$method = AbstractMethodPaypal::load();
do {
Configuration::clearConfigurationCacheForTesting();
if ($method->isCredentialsSetted()) {
$wait = false;
}
$duration = time() - $start;
if ($duration > $maxDuration) {
$wait = false;
}
} while ($wait);
Tools::redirectAdmin($this->context->link->getAdminLink('AdminPayPalSetup', true, [], ['checkCredentials' => 1]));
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* 2007-2020 PayPal
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author 2007-2020 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)
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalPPBTlib\Extensions\ProcessLogger\Controllers\Admin\AdminProcessLoggerController;
class AdminPaypalProcessLoggerController extends AdminProcessLoggerController
{
public function __construct()
{
parent::__construct();
$this->className = 'PaypalLog';
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from SARL 202 ecommence
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL 202 ecommence is strictly forbidden.
* In order to obtain a license, please contact us: tech@202-ecommerce.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe 202 ecommence
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la SARL 202 ecommence est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter 202-ecommerce <tech@202-ecommerce.com>
* ...........................................................................
*
* @author 202-ecommerce <tech@202-ecommerce.com>
* @copyright Copyright (c) 202-ecommerce
* @license Commercial license
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;