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 @@ ...@@ -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> <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> <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>
<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"> <locale name="settings.category.payment.title">
<de><![CDATA[Zahlungsprozess]]></de> <de><![CDATA[Zahlungsprozess]]></de>
<en><![CDATA[Payment process]]></en> <en><![CDATA[Payment process]]></en>
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
<type><![CDATA[boolean]]></type> <type><![CDATA[boolean]]></type>
<defaultvalue>1</defaultvalue> <defaultvalue>1</defaultvalue>
</conf> </conf>
<conf name="use_ipn_handler">
<type><![CDATA[boolean]]></type>
<defaultvalue>0</defaultvalue>
</conf>
</section> </section>
<section name="payment"> <section name="payment">
...@@ -109,6 +113,15 @@ ...@@ -109,6 +113,15 @@
</option> </option>
</select> </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"> <input conf="api.sandbox" type="checkbox">
<text> <text>
<locale group="quiqqer/payment-amazon" var="settings.api.sandbox.title"/> <locale group="quiqqer/payment-amazon" var="settings.api.sandbox.title"/>
......
...@@ -26,6 +26,10 @@ class Events ...@@ -26,6 +26,10 @@ class Events
*/ */
public static function onPaymentsGatewayReadRequest(Gateway $Gateway) public static function onPaymentsGatewayReadRequest(Gateway $Gateway)
{ {
if (!Provider::isIpnHandlingActivated()) {
return;
}
$headers = getallheaders(); $headers = getallheaders();
$body = file_get_contents('php://input'); $body = file_get_contents('php://input');
...@@ -74,8 +78,7 @@ class Events ...@@ -74,8 +78,7 @@ class Events
$Gateway->setOrder($Order); $Gateway->setOrder($Order);
$Gateway->enableGatewayPayment(); $Gateway->enableGatewayPayment();
// now the Gateway can call executeGatewayPayment() of the // now the Gateway can call \QUI\ERP\Payments\Amazon->executeGatewayPayment()
// payment method that is assigned to the Order
} }
/** /**
......
...@@ -11,6 +11,7 @@ use AmazonPay\ResponseInterface; ...@@ -11,6 +11,7 @@ use AmazonPay\ResponseInterface;
use QUI; use QUI;
use QUI\ERP\Order\AbstractOrder; use QUI\ERP\Order\AbstractOrder;
use QUI\ERP\Order\Handler as OrderHandler; use QUI\ERP\Order\Handler as OrderHandler;
use QUI\ERP\Accounting\Payments\Gateway\Gateway;
/** /**
* Class Payment * Class Payment
...@@ -526,9 +527,19 @@ class Payment extends QUI\ERP\Accounting\Payments\Api\AbstractPayment ...@@ -526,9 +527,19 @@ class Payment extends QUI\ERP\Accounting\Payments\Api\AbstractPayment
$Order->setPaymentData(self::ATTR_ORDER_CAPTURED, true); $Order->setPaymentData(self::ATTR_ORDER_CAPTURED, true);
$Order->update(QUI::getUsers()->getSystemUser()); $Order->update(QUI::getUsers()->getSystemUser());
$Gateway = Gateway::getInstance();
$Gateway->setOrder($Order);
$this->executeGatewayPayment($Gateway);
break; break;
case 'Pending':
// @todo pending status // @todo pending status
if (Provider::isIpnHandlingActivated()) {
// etc.
}
break;
default: default:
$reason = $status['ReasonCode']; $reason = $status['ReasonCode'];
......
...@@ -80,6 +80,16 @@ class Provider extends AbstractPaymentProvider ...@@ -80,6 +80,16 @@ class Provider extends AbstractPaymentProvider
return $Conf->get('widgets', $setting); 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 * Check if the Amazon Pay API settings are correct
* *
...@@ -94,6 +104,7 @@ class Provider extends AbstractPaymentProvider ...@@ -94,6 +104,7 @@ class Provider extends AbstractPaymentProvider
foreach ($apiSettings as $k => $v) { foreach ($apiSettings as $k => $v) {
switch ($k) { switch ($k) {
case 'sandbox': case 'sandbox':
case 'use_ipn_handler':
continue 2; continue 2;
break; 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