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

feat: IPN handling optional

Übergeordneter 776cdfd9
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -123,6 +123,14 @@
<de><![CDATA[Sandbox-Modus aktivieren (Zahlungen werden nicht tatsächlich durchgeführt sondern nur über eine Testumgebung; nur aktivieren, wenn der Zahlungsprozess mit Amazon Pay getestet werden soll!)]]></de>
<en><![CDATA[Enable sandbox mode (payments are not actually made but only through a test environment, only enable to test the payment process with Amazon Pay!)]]></en>
</locale>
<locale name="settings.api.use_ipn_handler.title">
<de><![CDATA[IPN-Handling]]></de>
<en><![CDATA[IPN Handling]]></en>
</locale>
<locale name="settings.api.use_ipn_handler.description" html="true">
<de><![CDATA[<b>Aktiviere asnychronen Empfang von Nachrichten seitens Amazon bzgl. des Status von Zahlungsoperationen</b> (notwendig, wenn Anweisung zur Zahlungsdurchführung später als 7 Tage nach Zahlungsautorisierung erfolgt; erfordert Einrichtung einer von außen erreichbaren <a href="https://pay.amazon.com/de/developer/documentation/lpwa/201952050" target="_blank">IPN-URL</a>)]]></de>
<en><![CDATA[<b>Enable asynchronous reception of Amazon messages regarding the status of payment capture requests</b> (necessary if payment capture requests are performed more than 7 days after payment authorization requests; requires an <a href="https://pay.amazon.com/de/developer/documentation/lpwa/201952050" target="_blank">IPN-URL</a> to be set up)]]></en>
</locale>
<locale name="settings.category.payment.title">
<de><![CDATA[Zahlungsprozess]]></de>
<en><![CDATA[Payment process]]></en>
......
......@@ -25,6 +25,10 @@
<type><![CDATA[boolean]]></type>
<defaultvalue>1</defaultvalue>
</conf>
<conf name="use_ipn_handler">
<type><![CDATA[boolean]]></type>
<defaultvalue>0</defaultvalue>
</conf>
</section>
<section name="payment">
......@@ -109,6 +113,15 @@
</option>
</select>
<input conf="api.use_ipn_handler" type="checkbox">
<text>
<locale group="quiqqer/payment-amazon" var="settings.api.use_ipn_handler.title"/>
</text>
<description>
<locale group="quiqqer/payment-amazon" var="settings.api.use_ipn_handler.description"/>
</description>
</input>
<input conf="api.sandbox" type="checkbox">
<text>
<locale group="quiqqer/payment-amazon" var="settings.api.sandbox.title"/>
......
......@@ -26,6 +26,10 @@ class Events
*/
public static function onPaymentsGatewayReadRequest(Gateway $Gateway)
{
if (!Provider::isIpnHandlingActivated()) {
return;
}
$headers = getallheaders();
$body = file_get_contents('php://input');
......@@ -74,8 +78,7 @@ class Events
$Gateway->setOrder($Order);
$Gateway->enableGatewayPayment();
// now the Gateway can call executeGatewayPayment() of the
// payment method that is assigned to the Order
// now the Gateway can call \QUI\ERP\Payments\Amazon->executeGatewayPayment()
}
/**
......
......@@ -11,6 +11,7 @@ use AmazonPay\ResponseInterface;
use QUI;
use QUI\ERP\Order\AbstractOrder;
use QUI\ERP\Order\Handler as OrderHandler;
use QUI\ERP\Accounting\Payments\Gateway\Gateway;
/**
* Class Payment
......@@ -526,9 +527,19 @@ class Payment extends QUI\ERP\Accounting\Payments\Api\AbstractPayment
$Order->setPaymentData(self::ATTR_ORDER_CAPTURED, true);
$Order->update(QUI::getUsers()->getSystemUser());
$Gateway = Gateway::getInstance();
$Gateway->setOrder($Order);
$this->executeGatewayPayment($Gateway);
break;
case 'Pending':
// @todo pending status
if (Provider::isIpnHandlingActivated()) {
// etc.
}
break;
default:
$reason = $status['ReasonCode'];
......
......@@ -80,6 +80,16 @@ class Provider extends AbstractPaymentProvider
return $Conf->get('widgets', $setting);
}
/**
* Check if IPN handling is activated in the module settings
*
* @return bool
*/
public static function isIpnHandlingActivated()
{
return boolval(self::getApiSetting('use_ipn_handler'));
}
/**
* Check if the Amazon Pay API settings are correct
*
......@@ -94,6 +104,7 @@ class Provider extends AbstractPaymentProvider
foreach ($apiSettings as $k => $v) {
switch ($k) {
case 'sandbox':
case 'use_ipn_handler':
continue 2;
break;
}
......
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