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

feat: check API configuration and display error msg if misconfigured

Übergeordneter 2e6a0d5d
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
...@@ -62,6 +62,10 @@ define('package/quiqqer/payment-amazon/bin/controls/PaymentDisplay', [ ...@@ -62,6 +62,10 @@ define('package/quiqqer/payment-amazon/bin/controls/PaymentDisplay', [
var self = this; var self = this;
var Elm = this.getElm(); var Elm = this.getElm();
if (!Elm.getElement('.quiqqer-payment-amazon-content')) {
return;
}
this.$MsgElm = Elm.getElement('.quiqqer-payment-amazon-message'); this.$MsgElm = Elm.getElement('.quiqqer-payment-amazon-message');
this.$AuthBtnElm = Elm.getElement('#quiqqer-payment-amazon-btn'); this.$AuthBtnElm = Elm.getElement('#quiqqer-payment-amazon-btn');
this.$WalletElm = Elm.getElement('#quiqqer-payment-amazon-wallet'); this.$WalletElm = Elm.getElement('#quiqqer-payment-amazon-wallet');
......
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
<de><![CDATA[Bezahlung der Bestellung #[oderId]]]></de> <de><![CDATA[Bezahlung der Bestellung #[oderId]]]></de>
<en><![CDATA[Payment of order #[orderId]]]></en> <en><![CDATA[Payment of order #[orderId]]]></en>
</locale> </locale>
<locale name="controls.PaymentDisplay.configuration_error">
<de><![CDATA[Die Zahlung mit Amazon Pay kann zur Zeit leider nicht durchgeführt werden. Bitte wählen Sie eine andere Zahlungsweise.]]></de>
<en><![CDATA[Unfortunately, Amazon Pay can not be used at the moment. Please choose a different method of payment.]]></en>
</locale>
<!-- Settings --> <!-- Settings -->
<locale name="settings.menu.title"> <locale name="settings.menu.title">
...@@ -223,10 +227,6 @@ ...@@ -223,10 +227,6 @@
<de><![CDATA[Bei der Authentifizierung mit Amazon ist ein Fehler aufgetreten. Bitte versuchen Sie erneut, sich mit Ihrem Amazon-Konto anzumelden oder wählen Sie eine andere Zahlungsweise.]]></de> <de><![CDATA[Bei der Authentifizierung mit Amazon ist ein Fehler aufgetreten. Bitte versuchen Sie erneut, sich mit Ihrem Amazon-Konto anzumelden oder wählen Sie eine andere Zahlungsweise.]]></de>
<en><![CDATA[There was an error authenticating with Amazon. Please try again to sign in with your Amazon account or choose another form of payment.]]></en> <en><![CDATA[There was an error authenticating with Amazon. Please try again to sign in with your Amazon account or choose another form of payment.]]></en>
</locale> </locale>
<locale name="controls.PaymentDisplay.configuration_error">
<de><![CDATA[Die Zahlung mit Amazon Pay kann zur Zeit leider nicht durchgeführt werden. Bitte wählen Sie eine andere Zahlungsweise.]]></de>
<en><![CDATA[Unfortunately, Amazon Pay can not be used at the moment. Please choose a different method of payment.]]></en>
</locale>
<locale name="controls.PaymentDisplay.info"> <locale name="controls.PaymentDisplay.info">
<de><![CDATA[Bitte klicken Sie auf die "amazon pay"-Schaltfläche und loggen sich mit Ihrem Amazon-Konto ein, um mit dem Zahlungsprozess fortzufahren.]]></de> <de><![CDATA[Bitte klicken Sie auf die "amazon pay"-Schaltfläche und loggen sich mit Ihrem Amazon-Konto ein, um mit dem Zahlungsprozess fortzufahren.]]></de>
<en><![CDATA[Please click the "amazon pay" button and sign in with your Amazon account to continue with the payment process.]]></en> <en><![CDATA[Please click the "amazon pay" button and sign in with your Amazon account to continue with the payment process.]]></en>
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
<p>{locale group="quiqqer/payment-amazon" var="PaymentDisplay.no_javascript"}</p> <p>{locale group="quiqqer/payment-amazon" var="PaymentDisplay.no_javascript"}</p>
</noscript> </noscript>
<style> {if !$apiSetUp}
.quiqqer-order-ordering-step { <p class="message-error">
height:500px !important; {locale group="quiqqer/payment-amazon" var="controls.PaymentDisplay.configuration_error"}
} </p>
</style> {else}
<div class="quiqqer-payment-amazon-message"></div> <div class="quiqqer-payment-amazon-message"></div>
<div class="quiqqer-payment-amazon-content"> <div class="quiqqer-payment-amazon-content">
<div id="quiqqer-payment-amazon-btn" data-size="{$btn_size}" data-color="{$btn_color}"></div> <div id="quiqqer-payment-amazon-btn" data-size="{$btn_size}" data-color="{$btn_color}"></div>
<div id="quiqqer-payment-amazon-wallet"></div> <div id="quiqqer-payment-amazon-wallet"></div>
<div id="quiqqer-payment-amazon-btn-pay" data-price="{$display_price}"></div> <div id="quiqqer-payment-amazon-btn-pay" data-price="{$display_price}"></div>
</div> </div>
\ No newline at end of file {/if}
\ No newline at end of file
...@@ -50,7 +50,8 @@ class PaymentDisplay extends QUI\Control ...@@ -50,7 +50,8 @@ class PaymentDisplay extends QUI\Control
$Engine->assign(array( $Engine->assign(array(
'btn_size' => Provider::getWidgetsSetting('btn_size'), 'btn_size' => Provider::getWidgetsSetting('btn_size'),
'btn_color' => Provider::getWidgetsSetting('btn_color'), 'btn_color' => Provider::getWidgetsSetting('btn_color'),
'display_price' => $PriceCalculation->getSum()->formatted() 'display_price' => $PriceCalculation->getSum()->formatted(),
'apiSetUp' => $this->isApiSetUp()
)); ));
$this->setJavaScriptControlOption('orderhash', $Order->getHash()); $this->setJavaScriptControlOption('orderhash', $Order->getHash());
...@@ -60,4 +61,31 @@ class PaymentDisplay extends QUI\Control ...@@ -60,4 +61,31 @@ class PaymentDisplay extends QUI\Control
return $Engine->fetch(dirname(__FILE__) . '/PaymentDisplay.html'); 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;
}
} }
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