mivita/app/Services/Payment/Payone/DTOs/PayonePaymentResult.php
Kevin ccc6f85809 Payment Phase R: PAYONE-Integration entflechten (R1–R7 + Review)
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>
2026-06-10 13:42:45 +00:00

67 lines
1.8 KiB
PHP

<?php
namespace App\Services\Payment\Payone\DTOs;
use App\Models\ShoppingPayment;
class PayonePaymentResult
{
/**
* @param array<string, mixed> $rawResponse
*/
public function __construct(
public readonly string $status,
public readonly array $rawResponse,
public readonly string $txid = '',
public readonly int $userid = 0,
public readonly ?string $redirectUrl = null,
public readonly ?string $errorMessage = null,
public readonly ?string $customerMessage = null,
public readonly ?string $errorCode = null,
public readonly ?ShoppingPayment $shoppingPayment = null,
) {}
public function isApproved(): bool
{
return $this->status === 'APPROVED';
}
public function isRedirect(): bool
{
return $this->status === 'REDIRECT';
}
public function isError(): bool
{
return $this->status === 'ERROR';
}
public function isValid(): bool
{
return $this->status === 'VALID';
}
/** @return array<string, mixed> */
public function toArray(): array
{
return $this->rawResponse;
}
/**
* @param array<string, mixed> $response
*/
public static function fromResponse(array $response, ?ShoppingPayment $shoppingPayment = null): self
{
return new self(
status: $response['status'] ?? 'UNKNOWN',
rawResponse: $response,
txid: (string) ($response['txid'] ?? ''),
userid: (int) ($response['userid'] ?? 0),
redirectUrl: $response['redirecturl'] ?? null,
errorMessage: $response['errormessage'] ?? null,
customerMessage: $response['customermessage'] ?? null,
errorCode: $response['errorcode'] ?? null,
shoppingPayment: $shoppingPayment,
);
}
}