* @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(); } }