Skip to content

Commit ba6cf96

Browse files
Merge pull request #71 from pagarme/bugfix/PAOPN-273/error_when_editing_customer_in_adm_portal
Bug fix editing customer through admin
2 parents 93e81a2 + 9eece5f commit ba6cf96

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Payment/Aggregates/Customer.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getCode()
4747
*/
4848
public function setCode($code)
4949
{
50-
$this->code = substr($code, 0, 52);
50+
$this->code = substr($code ?? "", 0, 52);
5151
}
5252

5353
/**
@@ -64,7 +64,7 @@ public function getName()
6464
*/
6565
public function setName($name)
6666
{
67-
$this->name = substr($name, 0, 64);
67+
$this->name = substr($name ?? "", 0, 64);
6868
}
6969

7070
/**
@@ -83,7 +83,7 @@ public function getEmail()
8383
public function setEmail($email)
8484
{
8585
$email = trim($email);
86-
$email = substr($email, 0, 64);
86+
$email = substr($email ?? "", 0, 64);
8787

8888
$this->validateEmail($email);
8989
$this->email = $email;
@@ -124,7 +124,7 @@ public function setDocument($document)
124124
{
125125
$this->document = $this->formatDocument($document);
126126

127-
if (empty($this->document)) {
127+
if (empty($this->document) && empty($this->getPagarmeId())) {
128128

129129
$inputName = $this->i18n->getDashboard('document');
130130
$message = $this->i18n->getDashboard(
@@ -228,8 +228,10 @@ public function convertToSDKRequest()
228228
$customerRequest->code = $this->getCode();
229229
$customerRequest->name = $this->getName();
230230
$customerRequest->email = $this->getEmail();
231-
$customerRequest->document = $this->getDocument();
232-
$customerRequest->type = $this->getTypeValue();
231+
if ($this->getDocument()) {
232+
$customerRequest->document = $this->getDocument();
233+
$customerRequest->type = $this->getTypeValue();
234+
}
233235
$customerRequest->address = $this->getAddressToSDK();
234236
$customerRequest->phones = $this->getPhonesToSDK();
235237

@@ -261,7 +263,7 @@ private function formatDocument($document)
261263
{
262264
$document = preg_replace(
263265
'/[^0-9]/is', '',
264-
substr($document, 0, 16)
266+
substr($document ?? "", 0, 16)
265267
);
266268

267269
return $document;

0 commit comments

Comments
 (0)