- Provider-Status/Uptime: Stripe-Kachel aktiviert; payment:check-uptime prüft zusätzlich api.stripe.com/v1/ (401 ohne Key = erreichbar) inkl. Auto-Incident - Zahlungen: Anbieter-Filter, Provider-Badges, Umsatz je Provider, Stripe-Dashboard-Deep-Links (ShoppingPayment/PaymentTransaction:: stripeDashboardUrl, pi_-Guard, testmodus-bewusst) - Rohe Transaktionen: Anbieter-Filter/-Spalte, Erfolgsraten je Anbieter; Bugfix: Stringable-Vergleich ließ den txaction-Filter immer mit leerem Wert greifen — Liste war dauerhaft leer - Neue Kachel „Abos je Anbieter" (Index + GF-Ansicht) mit Fehlerzählern und Stripe-Anteil-Fortschrittsbalken (Auslaufmodell PAYONE → Stripe ablesbar) - Incident-Kachel weist Stripe/PAYONE getrennt aus; Log-Viewer mit Kanal-Umschalter stripe/payone - Plan-Doku: S7.4-Umsetzungsstatus, Abo-Go-Live 2026-07-10 vermerkt Tests: PaymentDashboardProviderTest (9 neu), Dashboard-Suite 49 grün. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
138 lines
5.3 KiB
PHP
138 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* App\Models\PaymentTransaction
|
|
*
|
|
* @property int $id
|
|
* @property int $shopping_payment_id
|
|
* @property string $request
|
|
* @property int|null $txid
|
|
* @property int|null $userid
|
|
* @property string|null $status
|
|
* @property string|null $key
|
|
* @property string|null $txaction
|
|
* @property array|null $transmitted_data
|
|
* @property int|null $errorcode
|
|
* @property string|null $errormessage
|
|
* @property string|null $customermessage
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property-read ShoppingPayment $shopping_payment
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereCustomermessage($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereErrorcode($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereErrormessage($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereKey($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereRequest($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereShoppingPaymentId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereTransmittedData($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereTxaction($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereTxid($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereUserid($value)
|
|
*
|
|
* @property string|null $mode
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereMode($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class PaymentTransaction extends Model
|
|
{
|
|
protected $table = 'payment_transactions';
|
|
|
|
protected $casts = [
|
|
'transmitted_data' => 'array',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'shopping_payment_id',
|
|
'provider',
|
|
'request',
|
|
'txid',
|
|
'userid',
|
|
'status',
|
|
'key',
|
|
'txaction',
|
|
'transmitted_data',
|
|
'errorcode',
|
|
'errormessage',
|
|
'customermessage',
|
|
'mode',
|
|
];
|
|
|
|
public function shopping_payment()
|
|
{
|
|
return $this->belongsTo('App\Models\ShoppingPayment', 'shopping_payment_id');
|
|
}
|
|
|
|
/**
|
|
* Deep-Link ins Stripe-Dashboard für Stripe-Transaktionen
|
|
* (txid trägt dort die PaymentIntent-ID, siehe StripeTransactionRecorder).
|
|
*/
|
|
public function stripeDashboardUrl(): ?string
|
|
{
|
|
if ($this->provider !== 'stripe' || ! str_starts_with((string) $this->txid, 'pi_')) {
|
|
return null;
|
|
}
|
|
|
|
$base = $this->mode === 'test' ? 'https://dashboard.stripe.com/test' : 'https://dashboard.stripe.com';
|
|
|
|
return $base.'/payments/'.$this->txid;
|
|
}
|
|
|
|
/**
|
|
* Returns a human-readable description for known PAYONE error codes.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public static function payoneErrorDescriptions(): array
|
|
{
|
|
return [
|
|
2 => 'Allgemeiner Fehler',
|
|
4 => 'Karte gesperrt',
|
|
5 => 'Zahlung abgelehnt',
|
|
12 => 'Ungültige Kartennummer',
|
|
14 => 'Ungültige Kartendaten',
|
|
33 => 'Karte abgelaufen',
|
|
34 => 'Karte gesperrt/gestohlen',
|
|
55 => 'Falsche PIN',
|
|
56 => 'Kunde hat abgebrochen',
|
|
58 => 'Transaktion nicht erlaubt',
|
|
62 => 'Karte für internationale Transaktionen nicht zugelassen',
|
|
104 => 'Karte für Online-Zahlungen nicht erlaubt',
|
|
105 => 'Karte ungültig',
|
|
120 => 'Falsche Prüfziffer (CVV)',
|
|
130 => 'Limit überschritten',
|
|
131 => 'Währung nicht unterstützt',
|
|
135 => 'Bank antwortet nicht',
|
|
136 => 'Bank nicht gefunden',
|
|
137 => 'Betrag stimmt nicht überein',
|
|
900 => '3D-Secure Authentifizierung fehlgeschlagen',
|
|
902 => 'Bank hat abgelehnt',
|
|
970 => 'Keine Antwort (Timeout)',
|
|
4218 => 'Karte unter Betrugsverdacht',
|
|
4219 => 'Transaktion von Kartenaussteller abgelehnt',
|
|
];
|
|
}
|
|
|
|
public function getErrorDescriptionAttribute(): ?string
|
|
{
|
|
if (! $this->errorcode) {
|
|
return null;
|
|
}
|
|
|
|
return self::payoneErrorDescriptions()[(int) $this->errorcode] ?? null;
|
|
}
|
|
}
|