Browse Source

fix: code customer puxando errado na hora de buscar cartao no pagarme

Gustavo Mantovani 1 week ago
parent
commit
24237af16e
2 changed files with 7 additions and 1 deletions
  1. 1 1
      app/Services/Pagarme/PagarmePaymentService.php
  2. 6 0
      app/Services/PaymentService.php

+ 1 - 1
app/Services/Pagarme/PagarmePaymentService.php

@@ -287,7 +287,7 @@ class PagarmePaymentService
             document:     $document,
             type:         strlen($document) === 14 ? 'company' : 'individual',
             documentType: strlen($document) === 14 ? 'CNPJ' : 'CPF',
-            code:         "client-{$client->id}",
+            code:         $client->ensureGatewayCode(),
             address:      $customerAddress,
             phones:       $customerPhones,
         );

+ 6 - 0
app/Services/PaymentService.php

@@ -133,6 +133,7 @@ class PaymentService
         }
 
         $clientPaymentMethod = null;
+
         $cardId = null;
 
         if ($paymentMethod === 'credit_card') {
@@ -160,6 +161,7 @@ class PaymentService
         }
 
         $serviceAmount = (float) $schedule->total_amount;
+
         $platformFee = round($serviceAmount * 0.11, 2);
         $grossAmount = round($serviceAmount + $platformFee, 2);
 
@@ -299,6 +301,10 @@ class PaymentService
             return false;
         }
 
+        if ($payment->status === PaymentStatusEnum::PAID) {
+            return false;
+        }
+
         return $payment->expires_at !== null
             && $payment->expires_at->isPast();
     }