Download the PHP package marketpay/mt940 without Composer
On this page you can find all versions of the php package marketpay/mt940. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mt940
MarketPay/MT940
An MT940 bank statement parser for PHP
Installation
You can install MarketPay/MT940 using Composer. You can read more about Composer and its main repository at
http://packagist.org. First install Composer for your project using the instructions on the
Packagist home page, then define your dependency on MarketPay/MT940 in your composer.json
file.
This library follows the PSR-0 standard. You will need
a PSR-0 compliant autoloader to load the MarketPay/MT940 classes. Composer provides one for you in your
vendor/.composer/autoload.php
.
PSR-12 standard is for Code-Syntax.
Usage
Statement structure
The returned statements have the following properties. Not all banks supply
all properties (e.g. only few provide a transaction book date separately).
Properties that are not supplied will be null
.
MarketPay\MT940\StatementInterface
getNumber()
Statement sequence numbergetAccount()
An object implementingMarketPay\MT940\AccountInterface
getOpeningBalance()
An object implementingMarketPay\MT940\BalanceInterface
getClosingBalance()
An object implementingMarketPay\MT940\BalanceInterface
getTransactions()
An array of objects implementingMarketPay\MT940\TransactionInterface
MarketPay\MT940\AccountInterface
getNumber()
The account numbergetName()
The account holder name
MarketPay\MT940\BalanceInterface
getCurrency()
3-letter ISO 4217 currency codegetAmount()
Balance amountgetDate()
Balance date as a\DateTime
object
MarketPay\MT940\TransactionInterface
getContraAccount()
An object implementingMarketPay\MT940\AccountInterface
getAmount()
Transaction amountgetDescription()
Description textgetValueDate()
Date of the transaction as a\DateTime
getBookDate()
Date the transaction was booked as a\DateTime
getCode()
Get Code for this transactiongetRef()
Get Ref for this transactiongetBankRef()
Get BankRef for this transactiongetGVC()
Get GVC for this transactiongetTxText()
Get txText for this transactiongetPrimanota()
Get primanota for this transactiongetExtCode()
Get extCode for this transactiongetEref()
Get ERef for this transactiongetBIC()
Get BIC for this transactiongetIBAN()
Get IBAN for this transactiongetAccountHolder()
Get Account Holder for this transactiongetKref()
Get Kref for this transactiongetMref()
Get Mref for this transactiongetCred()
Get Cred for this transactiongetSvwz()
Get Svwz for this transaction
Supported banks
Currencly there are statement parsers for the following banks:
- ABN-AMRO
- Commerzbank
- Deutsche Bank
- German Bank
- ING
- Knab
- Landesbank Berlin
- NuaPay Bank
- Oldenburgische Landesbank
- PostFinance
- Rabobank
- SNS
- Sparkasse
- StarMoney
- Triodos Bank
- UniCredit Bank
Adding bank parsers
You can easily add your own parser to the statement reader.
When you add your own parser, the default list of parsers is cleared. You must add them back if you want the reader to support them as well.
You can also add your parser at a specific place in the parser chain. For example, this is how you add your parser before the ING parser.
Custom parsers should extend the MarketPay\MT940\Parser\AbstractParser
class.
Have a look at the parsers already implemented to see how to support your
bank. At the very minimum, you should implement the accept()
method.
Injecting classes
You can easily extend the build-in objects and inject them into the MT940 reader. This allows for easily integrating MT940 into your application. For example, by storing the statements in your database. You can inject them using the following methods:
setStatementClass($className)
defaults toMarketPay\MT940\Statement
setAccountClass($className)
defaults toMarketPay\MT940\Account
setContraAccountClass($className)
defaults toMarketPay\MT940\Account
setTransactionClass($className)
defaults toMarketPay\MT940\Transaction
setOpeningBalanceClass($className)
defaults toMarketPay\MT940\Balance
setClosingBalanceClass($className)
defaults toMarketPay\MT940\Balance
You can either specify the classname as a string, or provide a PHP callable that returns an object. Your classes do not have to extend the built-in classes but they must implement the proper interfaces.
The callable for the Statement
class is passed an AccountInterface
and the statement
sequence number as parameters. The callable for the Account
class and ContraAccount
class are passed the account number as parameter. The other callables are not passed
any variables.
If the callable for the Account
class or Statement
class returns null
then that
statement will be skipped by the parser.
An example, integrating MT940 with your ORM:
Contributing
If you have written a parser for your bank, I'd be happy to add it to the list of default parsers. Just send me a Pull Request with your parsers. Make sure that you also add a unit test for it that parses a test document. You can redact personal information from the test document (e.g. use '123456789' for the account number, etcetera).
I am also happy to implement a parser for you, if you prefer that. Just open an issue and I will contact you privately. I will need an unredacted MT940 file from your bank. It needs to be unredacted because the MT940 isn't well defined and can be fickle. If you redact it, it is possible that the parser I write will work on the file you supplied but not on the real thing. Of course, I will redact the file for you when I add it to my unit tests.
Do not add unredacted MT940 files in the issue tracker please. Send them to me privately. My e-mail address is listed in the source code files.
License
MarketPay\MT940 is licensed under the MIT license. See the LICENSE.txt file for the full details. The test files for the ABN-AMRO, ING, Rabobank and Triodos bank come from the dovadi/mt940 ruby parser. Their license can be found in the LICENSE.fixtures.txt file.
The test file for Sparkasse come from Dominic Richter / Powercloud GmbH. The Parser Commerzbank, Deutsche Bank, German Bank, Landesbank Berlin, NuaPay, Oldenburgische Landesbank, Sparkasse, StarMoney and Unicredit come from Powercloud GmbH.