kouinkouin/be-bank-transfer-message

Generate and validate Belgian bank transfer structured messages

v0.1.4 2017-10-03 16:46 UTC

This package is not auto-updated.

Last update: 2024-11-18 18:03:14 UTC


README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

This package contains a validator and generator for structured messages included in Belgian bank transfers. Common use cases:

  • Automatic generation of order invoices.
  • Association of payment provider messages to orders stored in your application.

The structured message format adheres to the Febelfin Guidelines

Install

Via Composer

$ composer require kouinkouin/be-bank-transfer-message

Usage

Generate a structured message

Based on a random number

$transferMessage = new BeBankTransferMessage\TransferMessage();
echo transferMessage->getStructuredMessage();

Based on a predefined number

$transferMessage = new BeBankTransferMessage\TransferMessage(12345);
echo transferMessage->getStructuredMessage();

Change to a different predefined number

$transferMessage->setNumber(54321);
$transferMessage->generate();
echo transferMessage->getStructuredMessage();

Or a random number

$transferMessage->setNumber();
$transferMessage->generate();
echo transferMessage->getStructuredMessage();

The default, valid circumfix of a structured message is the plus sign. Optionally, it's possible to use asterisks as a circumfix, if your formatting demands it.

$transferMessage->setNumber();
$transferMessage->generate(TransferMessage::CIRCUMFIX_ASTERISK);
echo transferMessage->getStructuredMessage();

Validate a structured message

A valid message

$transferMessage = new BeBankTransferMessage\TransferMessage();
$transferMessage->setStructuredMessage('+++090/9337/55493+++');
$result = $transferMessage->validate();  // TRUE

An invalid message

$transferMessage = new BeBankTransferMessage\TransferMessage();
$transferMessage->setStructuredMessage('+++011/9337/55493+++');
$result = $transferMessage->validate();  // FALSE

Additionally the setter method will throw an TransferMessageException() if the format of the structured message is not valid.

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.