PHP code example of bolovsky / sepa-xml

1. Go to this page and download the library: Download bolovsky/sepa-xml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bolovsky / sepa-xml example snippets


//Set the initial information
$directDebit = TransferFileFacadeFactory::createDirectDebit('test123', 'Me');

// create a payment, it's possible to create multiple payments,
// "firstPayment" is the identifier for the transactions
$directDebit->addPaymentInfo('firstPayment', array(
	'id' 					=> 'firstPayment',
	'creditorName' 			=> 'My Company',
	'creditorAccountIBAN'	=> 'FI1350001540000056',
	'creditorAgentBIC' 		=> 'PSSTFRPPMON',
	'seqType'				=> PaymentInformation::S_ONEOFF,
	'creditorId'			=> 'DE21WVM1234567890'
));
// Add a Single Transaction to the named payment
$directDebit->addTransfer('firstPayment', array(
	'amount'				=> '500',
	'debtorIban'			=> 'FI1350001540000056',
	'debtorBic'				=> 'OKOYFIHH',
	'debtorName'			=> 'Their Company',
	'debtorMandate'			=>  'AB12345',
	'debtorMandateSignDate'	=> '13.10.2012',
	'remittanceInformation'	=> 'Purpose of this direct debit'
));
// Retrieve the resulting XML
$directDebit->asXML();

// Create the initiating information
$groupHeader = new GroupHeader('SEPA File Identifier', 'Your Company Name');

// Some portuguese banks TransferInformation(
    '0.02', // Amount
    'FI1350001540000056', //IBAN of creditor
    'Their Corp' //Name of Creditor
    );
$transfer->setBic('OKOYFIHH'); // Set the BIC explicitly
$transfer->setRemittanceInformation('Transaction Description');
$sepa_transfer->setCode("SCOR"); // transaction code for this specific transfer, according to annex 5 (ISO codes billing/transfer reasons)
$sepa_transfer->setReference("INV20140101A-033"); // reference number to descript this transaction, i.e. an invoice

// Create a PaymentInformation the Transfer belongs to
$payment = new PaymentInformation(
    'Payment Info ID',
    'FR1420041010050500013M02606', // IBAN the money is transferred from
    'PSSTFRPPMON',  // BIC
    'My Corp' // Debitor Name
    );
// It's possible to add multiple Transfers in one Payment
$payment->addTransfer($transfer);

// It's possible to add multiple payments to one SEPA File
$sepaFile->addPaymentInformation($payment);

// Attach a dombuilder to the sepaFile to create the XML output
$domBuilder = DomBuilderFactory::createDomBuilder($sepaFile);

$domBuilder->asXml();