|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Z38\SwissPayment\TransactionInformation; |
|
4
|
|
|
|
|
5
|
|
|
use Z38\SwissPayment\Money; |
|
6
|
|
|
use Z38\SwissPayment\PostalAccount; |
|
7
|
|
|
use Z38\SwissPayment\PostalAddressInterface; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* IS1CreditTransfer contains all the information about a IS 1-stage (type 2.1) transaction. |
|
11
|
|
|
*/ |
|
12
|
|
|
class IS1CreditTransfer extends CreditTransfer |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var PostalAccount |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $creditorAccount; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* {@inheritdoc} |
|
21
|
|
|
* |
|
22
|
|
|
* @param PostalAccount $creditorAccount Postal account of the creditor |
|
23
|
|
|
*/ |
|
24
|
2 |
|
public function __construct($instructionId, $endToEndId, Money\CHF $amount, $creditorName, PostalAddressInterface $creditorAddress, PostalAccount $creditorAccount) |
|
25
|
|
|
{ |
|
26
|
2 |
|
parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress); |
|
27
|
|
|
|
|
28
|
2 |
|
$this->creditorAccount = $creditorAccount; |
|
29
|
2 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
2 |
|
public function asDom(\DOMDocument $doc) |
|
35
|
|
|
{ |
|
36
|
2 |
|
$root = $this->buildHeader($doc, 'CH02'); |
|
37
|
|
|
|
|
38
|
2 |
|
$root->appendChild($this->buildCreditor($doc)); |
|
39
|
|
|
|
|
40
|
2 |
|
$creditorAccount = $doc->createElement('CdtrAcct'); |
|
41
|
2 |
|
$creditorAccountId = $doc->createElement('Id'); |
|
42
|
2 |
|
$creditorAccountIdOther = $doc->createElement('Othr'); |
|
43
|
2 |
|
$creditorAccountIdOther->appendChild($doc->createElement('Id', $this->creditorAccount->format())); |
|
44
|
2 |
|
$creditorAccountId->appendChild($creditorAccountIdOther); |
|
45
|
2 |
|
$creditorAccount->appendChild($creditorAccountId); |
|
46
|
2 |
|
$root->appendChild($creditorAccount); |
|
47
|
|
|
|
|
48
|
2 |
|
if ($this->hasRemittanceInformation()) { |
|
49
|
|
|
$root->appendChild($this->buildRemittanceInformation($doc)); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
2 |
|
return $root; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|