Skip to content

Commit

Permalink
Merge pull request #187 from linushstge/feature/sepa-purpose-codes
Browse files Browse the repository at this point in the history
Implementation for optional SEPA credit transfer purpose codes
  • Loading branch information
andrew-svirin authored Jan 25, 2024
2 parents 46f62b6 + 2afd831 commit 8caca27
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<img src="https://www.ebics.org/typo3conf/ext/siz_ebicsorg_base/Resources/Public/Images/ebics-logo.png" width="300">

PHP library to communicate with a bank through EBICS protocol.
Supported PHP versions - PHP 7.2 - PHP 8.1
Supported PHP versions - PHP 7.2 - PHP 8.3
Support Ebics server versions: 2.4 (partially), 2.5 (default), 3.0

## License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,26 @@ public function createInstance(
return $this;
}

/**
* @param string $creditorFinInstBIC
* @param string $creditorIBAN
* @param string $creditorName
* @param float $amount
* @param string $currency
* @param string $purpose
* @param string|null $endToEndId
* @param string|null $purposeCode Optional Purpose Code - e.G. BENE BONU CBFF CHAR GOVT PENS SALA SSBE
* @return CustomerCreditTransferBuilder
*/
public function addTransaction(
string $creditorFinInstBIC,
string $creditorIBAN,
string $creditorName,
float $amount,
string $currency,
string $purpose,
string $endToEndId = null
string $endToEndId = null,
string $purposeCode = null
): CustomerCreditTransferBuilder {
$xpath = $this->prepareXPath($this->instance);
$nbOfTxsList = $xpath->query('//CstmrCdtTrfInitn/PmtInf/NbOfTxs');
Expand Down Expand Up @@ -247,6 +259,15 @@ public function addTransaction(
$xmlIBAN->nodeValue = $creditorIBAN;
$xmlId->appendChild($xmlIBAN);

if ($purposeCode) {
$xmlPurp = $this->instance->createElement('Purp');
$xmlCdtTrfTxInf->appendChild($xmlPurp);

$xmlCd = $this->instance->createElement('Cd');
$xmlCd->nodeValue = $purposeCode;
$xmlPurp->appendChild($xmlCd);
}

$xmlRmtInf = $this->instance->createElement('RmtInf');
$xmlCdtTrfTxInf->appendChild($xmlRmtInf);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ public function createInstance(
* @param float $amount
* @param string $currency
* @param string $purpose
* @param string $endToEndId
* @param string|null $endToEndId
* @param string|null $purposeCode Optional Purpose Code - e.G. BENE BONU CBFF CHAR GOVT PENS SALA SSBE
* @return CustomerInstantCreditTransferBuilder
*/
public function addTransaction(
Expand All @@ -194,7 +195,8 @@ public function addTransaction(
float $amount,
string $currency,
string $purpose,
string $endToEndId
string $endToEndId = null,
string $purposeCode = null
): CustomerInstantCreditTransferBuilder {
$xpath = $this->prepareXPath($this->instance);
$nbOfTxsList = $xpath->query('//CstmrCdtTrfInitn/PmtInf/NbOfTxs');
Expand Down Expand Up @@ -255,6 +257,15 @@ public function addTransaction(
$xmlIBAN->nodeValue = $creditorIBAN;
$xmlId->appendChild($xmlIBAN);

if ($purposeCode) {
$xmlPurp = $this->instance->createElement('Purp');
$xmlCdtTrfTxInf->appendChild($xmlPurp);

$xmlCd = $this->instance->createElement('Cd');
$xmlCd->nodeValue = $purposeCode;
$xmlPurp->appendChild($xmlCd);
}

$xmlRmtInf = $this->instance->createElement('RmtInf');
$xmlCdtTrfTxInf->appendChild($xmlRmtInf);

Expand Down

0 comments on commit 8caca27

Please sign in to comment.