bmdevel / bav
BAV 提供了对德国银行账户(Konto)的验证
Requires
- php: >=7.2
- bmdevel/php-index: ~0.3
Requires (Dev)
- doctrine/orm: ^2
- phpcompatibility/php-compatibility: ^9.3
- phpunit/phpunit: ^8.4
Suggests
- ext-PDO: Allows storing bank information in a database
- ext-dom: Enables picking the download URI by xpath
- ext-mbstring: Enables UTF-8 support
- lib-curl: Enables API for downloading the bank file
- doctrine/orm: Support for Doctrine ORM data backend
README
BAV(银行账户验证器)是一个用于德国银行账户的验证库。它在其他方面基于https://www.bundesbank.de/Redaktion/DE/Downloads/Aufgaben/Unbarer_Zahlungsverkehr/pruefzifferberechnungsmethoden.pdf?__blob=publicationFile
安装
使用 Composer
{ "require": { "malkusch/bav": "^1" } }
配置
您可以直接使用 BAV。BAV 附带了一个默认配置(DefaultConfiguration
)
-
UTF-8
编码(如果支持) -
FileDataBackendContainer
。即它使用联邦银行的文件进行二分搜索。请注意,此数据后端在安装和更新操作中使用bav/data
目录。您必须确保此目录可写。 -
自动安装。您不需要调用任何安装脚本。容器将在首次执行时下载联邦银行文件。
-
更新计划,如果联邦银行文件过时,则触发 E_USER_NOTICE。
您可以通过调用 ConfigurationRegistry::setConfiguration()
或更理想的是创建 bav/configuration.php
文件来定义自己的配置,该文件返回一个 Configuration
对象
namespace malkusch\bav; $configuration = new DefaultConfiguration(); $pdo = new \PDO("mysql:host=localhost;dbname=test;charset=UTF8"); $configuration->setDataBackendContainer(new PDODataBackendContainer($pdo)); $configuration->setUpdatePlan(new AutomaticUpdatePlan()); return $configuration;
更新
联邦银行每月三月、六月、九月和十二月发布新文件。BAV 需要这些新文件。您有几种方法可以更新 bav
脚本
调用 bin/bav-update.php
。
程序化
use malkusch\bav\BAV; $bav = new BAV(); $bav->update();
自动
在 bav/configuration.php
中启用 AutomaticUpdatePlan
以自动更新
namespace malkusch\bav; $configuration = new DefaultConfiguration(); $configuration->setUpdatePlan(new AutomaticUpdatePlan()); return $configuration;
此自动更新计划将在关闭钩子中执行长时间运行更新操作。即它不会在正常操作期间打扰用户。
用法
您可以使用 API 外观 BAV
使用 BAV
-
BAV::isValidBank($bankID)
:对于现有银行 ID 返回 true。 -
BAV::isValidBankAccount($bankID, $account)
:对于现有银行的现有账户返回 true。 -
BAV::isValidAccount($account)
:此方法将账户与isValidBank()
上一次调用中的银行进行验证。 -
BAV::getValidBankFilterCallback()
:返回用于过滤银行验证的回调。 -
BAV::getValidAccountFilterCallback()
:返回用于过滤账户验证的回调。账户过滤器需要在银行过滤器之后调用。 -
BAV::getMainAgency()
:返回银行的总部。 -
BAV::getAgencies()
:返回更多机构。主要机构不包括在此列表中。此列表可能为空。
一个Agency
对象具有以下字段
示例
use malkusch\bav\BAV; $bav = new BAV(); $bankID = "10000000"; $account = "1234567890" // check for a bank var_dump( $bav->isValidBank($bankID) ); // check for a bank account var_dump( $bav->isValidBankAccount($bankID, $account) ); // filter validation var_dump( filter_var($bankID, FILTER_CALLBACK, $bav->getValidBankFilterCallback()), filter_var($account, FILTER_CALLBACK, $bav->getValidAccountFilterCallback()) ); // Get informations about a bank $agency = $bav->getMainAgency($bankID); echo "{$agency->getName()} {$agency->getCity()}\n";
另请参阅bav/docs/example.php
。
可选依赖
您可能需要
-
CURL:如果您提供
bav/data/banklist.txt
,则不需要CURL。 -
mbstring:BAV使用Unicode编码。您的PHP必须支持编译的
mb_*
函数。如果缺少这些函数,BAV只能使用ISO-8859-15编码。 -
PDO:如果您打算使用DBS,则需要使用
PDODataBackendContainer
。PDODataBackendContainer
需要PHP中编译了PDO
支持。 -
doctrine/orm:您可以使用
DoctrineBackendContainer
,它使用doctrine作为数据后端。
许可证和作者
本项目免费并受WTFPL协议保护。所以您想做什么都可以。但留下关于作者的信息会更好。
原始项目的作者,该项目为本项目提供了灵感,是Björn Wilmsmann。本项目的负责人是Markus Malkusch markus@malkusch.de。
捐赠
如果您喜欢BAV并且感觉慷慨,请在这里捐赠一些比特币:1335STSwu9hST4vcMRppEPgENMHD2r1REK