PHP library for creating SEPA XML documents for direct debit transactions
PHP library for creating SEPA XML documents for direct debit transactions.
composer install to install dependencies and generate the autoload.phpFirst we have to define some variables and create a configuration instance:
Create a config file (e.g. config/application.ini) to define your company name, IBAN, BIC and creditor ID. You can use config/_application.ini as template. Create a config instance via \Sephpa\Config\ConfigIni('config/application.ini')
Create a config instance via \Sephpa\Config\ConfigInline($name, $iban, $bic, $creditorId)
Next we have to create a file instance which leads to an XML file in the end.
As defined in the ebics specifications [http://www.ebics.de] one file may contain several payments (with e.g. different due dates or sequence types like "first" or "recurring"), but some banks do not support that. You might have to create one separate file per payment, if you have transactions with e.g. different due dates or sequence types.
Next create a payment instance, define the sequence type and the due date and add the payment to the file.
The last step is creating one or more transactions and adding them to the corresponding payment.
In the Transaction you define the customers name, IBAN, BIC, his mandate reference and its sign date, the amount of the transaction, the subject (this is shown in the customers account statement) and a reference, which is used as the "End-to-End-Id" (which might also be visible for the customer).
The last step is parsing/compiling the XML and saving it to a file.
See the Debit Example for a full example with one transaction.
:::php
$configuration = new ConfigIni('config/application.ini');
$file = new File($configuration);
$payment = new PaymentDebit(
$configuration,
PaymentDebit::SEQUENCE_TYPE_FIRST,
new DateTime('2013-12-20')
);
$file->addPayment($payment);
$debit = new Debit();
$debit
->setName('Customer #1')
->setIban('DE12123456781234567890')
->setBic('BANKDEXXXXX')
->setMandateReference('MANDATE')
->setMandateReferenceSignDate('2013-12-01')
->setAmount(35)
->setSubject('Order #12345')
->setReference('C123456');
$payment->addTransaction($debit);
$file->parse();
$file->save('debit.xml');`
Namespaces have been removed for this example. Find the full exmample in examples/debit.php