drei-d / laravel-sepa-xml
Creates SEPA XML files
Requires
- php: ^8.4
- ext-dom: *
- laravel/framework: ^10|^11|^12|^13
Requires (Dev)
- larastan/larastan: ^3.15
- laravel/pint: ^1.32
- orchestra/testbench: ^11.3
- pestphp/pest: ^5.3
- pestphp/pest-plugin-laravel: ^5.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This project was made to create SEPA xml files in Laravel.
Dependencies
These dependencies are required:
- Laravel 10 or higher
- PHP 8.4 or higher
... and for some features, these are needed:
- ext-dom
- ext-iconv
Installation
This project is available via composer.
To install it, run:
composer install drei-d/laravel-sepa-xml
Configuration
This project comes with a predefined config.
In order to use this package, you need to customize it to your needs.
Publish the configuration by running:
php artisan vendor:publish --provider=DREID\\LaravelSepaXml\\Providers\\ServiceProvider
The configuration file should look like the following:
return [ 'from' => 'FROM EXAMPLE', 'iban' => 'IBAN EXAMPLE', 'bic' => 'BIC EXAMPLE', 'prefix' => 'PREFIX-EXAMPLE-', // group transactions as a single transfer 'batch_booking' => false ];
- Replace
FROM EXAMPLEwith your companies name. You should use caps lock and no special characters. - Replace
IBAN EXAMPLEwith the IBAN of the bank account you want to send money from. Do not include spaces. - Replace
BIC EXAMPLEwith the BIC of the bank account you want to send money from. Do not include spaces. - Replace
PREFIXwith a unique identifier for your project. This prefix is used to generate unique End-to-End-IDs for your transactions. - If you want to group your transactions as a single transfer, you can set
batch_bookingto true. If you are not familiar with batch booking, feel free to check out this post.
An example for our company would be:
return [ 'from' => 'DREID-D DIREKTWERBUNG GMBH CO KG', 'iban' => 'DE02120300000000202051', 'bic' => 'BYLADEM1001', 'prefix' => '3D-INTERN-', // group transactions as a single transfer 'batch_booking' => false ];
Usage
Saving to a file
You can create a new SEPA file using the provided Sepa facade, like this:
use DREID\LaravelSepaXml\Facades\Sepa; $creator = Sepa::create('T1-2026-') ->addTransaction( subject: 'Test-Subject for Transaction', amount: 49.95, // amount in EUR accountOwner: 'Max Mustermann', iban: 'DE02120300000000202051', // IBAN bic: 'BYLADEM1001', // BIC ) ->save('text.xml');
Getting the XML content as a string
Instead of saving to a file, you can also get the generated XML content like this:
use DREID\LaravelSepaXml\Facades\Sepa; $creator = Sepa::create('T1-2026-') ->addTransaction( // .. ) ->getContent();
Sanitizing the inputs
If you are not sure, whether your data contains (mostly forbidden) special characters or not, you can turn on the built-in sanitizer like this:
use DREID\LaravelSepaXml\Facades\Sepa; $creator = Sepa::create('T1-2026-') ->sanitized() ->addTransaction( // .. ) ->getContent();
Minifying the output
By default, the output gets formatted. You can also minify the XML instead:
use DREID\LaravelSepaXml\Facades\Sepa; $creator = Sepa::create('T1-2026-') ->minified() ->addTransaction( // .. ) ->getContent();
Using a different configuration per created file
If you need to create transactions from multiple accounts, you can pass a configuration class to the Sepa facade as well:
use DREID\LaravelSepaXml\Facades\Sepa; use DREID\LaravelSepaXml\DataTransferObjects\ConfigurationDto; $creator = Sepa::create( transactionNumber: 'T1-2026-', configurationDto: new ConfigurationDto( from: 'MAX MUSTERMANN', iban: 'DE02120300000000202051', bic: 'BYLADEM1001', prefix: 'TEST-', batchBooking: true, ) );