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
|
2 |
|
$this->serviceLevel = 'SEPA'; |
39
|
|
|
|
40
|
2 |
|
if ($creditorAgentBIC !== null) { |
41
|
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); |
|
|
|
|
42
|
2 |
|
$this->creditorAgentBIC = $creditorAgentBIC; |
43
|
2 |
|
} |
44
|
2 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
2 |
|
public function getChargeBearer() |
50
|
|
|
{ |
51
|
2 |
|
return 'SLEV'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
2 |
|
public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation) |
58
|
|
|
{ |
59
|
2 |
|
$root = $this->buildHeader($doc, $paymentInformation); |
60
|
|
|
|
61
|
2 |
|
if ($this->creditorAgentBIC !== null) { |
62
|
2 |
|
$creditorAgent = $doc->createElement('CdtrAgt'); |
63
|
2 |
|
$creditorAgent->appendChild($this->creditorAgentBIC->asDom($doc)); |
64
|
2 |
|
$root->appendChild($creditorAgent); |
65
|
2 |
|
} |
66
|
|
|
|
67
|
2 |
|
$root->appendChild($this->buildCreditor($doc)); |
68
|
|
|
|
69
|
2 |
|
$creditorAccount = $doc->createElement('CdtrAcct'); |
70
|
2 |
|
$creditorAccount->appendChild($this->creditorIBAN->asDom($doc)); |
71
|
2 |
|
$root->appendChild($creditorAccount); |
72
|
|
|
|
73
|
2 |
|
$this->appendPurpose($doc, $root); |
74
|
|
|
|
75
|
2 |
|
$this->appendRemittanceInformation($doc, $root); |
76
|
|
|
|
77
|
2 |
|
return $root; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: