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>
79 lines
3.1 KiB
PHP
79 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Payment\Payone;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
class PaymentMethodResolver
|
|
{
|
|
/**
|
|
* Resolves a payment method string into PAYONE method parameters.
|
|
*
|
|
* Supported formats:
|
|
* Simple: 'cc' | 'elv' | 'vor'
|
|
* Compound: 'wlt#PPE' | 'wlt#PDT' | 'sb#GPY' | 'sb#PNT' | 'fnc#MIV'
|
|
*
|
|
* @param array<string, mixed> $context Extra data required for specific methods (e.g. cc.pseudocardpan, elv.iban).
|
|
*
|
|
* @throws InvalidArgumentException for unknown method strings.
|
|
*/
|
|
public static function resolve(string $paymentMethod, array $context = []): PayoneMethodConfig
|
|
{
|
|
if (str_contains($paymentMethod, '#')) {
|
|
[$type, $subtype] = explode('#', $paymentMethod, 2);
|
|
|
|
return match ($type) {
|
|
'wlt' => new PayoneMethodConfig([
|
|
'clearingtype' => 'wlt',
|
|
'wallettype' => $subtype,
|
|
'onlinebanktransfertype' => '',
|
|
'request' => 'authorization',
|
|
]),
|
|
'sb' => new PayoneMethodConfig([
|
|
'clearingtype' => 'sb',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => $subtype,
|
|
'bankcountry' => 'DE',
|
|
'request' => 'authorization',
|
|
]),
|
|
'fnc' => match ($subtype) {
|
|
'MIV' => new PayoneMethodConfig([
|
|
'clearingtype' => 'fnc',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => 'MIV',
|
|
'request' => 'authorization',
|
|
]),
|
|
default => throw new InvalidArgumentException("Unknown fnc subtype: {$subtype}"),
|
|
},
|
|
default => throw new InvalidArgumentException("Unknown compound payment method type: {$type}"),
|
|
};
|
|
}
|
|
|
|
return match ($paymentMethod) {
|
|
'cc' => new PayoneMethodConfig([
|
|
'clearingtype' => 'cc',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => '',
|
|
'request' => 'authorization',
|
|
'pseudocardpan' => $context['cc']['pseudocardpan'] ?? '',
|
|
]),
|
|
'elv' => new PayoneMethodConfig([
|
|
'clearingtype' => 'elv',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => '',
|
|
'request' => 'authorization',
|
|
'mandate_identification' => $context['elv']['mandate_identification'] ?? '',
|
|
'iban' => $context['elv']['iban'] ?? '',
|
|
'bic' => $context['elv']['bic'] ?? '',
|
|
'bankaccountholder' => $context['elv']['bankaccountholder'] ?? '',
|
|
]),
|
|
'vor' => new PayoneMethodConfig([
|
|
'clearingtype' => 'vor',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => '',
|
|
'request' => 'authorization',
|
|
]),
|
|
default => throw new InvalidArgumentException("Unknown payment method: {$paymentMethod}"),
|
|
};
|
|
}
|
|
}
|