Skip to content

Commit

Permalink
merged some changes
Browse files Browse the repository at this point in the history
notably the "pain"-type can now be changed
  • Loading branch information
nemiah committed Mar 6, 2023
1 parent f6ce4d2 commit a66b8ee
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/nemiah/phpSepaXml/SEPACreditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SEPACreditor extends SEPAParty {

function __construct($data = null) {
$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", "e"), $data["name"]);
$data["name"] = str_replace(array("Ö", "Ä", "Ü"), array("Oe", "Ae", "Ue"), $data["name"]);
$data["name"] = str_replace(array("ß"), array("ss"), $data["name"]);

Expand Down
43 changes: 40 additions & 3 deletions src/nemiah/phpSepaXml/SEPADebitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class SEPADebitor extends SEPAParty {
public $mandateID = "";
public $mandateDateOfSignature = "";
public $name = "";

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

public $iban = "";
public $bic = "";
public $amount = 0;
Expand All @@ -26,10 +36,9 @@ class SEPADebitor extends SEPAParty {
public $sequenceType = "OOFF";
public $type = "COR1";
public $endToEndId = "NOTPROVIDED";
public $group = "";

public function XMLTransfer(\SimpleXMLElement $xml) {
$xml->addChild('Dbtr')->addChild('Nm', htmlentities($this->name));
$xml->addChild('Dbtr')->addChild('Nm', $this->fixNm($this->name));
$xml->addChild('DbtrAcct')->addChild('Id')->addChild('IBAN', str_replace(" ", "", $this->iban));
$xml->addChild('DbtrAgt')->addChild('FinInstnId')->addChild('BIC', $this->bic);
$xml->addChild('ChrgBr', 'SLEV');
Expand Down Expand Up @@ -57,7 +66,35 @@ public function XMLDirectDebit(\SimpleXMLElement $xml) {
$MndtRltdInf->addChild('AmdmntInd', 'false');

$DrctDbtTxInf->addChild('DbtrAgt')->addChild('FinInstnId')->addChild('BIC', $this->bic);
$DrctDbtTxInf->addChild('Dbtr')->addChild('Nm', $this->fixNm($this->name));

$Dbtr = $DrctDbtTxInf->addChild('Dbtr');
$Dbtr->addChild('Nm', $this->fixNm($this->name));

if(trim($this->addressLine1.$this->postalCode.$this->city.$this->country.$this->street) != ""){
$PstlAdr = $Dbtr->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);
}

$DrctDbtTxInf->addChild('DbtrAcct')->addChild('Id')->addChild('IBAN', str_replace(" ", "", $this->iban));

if ($this->ultimateDebitor != '')
Expand Down
8 changes: 4 additions & 4 deletions src/nemiah/phpSepaXml/SEPAFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class SEPAFile {

protected function start($type) {
libxml_use_internal_errors(true);
if ($type == "pain.008.003.02")
return new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.003.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.008.003.02 pain.008.003.02.xsd" />');

#if ($type == "pain.008.003.02")
return new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:'.$type.'" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:'.$type.' '.$type.'.xsd" />');
/*
if($type == "pain.001.003.03")
return new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.003.03 pain.001.003.03.xsd" />');
return null;
return null;*/
}

public function errors() {
Expand Down
7 changes: 6 additions & 1 deletion src/nemiah/phpSepaXml/SEPAParty.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ 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", " ", "", "e"), $name), 0, 70);
}

public static function fixNmS($name){
$P = new SEPAParty();
return $P->fixNm($name);
}
}

0 comments on commit a66b8ee

Please sign in to comment.