Strangler-Refactoring der PAYONE-Zahlungslogik in eine testbare
Service-Schicht, ohne Verhalten in Checkout/Cron/IPN zu ändern.
Neue Services (app/Services/Payment/Payone):
- PayonePaymentService (+ PayonePaymentResult-DTO) für CC-/SEPA-Check
und Abo-Abbuchung
- PayoneRequestBuilder, PaymentMethodResolver, PayoneMethodConfig
- PayoneTransactionRecorder: zentrale PaymentTransaction-Erstellung
(API-Response, Invoice, Webhook) inkl. PCI-Redaction (cardpan/cardcvc2)
- PayoneWebhookHandler (+ PayoneWebhookResult): IPN/TSOK-Logik aus
Api\PayoneController; response('TSOK') statt echo/exit
- PayoneTransportException + Handler-Mapping (403) statt abort() im Service
Hotfixes (R1): var_dump/exit & bare exit() entfernt, Log-Redaction.
Security (R-Review):
- PAYONE_KEY_HASH (MD5-Hash, kein Klartext) mit Boot-Hard-Fail; schließt
zugleich die ''-Webhook-Bypass-Lücke. Artisan-Command payone:hash-key
(verdeckte Eingabe, optional --write) zur Hash-Erzeugung.
- Webhook: txaction Pflichtfeld, mode-Fallback auf payment->mode.
Pay\PayoneController ist @deprecated-Fassade (614 → 328 Zeilen),
delegiert an Services via Container-Singleton.
Migration: fehlende Spalte shopping_payments.carddata nachgezogen.
Tests: 47 grün (PayonePaymentService, Recorder, Webhook, Resolver,
TransportException, hash-key). End-to-End im Test-System verifiziert
(siehe dev/2026-06-09-payments).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Payment\Payone\DTOs;
|
|
|
|
class PayoneWebhookResult
|
|
{
|
|
private function __construct(
|
|
public readonly string $response,
|
|
public readonly bool $processed,
|
|
public readonly ?string $rejectionCode = null,
|
|
public readonly bool $duplicate = false,
|
|
public readonly ?string $txaction = null,
|
|
public readonly bool $paid = false,
|
|
public readonly bool $mailSent = false,
|
|
public readonly bool $sendLink = false,
|
|
) {}
|
|
|
|
/**
|
|
* Webhook was rejected before processing (validation/key/price/relation error).
|
|
* PAYONE still receives "TSOK" so it stops retrying the malformed callback.
|
|
*/
|
|
public static function rejected(string $code): self
|
|
{
|
|
return new self(response: 'TSOK', processed: false, rejectionCode: $code);
|
|
}
|
|
|
|
/**
|
|
* Webhook is a duplicate of an already-processed txaction; ignored.
|
|
*/
|
|
public static function duplicateIgnored(string $txaction): self
|
|
{
|
|
return new self(response: 'TSOK', processed: false, duplicate: true, txaction: $txaction);
|
|
}
|
|
|
|
/**
|
|
* Webhook was processed: transaction recorded, status updated, side effects applied.
|
|
*/
|
|
public static function processed(string $txaction, bool $paid, bool $mailSent, bool $sendLink): self
|
|
{
|
|
return new self(
|
|
response: 'TSOK',
|
|
processed: true,
|
|
txaction: $txaction,
|
|
paid: $paid,
|
|
mailSent: $mailSent,
|
|
sendLink: $sendLink,
|
|
);
|
|
}
|
|
}
|