diff --git a/CHANGELOG.md b/CHANGELOG.md index 18af8a5..1e01ed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.X.X (2016-XX-XX) * Added support for general account identifiers. + * Added support for intermediary transaction agents. ## 0.3.0 (2016-01-01) diff --git a/src/Z38/SwissPayment/TransactionInformation/ForeignCreditTransfer.php b/src/Z38/SwissPayment/TransactionInformation/ForeignCreditTransfer.php index a22d944..9ef79f1 100644 --- a/src/Z38/SwissPayment/TransactionInformation/ForeignCreditTransfer.php +++ b/src/Z38/SwissPayment/TransactionInformation/ForeignCreditTransfer.php @@ -26,6 +26,11 @@ class ForeignCreditTransfer extends CreditTransfer */ protected $creditorAgent; + /** + * @var BIC + */ + protected $intermediaryAgent; + /** * {@inheritdoc} * @@ -44,6 +49,16 @@ public function __construct($instructionId, $endToEndId, Money $amount, $credito $this->creditorAgent = $creditorAgent; } + /** + * Set the intermediary agent of the transaction. + * + * @param BIC $intermediaryAgent BIC of the intmediary agent + */ + public function setIntermediaryAgent(BIC $intermediaryAgent) + { + $this->intermediaryAgent = $intermediaryAgent; + } + /** * {@inheritdoc} */ @@ -51,6 +66,12 @@ public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation) { $root = $this->buildHeader($doc, $paymentInformation); + if ($this->intermediaryAgent !== null) { + $intermediaryAgent = $doc->createElement('IntrmyAgt1'); + $intermediaryAgent->appendChild($this->intermediaryAgent->asDom($doc)); + $root->appendChild($intermediaryAgent); + } + $creditorAgent = $doc->createElement('CdtrAgt'); $creditorAgent->appendChild($this->creditorAgent->asDom($doc)); $root->appendChild($creditorAgent); diff --git a/tests/Z38/SwissPayment/Tests/Message/CustomerCreditTransferTest.php b/tests/Z38/SwissPayment/Tests/Message/CustomerCreditTransferTest.php index d91c874..c91edfc 100644 --- a/tests/Z38/SwissPayment/Tests/Message/CustomerCreditTransferTest.php +++ b/tests/Z38/SwissPayment/Tests/Message/CustomerCreditTransferTest.php @@ -108,6 +108,7 @@ protected function buildMessage() new GeneralAccount('123-4567890-78'), new FinancialInstitutionAddress('Belfius Bank', new UnstructuredPostalAddress('Pachecolaan 44', '1000 Brussel', 'BE')) ); + $transaction8->setIntermediaryAgent(new BIC('SWHQBEBB')); $transaction9 = new SEPACreditTransfer( 'instr-009',