- ProviderInterface/AbstractProvider: Vorgang mit Uhrzeit+Session (payment_transactions), Mail und Warenkorb erst nach Zahlung, idempotentes markPaid, Betragsabgleich, shop_event + PG payment_log - Secrets verschluesselt (libsodium) in MySQL, Schluessel ausserhalb Docroot - Cashdesk: ?payment_return/?payment_cancel, Pending-Riegel, zahlung_erst_spaeter() - Backend Zahlart-Editor: Einstellungen speichern (war ohne Empfaenger), Secret-Felder - payment_webhook.php (Standalone), cli.php (init-key, secret, reconcile, status) - PayPal-v2-Blaupause vom Juli entfernt
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Webhook-Endpunkt fuer alle Zahlungsanbieter: /payment_webhook.php?p=<module>
|
|
*
|
|
* Server-zu-Server, keine Session. Der Provider prueft die Signatur selbst und
|
|
* entscheidet, was mit dem Ereignis passiert. Antwort 2xx = angenommen, sonst
|
|
* stellt der Anbieter erneut zu.
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/core/payments/bootstrap.php';
|
|
|
|
$module = isset($_GET['p']) ? (string) $_GET['p'] : '';
|
|
$provider = \Payments\Registry::get($module, $base_object);
|
|
if (!$provider) {
|
|
\http_response_code(404);
|
|
echo 'unknown provider';
|
|
exit;
|
|
}
|
|
|
|
$rawBody = (string) \file_get_contents('php://input');
|
|
$headers = [];
|
|
foreach ($_SERVER as $key => $value) {
|
|
if (\strncmp($key, 'HTTP_', 5) === 0) {
|
|
$headers[\strtolower(\str_replace('_', '-', \substr($key, 5)))] = (string) $value;
|
|
}
|
|
}
|
|
|
|
try {
|
|
$status = $provider->onWebhook($headers, $rawBody);
|
|
} catch (\Throwable $e) {
|
|
\error_log('payment_webhook ' . $module . ': ' . $e->getMessage());
|
|
$status = 500;
|
|
}
|
|
|
|
\http_response_code($status);
|
|
echo $status < 300 ? 'ok' : 'rejected';
|