Skip to content

Commit

Permalink
Merge pull request #68 from paynl/feature/PLUG-2883
Browse files Browse the repository at this point in the history
PLUG-2883 - Multicore toevoegen
  • Loading branch information
woutse authored Nov 16, 2023
2 parents 2ea4f76 + b63c520 commit a777812
Show file tree
Hide file tree
Showing 78 changed files with 3,538 additions and 671 deletions.
231 changes: 127 additions & 104 deletions paynlpaymentmethods/paynlpaymentmethods.php

Large diffs are not rendered by default.

28 changes: 22 additions & 6 deletions paynlpaymentmethods/src/PayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
class PayHelper
{
/**
* @param $useMultiCore
* @return void
*/
public static function sdkLogin()
public static function sdkLogin($useMultiCore = false)
{
$apitoken = Tools::getValue('PAYNL_API_TOKEN', Configuration::get('PAYNL_API_TOKEN'));
if (empty($apitoken) && !empty(Configuration::get('PAYNL_API_TOKEN'))) {
$apitoken = Configuration::get('PAYNL_API_TOKEN');
}
$serviceId = Tools::getValue('PAYNL_SERVICE_ID', Configuration::get('PAYNL_SERVICE_ID'));
$gateway = Tools::getValue('PAYNL_FAILOVER_GATEWAY', Configuration::get('PAYNL_FAILOVER_GATEWAY'));

if (!empty(trim($gateway))) {
\Paynl\Config::setApiBase(trim($gateway));
if ($useMultiCore) {
$gateway = self::getFailoverGateway();
if (!empty(trim($gateway))) {
\Paynl\Config::setApiBase(trim($gateway));
}
}
\Paynl\Config::setApiToken($apitoken);
\Paynl\Config::setServiceId($serviceId);
Expand All @@ -36,8 +39,9 @@ public static function isLoggedIn()
\Paynl\Paymentmethods::getList();
return ['status' => true];
} catch (\Paynl\Error\Error $e) {
$gateway = Tools::getValue('PAYNL_FAILOVER_GATEWAY', Configuration::get('PAYNL_FAILOVER_GATEWAY'));
if (!empty($gateway) && str_contains($gateway, 'https://rest-api.achterelkebetaling.nl')) {
$gateway = self::getFailoverGateway();

if (!empty($gateway) && str_contains($gateway, 'https://rest.achterelkebetaling.nl')) {
return ['status' => true];
}
return ['status' => false, 'error' => $e->getMessage()];
Expand Down Expand Up @@ -144,4 +148,16 @@ public static function checkCredentials($object)
}
return ['status' => $status, 'error' => $error];
}

/**
* @return mixed
*/
public static function getFailoverGateway()
{
$gateway = Tools::getValue('PAYNL_FAILOVER_GATEWAY', Configuration::get('PAYNL_FAILOVER_GATEWAY'));
if ($gateway == 'custom') {
$gateway = Tools::getValue('PAYNL_CUSTOM_FAILOVER_GATEWAY', Configuration::get('PAYNL_CUSTOM_FAILOVER_GATEWAY'));
}
return $gateway;
}
}
18 changes: 18 additions & 0 deletions paynlpaymentmethods/vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInita3a46c0e362da920ffeb331fe601b182::getLoader();
Loading

0 comments on commit a777812

Please sign in to comment.