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