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>
115 lines
3.4 KiB
PHP
115 lines
3.4 KiB
PHP
<?php
|
|
|
|
use App\Services\Payment\Payone\PaymentMethodResolver;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
// --- Simple methods ---
|
|
|
|
it('resolves cc with pseudocardpan from context', function (): void {
|
|
$config = PaymentMethodResolver::resolve('cc', ['cc' => ['pseudocardpan' => 'PSEUDO123']]);
|
|
|
|
expect($config->toArray())->toMatchArray([
|
|
'clearingtype' => 'cc',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => '',
|
|
'request' => 'authorization',
|
|
'pseudocardpan' => 'PSEUDO123',
|
|
]);
|
|
});
|
|
|
|
it('resolves vor with no context needed', function (): void {
|
|
$config = PaymentMethodResolver::resolve('vor');
|
|
|
|
expect($config->toArray())->toMatchArray([
|
|
'clearingtype' => 'vor',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => '',
|
|
'request' => 'authorization',
|
|
]);
|
|
});
|
|
|
|
it('resolves elv with bank data from context', function (): void {
|
|
$ctx = [
|
|
'elv' => [
|
|
'mandate_identification' => 'MAND001',
|
|
'iban' => 'DE89370400440532013000',
|
|
'bic' => 'COBADEFFXXX',
|
|
'bankaccountholder' => 'Max Mustermann',
|
|
],
|
|
];
|
|
|
|
$config = PaymentMethodResolver::resolve('elv', $ctx);
|
|
|
|
expect($config->toArray())->toMatchArray([
|
|
'clearingtype' => 'elv',
|
|
'request' => 'authorization',
|
|
'iban' => 'DE89370400440532013000',
|
|
'bic' => 'COBADEFFXXX',
|
|
'mandate_identification' => 'MAND001',
|
|
'bankaccountholder' => 'Max Mustermann',
|
|
]);
|
|
});
|
|
|
|
// --- Compound methods ---
|
|
|
|
it('resolves wlt#PPE for PayPal via PAYONE', function (): void {
|
|
$config = PaymentMethodResolver::resolve('wlt#PPE');
|
|
|
|
expect($config->toArray())->toMatchArray([
|
|
'clearingtype' => 'wlt',
|
|
'wallettype' => 'PPE',
|
|
'onlinebanktransfertype' => '',
|
|
'request' => 'authorization',
|
|
]);
|
|
});
|
|
|
|
it('resolves wlt#PDT for paydirekt', function (): void {
|
|
$config = PaymentMethodResolver::resolve('wlt#PDT');
|
|
|
|
expect($config->toArray()['wallettype'])->toBe('PDT');
|
|
});
|
|
|
|
it('resolves sb#PNT for Sofort', function (): void {
|
|
$config = PaymentMethodResolver::resolve('sb#PNT');
|
|
|
|
expect($config->toArray())->toMatchArray([
|
|
'clearingtype' => 'sb',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => 'PNT',
|
|
'bankcountry' => 'DE',
|
|
'request' => 'authorization',
|
|
]);
|
|
});
|
|
|
|
it('resolves sb#GPY for giropay', function (): void {
|
|
$config = PaymentMethodResolver::resolve('sb#GPY');
|
|
|
|
expect($config->toArray()['onlinebanktransfertype'])->toBe('GPY');
|
|
});
|
|
|
|
it('resolves fnc#MIV for MIVITA invoice', function (): void {
|
|
$config = PaymentMethodResolver::resolve('fnc#MIV');
|
|
|
|
expect($config->toArray())->toMatchArray([
|
|
'clearingtype' => 'fnc',
|
|
'wallettype' => '',
|
|
'onlinebanktransfertype' => 'MIV',
|
|
'request' => 'authorization',
|
|
]);
|
|
});
|
|
|
|
// --- Error cases ---
|
|
|
|
it('throws for unknown simple payment method', function (): void {
|
|
PaymentMethodResolver::resolve('unknown');
|
|
})->throws(InvalidArgumentException::class, 'Unknown payment method: unknown');
|
|
|
|
it('throws for unknown compound type', function (): void {
|
|
PaymentMethodResolver::resolve('xyz#FOO');
|
|
})->throws(InvalidArgumentException::class, 'Unknown compound payment method type: xyz');
|
|
|
|
it('throws for unknown fnc subtype', function (): void {
|
|
PaymentMethodResolver::resolve('fnc#PYV');
|
|
})->throws(InvalidArgumentException::class, 'Unknown fnc subtype: PYV');
|