This commit is contained in:
2026-07-16 10:00:12 -03:00
7 changed files with 102 additions and 4 deletions

View File

@@ -54,7 +54,7 @@ class TelepagosWebhookService
$dni = substr($cuit, 2, -1);
$compra = Purchase::where('tenant_codigo', $tenantCodigo)
->whereRaw("REPLACE(dni, '.', '') = ?", [$dni])
->where('payer_dni', $dni)
->whereIn('status', [Purchase::STATUS_CREATED, Purchase::STATUS_PENDING_PAYMENT])
->where('payment_method', 'transfer')
->where('total', $amount)

View File

@@ -68,10 +68,16 @@ class PurchaseController extends Controller
$method = $request->validated('method');
$totalAmount = $compra->calculateCurrentTotalAmount();
$compra->update([
$purchaseUpdate = [
'payment_method' => $method,
'total' => $totalAmount,
]);
];
if ($method === 'transfer') {
$purchaseUpdate['payer_dni'] = preg_replace('/\D+/', '', (string) $request->validated('payer_dni'));
}
$compra->update($purchaseUpdate);
if ($method === 'transfer') {
$telepagosService = new TelepagosIntegrationService;

View File

@@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
'payment_method',
'total',
'dni',
'payer_dni',
'telefono',
'nombre_apellido',
'email',

View File

@@ -19,6 +19,11 @@ class PaymentIntentRequest extends FormRequest
{
return [
'method' => ['required', 'string', Rule::in(['qr', 'transfer'])],
'payer_dni' => [
Rule::requiredIf(fn (): bool => $this->input('method') === 'transfer'),
'string',
'regex:/^\d{7,8}$/',
],
];
}
}

View File

@@ -44,6 +44,7 @@ class PurchaseResource extends JsonResource
'status' => $this->status,
'payment_method' => $this->payment_method,
'dni' => $this->dni,
'payer_dni' => $this->payer_dni,
'telefono' => $this->telefono,
'nombre_apellido' => $this->nombre_apellido,
'email' => $this->email,