|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Z38\SwissPayment\TransactionInformation; |
|
4
|
|
|
|
|
5
|
|
|
use DOMDocument; |
|
6
|
|
|
use Z38\SwissPayment\Money; |
|
7
|
|
|
use Z38\SwissPayment\PaymentInformation\PaymentInformation; |
|
8
|
|
|
use Z38\SwissPayment\PostalAccount; |
|
9
|
|
|
use Z38\SwissPayment\PostalAddressInterface; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* IS1CreditTransfer contains all the information about a IS 1-stage (type 2.1) transaction. |
|
13
|
|
|
*/ |
|
14
|
|
|
class IS1CreditTransfer extends CreditTransfer |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var PostalAccount |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $creditorAccount; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* {@inheritdoc} |
|
23
|
|
|
* |
|
24
|
|
|
* @param PostalAccount $creditorAccount Postal account of the creditor |
|
25
|
|
|
* |
|
26
|
|
|
* @throws \InvalidArgumentException. An InvalidArgumentException is thrown if amount is not EUR or CHF |
|
27
|
|
|
*/ |
|
28
|
3 |
|
public function __construct($instructionId, $endToEndId, Money\Money $amount, $creditorName, PostalAddressInterface $creditorAddress, PostalAccount $creditorAccount) |
|
29
|
|
|
{ |
|
30
|
3 |
|
if (false === $amount instanceof Money\EUR && false === $amount instanceof Money\CHF) { |
|
31
|
1 |
|
throw new \InvalidArgumentException(sprintf( |
|
32
|
1 |
|
'Amount must be an instance of Z38\SwissPayment\Money\EUR or Z38\SwissPayment\Money\CHF. Instance of %s given.', |
|
33
|
1 |
|
get_class($amount) |
|
34
|
1 |
|
)); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
2 |
|
parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress); |
|
38
|
|
|
|
|
39
|
2 |
|
$this->creditorAccount = $creditorAccount; |
|
40
|
2 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritdoc} |
|
44
|
|
|
*/ |
|
45
|
2 |
|
public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation) |
|
46
|
|
|
{ |
|
47
|
2 |
|
$root = $this->buildHeader($doc, $paymentInformation, 'CH02'); |
|
48
|
|
|
|
|
49
|
2 |
|
$root->appendChild($this->buildCreditor($doc)); |
|
50
|
|
|
|
|
51
|
2 |
|
$creditorAccount = $doc->createElement('CdtrAcct'); |
|
52
|
2 |
|
$creditorAccount->appendChild($this->creditorAccount->asDom($doc)); |
|
53
|
2 |
|
$root->appendChild($creditorAccount); |
|
54
|
|
|
|
|
55
|
2 |
|
if ($this->hasRemittanceInformation()) { |
|
56
|
|
|
$root->appendChild($this->buildRemittanceInformation($doc)); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
2 |
|
return $root; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|