Skip to content

Commit

Permalink
Merge pull request z38#28 from celinederoland/dev/bank-credit-transfe…
Browse files Browse the repository at this point in the history
…r-without-postal-address

Allow omission of the creditor address
  • Loading branch information
z38 authored Jul 16, 2018
2 parents 47e0e2d + 87ed4f6 commit b968153
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Z38\SwissPayment\IID;
use Z38\SwissPayment\Money;
use Z38\SwissPayment\PaymentInformation\PaymentInformation;
use Z38\SwissPayment\PostalAddressInterface;

/**
* BankCreditTransfer contains all the information about a type 3 transaction.
Expand All @@ -35,7 +34,7 @@ class BankCreditTransfer extends CreditTransfer
*
* @throws \InvalidArgumentException When the amount is not in EUR or CHF or when the creditor agent is not BIC or IID.
*/
public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, PostalAddressInterface $creditorAddress, IBAN $creditorIBAN, FinancialInstitutionInterface $creditorAgent)
public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, $creditorAddress, IBAN $creditorIBAN, FinancialInstitutionInterface $creditorAgent)
{
if (!$amount instanceof Money\EUR && !$amount instanceof Money\CHF) {
throw new InvalidArgumentException(sprintf(
Expand Down
18 changes: 10 additions & 8 deletions src/Z38/SwissPayment/TransactionInformation/CreditTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class CreditTransfer
protected $creditorName;

/**
* @var PostalAddressInterface
* @var PostalAddressInterface|null
*/
protected $creditorAddress;

Expand Down Expand Up @@ -60,15 +60,15 @@ abstract class CreditTransfer
/**
* Constructor
*
* @param string $instructionId Identifier of the instruction (should be unique within the message)
* @param string $endToEndId End-To-End Identifier of the instruction (passed unchanged along the complete processing chain)
* @param Money $amount Amount of money to be transferred
* @param string $creditorName Name of the creditor
* @param PostalAddressInterface $creditorAddress Address of the creditor
* @param string $instructionId Identifier of the instruction (should be unique within the message)
* @param string $endToEndId End-To-End Identifier of the instruction (passed unchanged along the complete processing chain)
* @param Money $amount Amount of money to be transferred
* @param string $creditorName Name of the creditor
* @param PostalAddressInterface|null $creditorAddress Address of the creditor
*
* @throws \InvalidArgumentException When any of the inputs contain invalid characters or are too long.
*/
public function __construct($instructionId, $endToEndId, Money $amount, $creditorName, PostalAddressInterface $creditorAddress)
public function __construct($instructionId, $endToEndId, Money $amount, $creditorName, PostalAddressInterface $creditorAddress = null)
{
$this->instructionId = Text::assertIdentifier($instructionId);
$this->endToEndId = Text::assertIdentifier($endToEndId);
Expand Down Expand Up @@ -199,7 +199,9 @@ protected function buildCreditor(\DOMDocument $doc)
{
$creditor = $doc->createElement('Cdtr');
$creditor->appendChild(Text::xml($doc, 'Nm', $this->creditorName));
$creditor->appendChild($this->creditorAddress->asDom($doc));
if ($this->creditorAddress !== null) {
$creditor->appendChild($this->creditorAddress->asDom($doc));
}

return $creditor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Z38\SwissPayment\FinancialInstitutionInterface;
use Z38\SwissPayment\Money\Money;
use Z38\SwissPayment\PaymentInformation\PaymentInformation;
use Z38\SwissPayment\PostalAddressInterface;

/**
* ForeignCreditTransfer contains all the information about a foreign (type 6) transaction.
Expand Down Expand Up @@ -37,7 +36,7 @@ class ForeignCreditTransfer extends CreditTransfer
* @param AccountInterface $creditorAccount Account of the creditor
* @param BIC|FinancialInstitutionAddress $creditorAgent BIC or address of the creditor's financial institution
*/
public function __construct($instructionId, $endToEndId, Money $amount, $creditorName, PostalAddressInterface $creditorAddress, AccountInterface $creditorAccount, FinancialInstitutionInterface $creditorAgent)
public function __construct($instructionId, $endToEndId, Money $amount, $creditorName, $creditorAddress, AccountInterface $creditorAccount, FinancialInstitutionInterface $creditorAgent)
{
parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Z38\SwissPayment\Money;
use Z38\SwissPayment\PaymentInformation\PaymentInformation;
use Z38\SwissPayment\PostalAccount;
use Z38\SwissPayment\PostalAddressInterface;

/**
* IS1CreditTransfer contains all the information about a IS 1-stage (type 2.1) transaction.
Expand All @@ -26,7 +25,7 @@ class IS1CreditTransfer extends CreditTransfer
*
* @throws \InvalidArgumentException When the amount is not in EUR or CHF.
*/
public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, PostalAddressInterface $creditorAddress, PostalAccount $creditorAccount)
public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, $creditorAddress, PostalAccount $creditorAccount)
{
if (!$amount instanceof Money\EUR && !$amount instanceof Money\CHF) {
throw new InvalidArgumentException(sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Z38\SwissPayment\Money;
use Z38\SwissPayment\PaymentInformation\PaymentInformation;
use Z38\SwissPayment\PostalAccount;
use Z38\SwissPayment\PostalAddressInterface;
use Z38\SwissPayment\Text;

/**
Expand Down Expand Up @@ -40,7 +39,7 @@ class IS2CreditTransfer extends CreditTransfer
*
* @throws \InvalidArgumentException When the amount is not in EUR or CHF.
*/
public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, PostalAddressInterface $creditorAddress, IBAN $creditorIBAN, $creditorAgentName, PostalAccount $creditorAgentPostal)
public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, $creditorAddress, IBAN $creditorIBAN, $creditorAgentName, PostalAccount $creditorAgentPostal)
{
if (!$amount instanceof Money\EUR && !$amount instanceof Money\CHF) {
throw new InvalidArgumentException(sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Z38\SwissPayment\IBAN;
use Z38\SwissPayment\Money;
use Z38\SwissPayment\PaymentInformation\PaymentInformation;
use Z38\SwissPayment\PostalAddressInterface;

/**
* SEPACreditTransfer contains all the information about a foreign SEPA (type 5) transaction.
Expand All @@ -30,7 +29,7 @@ class SEPACreditTransfer extends CreditTransfer
* @param IBAN $creditorIBAN IBAN of the creditor
* @param BIC|null $creditorAgentBIC BIC of the creditor's financial institution
*/
public function __construct($instructionId, $endToEndId, Money\EUR $amount, $creditorName, PostalAddressInterface $creditorAddress, IBAN $creditorIBAN, BIC $creditorAgentBIC = null)
public function __construct($instructionId, $endToEndId, Money\EUR $amount, $creditorName, $creditorAddress, IBAN $creditorIBAN, BIC $creditorAgentBIC = null)
{
parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function buildMessage()
'e2e-004',
new Money\CHF(30000), // CHF 300.00
'Muster Transport AG',
new StructuredPostalAddress('Wiesenweg', '14b', '8058', 'Zürich-Flughafen'),
null,
$iban4,
IID::fromIBAN($iban4)
);
Expand Down

0 comments on commit b968153

Please sign in to comment.