feat: implement Telepagos webhook handling with request validation and service integration
This commit is contained in:
@@ -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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user