diff --git a/README.md b/README.md index acd9f37a..39e3620c 100644 --- a/README.md +++ b/README.md @@ -187,5 +187,29 @@ echo ($transaction->isPaid() || $transaction->isAuthorized())?'Paid':'Not paid'; ``` +### Failover gateway +In the event of an outage, set the failover gateway like this: + +``` +use Paynl\Config; +use Paynl\Transaction; + +require __DIR__ . '/vendor/autoload.php'; + +Config::setTokenCode('AT-####-####'); +Config::setApiToken('****************************************'); +Config::setServiceId('SL-####-####'); + +# Setting Failover gateway (for available cores, call Config::getCores()) +Config::setCore( Config::CORE2 ); + +# Or for SDK versions lower then 1.6.7, use: +Config::setApiBase('https://rest.achterelkebetaling.nl'); + +$requiredArguments = []; // See: Start a transaction example +$result = Transaction::start($requiredArguments); +``` + + ### Testing Please run ```vendor/bin/phpunit --bootstrap vendor/autoload.php tests/``` to test the application diff --git a/composer.json b/composer.json index ec6bdab3..c193f6a9 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "paynl/sdk", - "version": "1.6.6", + "version": "1.6.7", "require": { "php-curl-class/php-curl-class": "^8.3||^9.0", "ext-json": "*", diff --git a/src/Config.php b/src/Config.php index b0bd7090..7421aa02 100644 --- a/src/Config.php +++ b/src/Config.php @@ -11,6 +11,12 @@ */ class Config { + const CORE1 = 'https://rest-api.pay.nl'; + const CORE1_TEXT = 'Pay.nl (Default)'; + const CORE2 = 'https://rest.achterelkebetaling.nl'; + const CORE2_TEXT = 'Achterelkebetaling.'; + const CORE3 = 'https://rest.payments.nl'; + const CORE3_TEXT = 'Payments.nl'; /** * @var string The token code (AT-xxxx-xxxx) @@ -70,9 +76,9 @@ class Config public static function getCores() { return [ - 'https://rest-api.pay.nl' => 'Pay.nl (Default)', - 'https://rest.achterelkebetaling.nl' => 'Achterelkebetaling.nl', - 'https://rest.payments.nl' => 'Payments.nl', + self::CORE1 => self::CORE1_TEXT, + self::CORE2 => self::CORE2_TEXT, + self::CORE3 => self::CORE3_TEXT, ]; } @@ -132,6 +138,15 @@ public static function setApiBase($apiBase) self::$apiBase = $apiBase; } + /** + * @param $core + * @return void + */ + public static function setCore($core) + { + self::setApiBase($core); + } + /** * @param string $paymentApiBase */