diff --git a/src/QUI/ERP/Payments/Amazon/PaymentDisplay.php b/src/QUI/ERP/Payments/Amazon/PaymentDisplay.php index 7d455d8446637943e24364b1dae3f208e70be215..ea37f2f2f16721fa22ea21fbe5b00e442161be87 100644 --- a/src/QUI/ERP/Payments/Amazon/PaymentDisplay.php +++ b/src/QUI/ERP/Payments/Amazon/PaymentDisplay.php @@ -20,7 +20,7 @@ class PaymentDisplay extends QUI\Control * * @param array $attributes */ - public function __construct(array $attributes = array()) + public function __construct(array $attributes = []) { parent::__construct($attributes); @@ -47,12 +47,12 @@ class PaymentDisplay extends QUI\Control $Order = $this->getAttribute('Order'); $PriceCalculation = $Order->getPriceCalculation(); - $Engine->assign(array( + $Engine->assign([ 'btn_size' => Provider::getWidgetsSetting('btn_size'), 'btn_color' => Provider::getWidgetsSetting('btn_color'), 'display_price' => $PriceCalculation->getSum()->formatted(), - 'apiSetUp' => $this->isApiSetUp() - )); + 'apiSetUp' => Provider::isApiSetUp() + ]); $this->setJavaScriptControlOption('orderhash', $Order->getHash()); @@ -61,31 +61,4 @@ class PaymentDisplay extends QUI\Control return $Engine->fetch(dirname(__FILE__) . '/PaymentDisplay.html'); } - - /** - * Check if the Amazon Pay API settings are correct - * - * @return bool - * @throws QUI\Exception - */ - protected function isApiSetUp() - { - $Conf = QUI::getPackage('quiqqer/payment-amazon')->getConfig(); - $apiSettings = $Conf->getSection('api'); - - foreach ($apiSettings as $k => $v) { - if (empty($v)) { - QUI\System\Log::addError( - 'Your Amazon Pay API credentials seem to be (partially) missing.' - . ' Amazon Pay CAN NOT be used at the moment. Please enter all your' - . ' API credentials. See https://dev.quiqqer.com/quiqqer/payment-amazon/wikis/api-configuration' - . ' for further instructions.' - ); - - return false; - } - } - - return true; - } } diff --git a/src/QUI/ERP/Payments/Amazon/Provider.php b/src/QUI/ERP/Payments/Amazon/Provider.php index b2613e9a8f6edb064cdd7f991123810fd666255c..0531c789c9e5ecc9cba4c4d6657b22acfffbdd24 100644 --- a/src/QUI/ERP/Payments/Amazon/Provider.php +++ b/src/QUI/ERP/Payments/Amazon/Provider.php @@ -79,4 +79,37 @@ class Provider extends AbstractPaymentProvider return $Conf->get('widgets', $setting); } + + /** + * Check if the Amazon Pay API settings are correct + * + * @return bool + * @throws QUI\Exception + */ + public static function isApiSetUp() + { + $Conf = QUI::getPackage('quiqqer/payment-amazon')->getConfig(); + $apiSettings = $Conf->getSection('api'); + + foreach ($apiSettings as $k => $v) { + switch ($k) { + case 'sandbox': + continue 2; + break; + } + + if (empty($v)) { + QUI\System\Log::addError( + 'Your Amazon Pay API credentials seem to be (partially) missing.' + . ' Amazon Pay CAN NOT be used at the moment. Please enter all your' + . ' API credentials. See https://dev.quiqqer.com/quiqqer/payment-amazon/wikis/api-configuration' + . ' for further instructions.' + ); + + return false; + } + } + + return true; + } }