Skip to content
Code-Schnipsel Gruppen Projekte
Commit 3c37fa39 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

refactor: moved isApiSetUp() from PaymentDisplay to Provider class; fix: isApiSetup()

Übergeordneter adfd4eb2
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -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;
}
}
......@@ -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;
}
}
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren