Skip to content

Commit b0bd22e

Browse files
committed
support for different charge bearers in customer credit transfers
1 parent 270e0db commit b0bd22e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Builders/CustomerCreditTransfer/CustomerCreditTransferBuilder.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct()
4545
* least for 15 days. Used for rejecting duplicated transactions (max length: 35 characters)
4646
* @param string|null $paymentReference Overwrite default payment reference -
4747
* visible on creditors bank statement (max length: 35 characters)
48+
* @param string|null $chargeBearer Overwrite default charge bearer (one of SLEV, CRED, DEBT, SHAR)
4849
*
4950
* @return $this
5051
*/
@@ -56,7 +57,8 @@ public function createInstance(
5657
?DateTime $executionDate = null,
5758
bool $batchBooking = true,
5859
?string $msgId = null,
59-
?string $paymentReference = null
60+
?string $paymentReference = null,
61+
?string $chargeBearer = null
6062
): CustomerCreditTransferBuilder {
6163
$this->instance = new CustomerCreditTransfer();
6264
$now = new DateTime();
@@ -183,7 +185,11 @@ public function createInstance(
183185
$xmlFinInstnId->appendChild($xmlBIC);
184186

185187
$xmlChrgBr = $this->instance->createElement('ChrgBr');
186-
$xmlChrgBr->nodeValue = 'SLEV';
188+
if ($chargeBearer) {
189+
$xmlChrgBr->nodeValue = $chargeBearer;
190+
} else {
191+
$xmlChrgBr->nodeValue = 'SLEV';
192+
}
187193
$xmlPmtInf->appendChild($xmlChrgBr);
188194

189195
return $this;
@@ -334,7 +340,8 @@ public function addSEPATransaction(
334340
?PostalAddressInterface $postalAddress,
335341
float $amount,
336342
string $currency,
337-
?string $purpose = null
343+
?string $purpose = null,
344+
?string $chargeBearer = null
338345
): CustomerCreditTransferBuilder {
339346
if ($currency !== 'EUR') {
340347
throw new InvalidArgumentException('The SEPA transaction is restricted to EUR currency.');
@@ -356,7 +363,11 @@ public function addSEPATransaction(
356363
$this->addAmountElement($xmlCdtTrfTxInf, $amount, $currency);
357364

358365
$xmlChrgBr = $this->instance->createElement('ChrgBr');
359-
$xmlChrgBr->nodeValue = 'SLEV';
366+
if ($chargeBearer) {
367+
$xmlChrgBr->nodeValue = $chargeBearer;
368+
} else {
369+
$xmlChrgBr->nodeValue = 'SLEV';
370+
}
360371
$xmlCdtTrfTxInf->appendChild($xmlChrgBr);
361372

362373
$this->addCreditor(

0 commit comments

Comments
 (0)