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
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* SEPACreditTransfer contains all the information about a foreign SEPA (type 5) transaction. |
13
|
|
|
*/ |
14
|
|
|
class SEPACreditTransfer extends CreditTransfer |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var IBAN |
18
|
|
|
*/ |
19
|
|
|
protected $creditorIBAN; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var BIC|null |
23
|
|
|
*/ |
24
|
|
|
protected $creditorAgentBIC; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
* |
29
|
|
|
* @param IBAN $creditorIBAN IBAN of the creditor |
30
|
|
|
* @param BIC|null $creditorAgentBIC BIC of the creditor's financial institution |
31
|
|
|
*/ |
32
|
3 |
|
public function __construct($instructionId, $endToEndId, Money\EUR $amount, $creditorName, $creditorAddress, IBAN $creditorIBAN, BIC $creditorAgentBIC = null) |
33
|
|
|
{ |
34
|
3 |
|
parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress); |
35
|
|
|
|
36
|
3 |
|
$this->creditorIBAN = $creditorIBAN; |
37
|
3 |
|
$this->serviceLevel = 'SEPA'; |
38
|
|
|
|
39
|
3 |
|
if ($creditorAgentBIC !== null) { |
40
|
3 |
|
@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
|
3 |
|
$this->creditorAgentBIC = $creditorAgentBIC; |
42
|
3 |
|
} |
43
|
3 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
2 |
|
public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation) |
49
|
|
|
{ |
50
|
2 |
|
$root = $this->buildHeader($doc, $paymentInformation); |
51
|
|
|
|
52
|
2 |
|
$root->appendChild($doc->createElement('ChrgBr', 'SLEV')); |
53
|
|
|
|
54
|
2 |
|
if ($this->creditorAgentBIC !== null) { |
55
|
2 |
|
$creditorAgent = $doc->createElement('CdtrAgt'); |
56
|
2 |
|
$creditorAgent->appendChild($this->creditorAgentBIC->asDom($doc)); |
57
|
2 |
|
$root->appendChild($creditorAgent); |
58
|
2 |
|
} |
59
|
|
|
|
60
|
2 |
|
$root->appendChild($this->buildCreditor($doc)); |
61
|
|
|
|
62
|
2 |
|
$creditorAccount = $doc->createElement('CdtrAcct'); |
63
|
2 |
|
$creditorAccount->appendChild($this->creditorIBAN->asDom($doc)); |
64
|
2 |
|
$root->appendChild($creditorAccount); |
65
|
|
|
|
66
|
2 |
|
$this->appendPurpose($doc, $root); |
67
|
|
|
|
68
|
2 |
|
$this->appendRemittanceInformation($doc, $root); |
69
|
|
|
|
70
|
2 |
|
return $root; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: