first commit

This commit is contained in:
2024-10-28 22:14:22 +01:00
commit b65352c452
40581 changed files with 5712079 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
drwxr-xr-x 2 30094 users 11 Oct 6 10:16 .
drwxr-xr-x 4 30094 users 5 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 46931 Oct 14 2021 AdminPayPalCustomizeCheckoutController.php
-rw-r--r-- 1 30094 users 3746 Oct 14 2021 AdminPayPalHelpController.php
-rw-r--r-- 1 30094 users 2789 Oct 14 2021 AdminPayPalInstallmentController.php
-rw-r--r-- 1 30094 users 3951 Oct 14 2021 AdminPayPalLogsController.php
-rw-r--r-- 1 30094 users 14770 Oct 14 2021 AdminPayPalSetupController.php
-rw-r--r-- 1 30094 users 1234 Oct 14 2021 AdminPaypalConfigurationController.php
-rw-r--r-- 1 30094 users 1821 Oct 14 2021 AdminPaypalGetCredentialsController.php
-rw-r--r-- 1 30094 users 1235 Oct 14 2021 AdminPaypalProcessLogger.php
-rw-r--r-- 1 30094 users 1399 Oct 14 2021 index.php

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\AdminPayPalController;
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder;
use Symfony\Component\HttpFoundation\JsonResponse;
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 = [
'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()
{
return $this->module->registerHooks();
}
}

View File

@@ -0,0 +1,84 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalAddons\classes\AdminPayPalController;
use PaypalAddons\classes\Form\Controller\AdminPayPalInstallment\FormInstallment;
use PaypalAddons\classes\Form\FormInterface;
use PaypalAddons\classes\InstallmentBanner\Banner;
use Symfony\Component\HttpFoundation\JsonResponse;
class AdminPayPalInstallmentController extends AdminPayPalController
{
protected $headerToolBar = true;
/** @var array<string, FormInterface> */
protected $forms;
public function __construct()
{
parent::__construct();
$this->forms['formInstallment'] = new FormInstallment();
}
public function initContent()
{
parent::initContent();
$this->initFormInstallment();
$this->context->smarty->assign('formInstallment', $this->renderForm());
$content = $this->context->smarty->fetch($this->getTemplatePath() . 'installment.tpl');
$this->context->smarty->assign('content', $content);
$this->addJS(_PS_MODULE_DIR_ . $this->module->name . '/views/js/adminInstallment.js');
}
protected function initFormInstallment()
{
$this->fields_form['form']['form'] = $this->forms['formInstallment']->getFields();
$this->tpl_form_vars = array_merge(
$this->tpl_form_vars,
$this->forms['formInstallment']->getValues()
);
}
public function saveForm()
{
return $this->forms['formInstallment']->save();
}
public function displayAjaxGetBanner()
{
$jsonResponse = new JsonResponse();
$banner = new Banner();
$jsonResponse->setData([
'success' => true,
'content' => $banner->render(),
]);
return $jsonResponse->send();
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
require_once _PS_MODULE_DIR_ . 'paypal/controllers/admin/AdminPaypalProcessLogger.php';
class AdminPayPalLogsController extends AdminPaypalProcessLoggerController
{
public function init()
{
if (\Tools::getValue('action') === 'set_sandbox_mode') {
\Configuration::updateValue('PAYPAL_SANDBOX', (int) \Tools::getValue('sandbox_mode'));
}
$this->page_header_toolbar_title = $this->l('Logs');
$this->filter = true;
parent::init();
}
public function processFilter()
{
if (Tools::isSubmit('submitFilter' . $this->list_id)) {
return parent::processFilter();
}
$isWriteCookie = false;
foreach ($this->getDefaultFilters() as $key => $value) {
if (Tools::isSubmit('submitFilter' . $this->list_id) === false) {
$this->context->cookie->__set($key, $value);
$isWriteCookie = true;
}
}
if ($isWriteCookie) {
$this->context->cookie->write();
}
$this->_filter = sprintf(' AND a.`sandbox` = %d ', (int) \Configuration::get('PAYPAL_SANDBOX'));
}
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();
$this->content = $this->context->smarty
->assign('content', $this->content)
->assign('isModeSandbox', (int) \Configuration::get('PAYPAL_SANDBOX'))
->assign('psVersion', _PS_VERSION_)
->fetch($this->getTemplatePath() . 'admin.tpl');
$this->context->smarty->assign('content', $this->content);
}
public function setMedia($isNewTheme = false)
{
parent::setMedia($isNewTheme);
$this->addCSS(_PS_MODULE_DIR_ . $this->module->name . '/views/css/paypal_bo.css');
}
protected function getDefaultFilters()
{
return [
$this->getCookieFilterPrefix() . $this->list_id . 'Filter_a!sandbox' => Configuration::get('PAYPAL_SANDBOX'),
];
}
public function initPageHeaderToolbar()
{
$query = [
'token' => $this->token,
'action' => 'set_sandbox_mode',
'sandbox_mode' => \Configuration::get('PAYPAL_SANDBOX') ? 0 : 1,
];
$this->page_header_toolbar_btn['switch_sandbox'] = [
'desc' => $this->l('Sandbox mode'),
'icon' => 'process-icon-toggle-' . (\Configuration::get('PAYPAL_SANDBOX') ? 'on' : 'off'),
'help' => $this->l('Sandbox mode is the test environment where you\'ll be not able to collect any real payments.'),
'href' => self::$currentIndex . '?' . http_build_query($query),
];
parent::initPageHeaderToolbar();
$this->context->smarty->clearAssign('help_link');
}
}

View File

@@ -0,0 +1,61 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
use PaypalAddons\classes\Constants\PUI;
use PaypalAddons\classes\PUI\PsMerchantId;
use PaypalAddons\services\Core\PaypalMerchantId;
class AdminPayPalPUIListenerController extends ModuleAdminController
{
public function init()
{
parent::init();
Configuration::updateValue(PUI::PARTNER_REFERRAL_ACTION_URL, false);
if (Tools::getValue('merchantId') != $this->initPsMerchantId()->get()) {
return $this->redirectToSetup();
}
$this->initPaypalMerchantId()->set(Tools::getValue('merchantIdInPayPal'));
return $this->redirectToSetup();
}
protected function initPsMerchantId()
{
return new PsMerchantId();
}
protected function redirectToSetup()
{
Tools::redirectAdmin($this->context->link->getAdminLink('AdminPayPalSetup'));
}
protected function initPaypalMerchantId()
{
return new PaypalMerchantId();
}
}

View File

@@ -0,0 +1,427 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\classes\AdminPayPalController;
use PaypalAddons\classes\API\Onboarding\PaypalGetAuthToken;
use PaypalAddons\classes\API\Onboarding\PaypalGetCredentials;
use PaypalAddons\classes\PUI\SignUpLinkButton;
use PaypalAddons\classes\PuiMethodInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
class AdminPayPalSetupController extends AdminPayPalController
{
protected $headerToolBar = true;
public function __construct()
{
parent::__construct();
$this->parametres = [
'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);
}
// Don't show somes tabs if a module is not configured
$method = AbstractMethodPaypal::load();
$isShowTabs = $method->isConfigured();
foreach (['AdminPayPalCustomizeCheckout', 'AdminPayPalLogs'] as $adminController) {
$tab = Tab::getInstanceFromClassName($adminController);
if ($isShowTabs != $tab->active) {
$tab->active = $isShowTabs;
$tab->save();
}
}
// Activate/Disactivate AdminPaypalInstallment tab
$this->module->hookActionLocalizationPageSave([]);
}
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');
}
$countryDefault = new Country((int) \Configuration::get('PS_COUNTRY_DEFAULT'), $this->context->language->id);
$tpl_vars = [
'country_iso' => $countryDefault->iso_code,
];
$this->initAccountSettingsBlock();
$formAccountSettings = $this->renderForm();
$this->clearFieldsForm();
$tpl_vars['formAccountSettings'] = $formAccountSettings;
if (in_array($this->method, ['EC', 'MB'])) {
$this->initPaymentSettingsBlock();
$formPaymentSettings = $this->renderForm();
$this->clearFieldsForm();
$tpl_vars['formPaymentSettings'] = $formPaymentSettings;
}
$this->initStatusBlock();
$formStatus = $this->renderForm();
$this->clearFieldsForm();
$tpl_vars['formStatus'] = $formStatus;
if ($this->isShowInstallmentPopup()) {
$tpl_vars['installmentController'] = $this->context->link->getAdminLink('AdminPayPalInstallment', true);
$tpl_vars['showInstallmentPopup'] = true;
}
$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'] = [
'legend' => [
'title' => $this->l('Account settings'),
'icon' => 'icon-cogs',
],
'input' => [
[
'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, ['IN', 'JP'])) {
$this->fields_form['form']['form']['submit'] = [
'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;
if ($method instanceof PuiMethodInterface && $method->isConfigured()) {
$tpl_vars['SignUpLinkButton'] = $this->initSignUpLinkButton($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 = [];
if ($this->isPaymentModeSetted() == false) {
$inputGroup[] = [
'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 = [
'type' => 'select',
'name' => 'paypal_api_intent',
'options' => [
'query' => [
[
'id' => 'sale',
'name' => $this->l('Sale'),
],
[
'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[] = [
'type' => 'html',
'name' => '',
'col' => 12,
'label' => '',
'html_content' => $this->module->displayInformation($this->l('We recommend Authorize process only for lean manufacturers and craft products sellers.')),
];
$this->fields_form['form']['form'] = [
'legend' => [
'title' => $this->l('Payment settings'),
'icon' => 'icon-cogs',
],
'input' => $inputGroup,
'submit' => [
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right button',
],
'id_form' => 'pp_config_payment',
];
$values = [
'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'] = [
'legend' => [
'title' => $this->l('Environment Settings'),
'icon' => 'icon-cogs',
],
'input' => [
[
'type' => 'html',
'html_content' => $html_content,
'name' => '',
'col' => 12,
'label' => '',
],
[
'type' => 'hidden',
'name' => 'paypal_sandbox',
'col' => 12,
'label' => '',
],
],
'id_form' => 'pp_config_environment',
];
$values = [
'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 = [
'merchantCountry' => $countryDefault->name,
'tlsVersion' => $this->_checkTLSVersion(),
'accountConfigured' => $method == null ? false : $method->isConfigured(),
'sslActivated' => $this->module->isSslActive(),
];
if ($this->getWebhookOption()->isEnable() && $this->getWebhookOption()->isEligibleContext()) {
$webhookCheck = $this->_checkWebhook();
$tpl_vars['showWebhookState'] = true;
$tpl_vars['webhookState'] = $webhookCheck['state'];
$tpl_vars['webhookStateMsg'] = $webhookCheck['message'];
}
$this->context->smarty->assign($tpl_vars);
$html_content = $this->context->smarty->fetch($this->getTemplatePath() . '_partials/statusBlock.tpl');
$this->fields_form[]['form'] = [
'legend' => [
'title' => $this->l('Status'),
'icon' => 'icon-cogs',
],
'input' => [
[
'type' => 'html',
'html_content' => $html_content,
'name' => '',
'col' => 12,
'label' => '',
],
],
];
}
public function displayAjaxLogoutAccount()
{
$response = new JsonResponse();
$content = [
'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([
'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'), ['sale', 'authorize']);
}
protected function isShowInstallmentPopup()
{
$countryDefault = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT', null, null, $this->context->shop->id));
if (Validate::isLoadedObject($countryDefault) === false) {
return false;
}
if (Tools::strtolower($countryDefault->iso_code) != 'fr') {
return false;
}
if (false == (int) Configuration::get('PAYPAL_SHOW_INSTALLMENT_POPUP', null, null, $this->context->shop->id)) {
return false;
}
Configuration::updateValue('PAYPAL_SHOW_INSTALLMENT_POPUP', 0, false, null, $this->context->shop->id);
return true;
}
protected function initSignUpLinkButton(PuiMethodInterface $method)
{
return new SignUpLinkButton($method);
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
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,64 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
require_once _PS_MODULE_DIR_ . 'paypal/vendor/autoload.php';
use PaypalAddons\classes\AbstractMethodPaypal;
use PaypalAddons\services\Core\PaypalMerchantId;
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;
$this->initPaypalMerchantId()->set(Tools::getValue('merchantIdInPayPal'));
}
$duration = time() - $start;
if ($duration > $maxDuration) {
$wait = false;
}
} while ($wait);
Tools::redirectAdmin($this->context->link->getAdminLink('AdminPayPalSetup', true, [], ['checkCredentials' => 1]));
}
protected function initPaypalMerchantId()
{
return new PaypalMerchantId();
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* 2007-2022 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-2022 PayPal
* @author 202 ecommerce <tech@202-ecommerce.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright PayPal
*/
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;