Просмотр исходного кода

fix: permite passport no payload de pedido

Gustavo Mantovani 3 дней назад
Родитель
Сommit
5a7956ad4a

+ 8 - 0
app/Data/Pagarme/Customer/CustomerRequestData.php

@@ -35,6 +35,14 @@ final readonly class CustomerRequestData extends PagarmeData
             'document'      => $this->document,
             'type'          => $this->type,
             'document_type' => $this->documentType,
+            'documents'     => [
+                [
+                    'type'   => $this->documentType,
+                    'number' => $this->documentType === 'PASSPORT'
+                        ? $this->document
+                        : self::digits($this->document),
+                ],
+            ],
             'code'          => $this->code,
             'address'       => $this->address,
             'phones'        => $this->phones,

+ 7 - 1
app/Services/Pagarme/Concerns/FormatsPagarmeData.php

@@ -14,7 +14,13 @@ trait FormatsPagarmeData
 
     protected function customerDocument(?string $value): string
     {
-        return trim((string) $value);
+        $document = trim((string) $value);
+
+        if (preg_match('/[A-Za-z]/', $document) === 1) {
+            return $document;
+        }
+
+        return $this->digits($document);
     }
 
     protected function customerDocumentType(string $document): string