Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions modules/registrars/openprovider/OpenProvider/API/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,17 @@ public function getCustomer(string $handle, bool $formattedForWhmcs = true): arr
$customerInfo['Last Name'] = $customerOp['name']['lastName'];
$customerInfo['Company Name'] = $customerOp['companyName'];
$customerInfo['Email Address'] = $customerOp['email'];
$customerInfo['Address'] = $customerOp['address']['street'] . ' ' .
$customerOp['address']['number'] . ' ' .
$customerOp['address']['suffix'];
if ($customerOp['address']['country'] === 'US') {
$customerInfo['Address'] =
$customerOp['address']['number'] . ' ' .
$customerOp['address']['street'] . ' ' .
$customerOp['address']['suffix'];
} else {
$customerInfo['Address'] =
$customerOp['address']['street'] . ' ' .
$customerOp['address']['number'] . ' ' .
$customerOp['address']['suffix'];
}
$customerInfo['City'] = $customerOp['address']['city'];
$customerInfo['State'] = $customerOp['address']['state'];
$customerInfo['Zip Code'] = $customerOp['address']['zipcode'];
Expand Down
32 changes: 23 additions & 9 deletions modules/registrars/openprovider/OpenProvider/API/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public function __construct($params, $prefix = '')
'lastname' => 'last name',
'gender' => 'gender',
'address' => 'address',
'address1' => 'address 1',
'address2' => 'address 2',
'postcode' => 'zip code',
'city' => 'city',
'state' => 'fullstate',
Expand Down Expand Up @@ -165,17 +167,29 @@ public function __construct($params, $prefix = '')
//Customer Address
$fullAddress = '';
if ($getFromContactDetails) {
if (isset($params[$indexes['address']]) && !empty($params[$indexes['address']])) {
$fullAddress = $params[$indexes['address']];
} else if (!empty(trim($params[$indexes['address1']] . ' ' . $params[$indexes['address2']]))) {
$fullAddress = $params[$indexes['address1']] . ' ' . $params[$indexes['address2']];
}
$address1 = $params[$indexes['address1']] ?? '';
$address2 = $params[$indexes['address2']] ?? '';
$address = $params[$indexes['address']] ?? '';

if (!empty(trim($address1 . ' ' . $address2))) {
$fullAddress = trim($address1 . ' ' . $address2);
} elseif (!empty(trim($address))) {
$fullAddress = $address;
}
} else {
if (!empty(trim($params[$indexes['address1']] . ' ' . $params[$indexes['address2']]))) {
$fullAddress = $params[$indexes['address1']] . ' ' . $params[$indexes['address2']];
}
$address1 = $params[$indexes['address1']] ?? '';
$address2 = $params[$indexes['address2']] ?? '';
Comment thread
DaniNC marked this conversation as resolved.
Outdated
$fullAddress = trim($address1 . ' ' . $address2);
}


logModuleCall('openprovider', 'composed_fullAddress', [
'address1' => $address1 ?? '',
'address2' => $address2 ?? '',
'address' => $address ?? '',
'final' => $fullAddress,
], '', '');


$address = new \OpenProvider\API\CustomerAddress(array(
'fulladdress' => $fullAddress ?: null,
'zipcode' => $params[$indexes['postcode']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public function __construct($fields = array())
parent::__construct($fields);

if (isset($fields['fulladdress']) && !is_null($fields['fulladdress'])) {
$this->setAddress($fields['fulladdress']);
$this->setAddress($fields['fulladdress'], $fields['country'] ?? '');
}
}

/**
* Format address
* @param string
*/
protected function setAddress($fullAddress)
protected function setAddress($fullAddress, $country = '')
{
Comment thread
DaniNC marked this conversation as resolved.
try {
$splitAddress = AddressSplitter::splitAddress($fullAddress);
Expand All @@ -40,12 +40,13 @@ protected function setAddress($fullAddress)

$this->street = $convertedAddress;
$this->number = $housenumber;
} catch (\Exception $e)
{
if (strpos($e->getMessage(), ' could not be splitted into street name and house number.') !== false)
$this->suffix = $splitAddress['additionToAddress1'];
} catch (\Exception $e){
if (strpos($e->getMessage(), ' could not be splitted into street name and house number.') !== false) {
$this->street = $fullAddress;
else
} else {
throw $e;
}
}
}
}