Bläddra i källkod

refactor: ajuste para nao utilizar antecipacao manual e sim automatica do sistema configurada via recebedor

Gustavo Mantovani 5 timmar sedan
förälder
incheckning
804ef13667
2 ändrade filer med 10 tillägg och 28 borttagningar
  1. 6 8
      app/Services/Pagarme/PagarmeRecipientService.php
  2. 4 20
      app/Services/WebhookService.php

+ 6 - 8
app/Services/Pagarme/PagarmeRecipientService.php

@@ -75,10 +75,9 @@ class PagarmeRecipientService
             ),
 
             automaticAnticipationSettings: new AutomaticAnticipationSettingsData(
-                enabled:          true,
-                type:             'full',
-                volumePercentage: 100,
-                delay:            1,
+                enabled: true,
+                type:    'full',
+                delay:   1,
             ),
         );
 
@@ -114,10 +113,9 @@ class PagarmeRecipientService
             ],
 
             'recipient_automatic_anticipation_settings' => [
-                'enabled'           => true,
-                'type'              => 'full',
-                'volume_percentage' => 100,
-                'delay'             => 1,
+                'enabled' => true,
+                'type'    => 'full',
+                'delay'   => 1,
             ],
 
             'recipient_metadata' => $metadata,

+ 4 - 20
app/Services/WebhookService.php

@@ -2,10 +2,8 @@
 
 namespace App\Services;
 
-use App\Enums\PaymentStatusEnum;
 use App\Models\Payment;
 use App\Models\Webhook;
-use App\Services\Pagarme\PagarmeAnticipationService;
 use App\Services\Pagarme\PagarmePaymentService;
 use Illuminate\Support\Facades\Log;
 
@@ -32,10 +30,9 @@ class WebhookService
     ];
 
     public function __construct(
-        private readonly PagarmePaymentService      $pagarmePaymentService,
-        private readonly PagarmeAnticipationService $pagarmeAnticipationService,
-        private readonly PaymentService             $paymentService,
-        private readonly ProviderWithdrawalService  $providerWithdrawalService,
+        private readonly PagarmePaymentService     $pagarmePaymentService,
+        private readonly PaymentService            $paymentService,
+        private readonly ProviderWithdrawalService $providerWithdrawalService,
     ) {
     }
 
@@ -99,12 +96,6 @@ class WebhookService
 
             $this->paymentService->syncScheduleStatusAfterPayment($payment->schedule, $payment);
 
-            if ($this->shouldCreateCreditCardAnticipation($event, $payment)) {
-                $anticipationLimits = $this->pagarmeAnticipationService->fetchAnticipationLimitsForPayment($payment);
-
-                $this->pagarmeAnticipationService->createBulkAnticipation($payment, $anticipationLimits);
-            }
-
             $webhook->update([
                 'payment_id'   => $payment->id,
                 'status'       => 'processed',
@@ -234,11 +225,4 @@ class WebhookService
             ->latest('id')
             ->first();
     }
-
-    private function shouldCreateCreditCardAnticipation(?string $event, Payment $payment): bool
-    {
-        return $event === 'charge.paid'
-            && $payment->payment_method === 'credit_card'
-            && $payment->status === PaymentStatusEnum::PAID;
-    }
-}
+}