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