feat: implement Telepagos webhook handling with request validation and service integration

This commit is contained in:
2026-07-06 09:57:45 -03:00
parent 403caf77f5
commit 3731cd67fe
9 changed files with 329 additions and 0 deletions

View File

@@ -57,4 +57,33 @@ class Purchase extends Model
{
return $this->hasMany(PurchaseItem::class, 'compra_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne<TelepagosQr, $this>
*/
public function telepagosQr()
{
return $this->hasOne(TelepagosQr::class, 'compra_id');
}
/**
* @return HasMany<TelepagosPayment, $this>
*/
public function telepagosPayments(): HasMany
{
return $this->hasMany(TelepagosPayment::class, 'compra_id');
}
public function getTotalAmount(): float
{
return (float) $this->items()->sum('total');
}
public function finalize(): void
{
$this->update([
'status' => 'pagado', // Or the equivalent final status in your system
'payment_status' => 'paid',
]);
}
}