Skip to content

Commit

Permalink
replace |
Browse files Browse the repository at this point in the history
  • Loading branch information
nemiah committed Jan 4, 2022
1 parent 1f85c8a commit f6ce4d2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
41 changes: 39 additions & 2 deletions src/nemiah/phpSepaXml/SEPACreditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ class SEPACreditor extends SEPAParty {
public $paymentID = "NOTPROVIDED";
public $endToEndId = "NOTPROVIDED";

public $addressLine1 = "";
public $addressLine2 = "";
public $street = "";
public $buildingNumber = "";
public $postalCode = "";
public $city = "";
public $country = "";

function __construct($data = null) {
$data["name"] = str_replace(array("&", "³"), array("und", "3"), $data["name"]);
$data["name"] = str_replace(array("&", "³", "|"), array("und", "3", ""), $data["name"]);
$data["name"] = str_replace(array("ö", "ä", "ü"), array("oe", "ae", "ue"), $data["name"]);
$data["name"] = str_replace(array("Ö", "Ä", "Ü"), array("Oe", "Ae", "Ue"), $data["name"]);
$data["name"] = str_replace(array("ß"), array("ss"), $data["name"]);
Expand All @@ -35,7 +43,36 @@ function __construct($data = null) {
}

public function XMLDirectDebit(\SimpleXMLElement $xml) {
$xml->addChild('Cdtr')->addChild('Nm', htmlentities($this->name));
#$xml->addChild('Cdtr')->addChild('Nm', htmlentities($this->name));

$Cdtr = $xml->addChild('Cdtr');
$Cdtr->addChild('Nm', $this->fixNm($this->name));

if(trim($this->addressLine1.$this->postalCode.$this->city.$this->country.$this->street) != ""){
$PstlAdr = $Cdtr->addChild("PstlAdr");

if($this->addressLine1 != "")
$PstlAdr->addChild ("AdrLine", $this->fixNm($this->addressLine1));

if($this->addressLine2 != "")
$PstlAdr->addChild ("AdrLine", $this->fixNm($this->addressLine2));

if($this->postalCode != "")
$PstlAdr->addChild("PstCd", $this->postalCode);

if($this->city != "")
$PstlAdr->addChild("TwnNm", $this->city);

if($this->country != "")
$PstlAdr->addChild("Ctry", $this->country);

if($this->street != "")
$PstlAdr->addChild("StrtNm", $this->fixNm($this->street));

if($this->buildingNumber != "")
$PstlAdr->addChild("BldgNb", $this->buildingNumber);
}

$xml->addChild('CdtrAcct')->addChild('Id')->addChild('IBAN', str_replace(" ", "", $this->iban));
$xml->addChild('CdtrAgt')->addChild('FinInstnId')->addChild('BIC', $this->bic);
$xml->addChild('ChrgBr', 'SLEV');
Expand Down
4 changes: 2 additions & 2 deletions src/nemiah/phpSepaXml/SEPAParty.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ function __construct($data = null) {
}

function fixNm($name){
return mb_substr(str_replace(array("ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "&", "³"), array("ae", "oe", "ue", "Ae", "Oe", "Ue", "ss", "und", "3"), $name), 0, 70);
return mb_substr(str_replace(array("ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "&", "³", "-", "|"), array("ae", "oe", "ue", "Ae", "Oe", "Ue", "ss", "und", "3", " ", ""), $name), 0, 70);
}
}
}

0 comments on commit f6ce4d2

Please sign in to comment.