1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Z38\SwissPayment\TransactionInformation; |
4
|
|
|
|
5
|
|
|
use DOMDocument; |
6
|
|
|
use Z38\SwissPayment\BIC; |
7
|
|
|
use Z38\SwissPayment\IBAN; |
8
|
|
|
use Z38\SwissPayment\Money; |
9
|
|
|
use Z38\SwissPayment\PaymentInformation\PaymentInformation; |
10
|
|
|
use Z38\SwissPayment\PostalAddressInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* SEPACreditTransfer contains all the information about a foreign SEPA (type 5) transaction. |
14
|
|
|
*/ |
15
|
|
|
class SEPACreditTransfer extends CreditTransfer |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var IBAN |
19
|
|
|
*/ |
20
|
|
|
protected $creditorIBAN; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var BIC|null |
24
|
|
|
*/ |
25
|
|
|
protected $creditorAgentBIC; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
* |
30
|
|
|
* @param IBAN $creditorIBAN IBAN of the creditor |
31
|
|
|
* @param BIC|null $creditorAgentBIC BIC of the creditor's financial institution |
32
|
|
|
*/ |
33
|
2 |
|
public function __construct($instructionId, $endToEndId, Money\EUR $amount, $creditorName, PostalAddressInterface $creditorAddress, IBAN $creditorIBAN, BIC $creditorAgentBIC = null) |
34
|
|
|
{ |
35
|
2 |
|
parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress); |
36
|
|
|
|
37
|
2 |
|
$this->creditorIBAN = $creditorIBAN; |
38
|
|
|
|
39
|
2 |
|
if ($creditorAgentBIC !== null) { |
40
|
2 |
|
@trigger_error('Setting the creditor agent BIC of SEPA payments is deprecated. The execution of the payment will be based on the IBAN.', E_USER_DEPRECATED); |
|
|
|
|
41
|
2 |
|
$this->creditorAgentBIC = $creditorAgentBIC; |
42
|
2 |
|
} |
43
|
2 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
2 |
|
public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation) |
49
|
|
|
{ |
50
|
2 |
|
$root = $this->buildHeader($doc, $paymentInformation, null, 'SEPA'); |
51
|
|
|
|
52
|
2 |
|
if ($this->creditorAgentBIC !== null) { |
53
|
2 |
|
$creditorAgent = $doc->createElement('CdtrAgt'); |
54
|
2 |
|
$creditorAgent->appendChild($this->creditorAgentBIC->asDom($doc)); |
55
|
2 |
|
$root->appendChild($creditorAgent); |
56
|
2 |
|
} |
57
|
|
|
|
58
|
2 |
|
$root->appendChild($this->buildCreditor($doc)); |
59
|
|
|
|
60
|
2 |
|
$creditorAccount = $doc->createElement('CdtrAcct'); |
61
|
2 |
|
$creditorAccount->appendChild($this->creditorIBAN->asDom($doc)); |
62
|
2 |
|
$root->appendChild($creditorAccount); |
63
|
|
|
|
64
|
2 |
|
if ($this->hasRemittanceInformation()) { |
65
|
|
|
$root->appendChild($this->buildRemittanceInformation($doc)); |
66
|
|
|
} |
67
|
|
|
|
68
|
2 |
|
return $root; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: